Fix some problems with class and className

This commit is contained in:
Fabian Stamm 2020-04-21 00:47:38 +02:00
parent 3833510262
commit 81f124378f
12 changed files with 50 additions and 42 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "@hibas123/theme-preact", "name": "@hibas123/theme-preact",
"version": "1.0.6", "version": "1.0.7",
"description": "", "description": "",
"main": "out/index.js", "main": "out/index.js",
"dependencies": { "dependencies": {

View File

@ -16,11 +16,12 @@ export default function Button({
children, children,
format, format,
className, className,
class: c,
...props ...props
}: IButtonProps) { }: IButtonProps) {
let cl = "ht-btn"; let cl = "ht-btn";
if (className) cl += " " + (className || "") + (props.class || ""); if (className) cl += " " + (className || "") + (c || "");
switch (format) { switch (format) {
case ButtonFormats.DEFAULT: case ButtonFormats.DEFAULT:

View File

@ -1,14 +1,12 @@
import { h, JSX } from "preact"; import { h, JSX } from "preact";
export default function Card({ export default function Card({
className, className,
class: c,
children, children,
...props ...props
}: JSX.HTMLAttributes<HTMLDivElement>) { }: JSX.HTMLAttributes<HTMLDivElement>) {
return ( return (
<div <div className={"ht-card " + (className || "") + (c || "")} {...props}>
className={"ht-card " + (className || "") + (props.class || "")}
{...props}
>
{children} {children}
</div> </div>
); );

View File

@ -2,11 +2,12 @@ import { h, JSX } from "preact";
export default function Container({ export default function Container({
className, className,
children, children,
class: c,
...props ...props
}: JSX.HTMLAttributes<HTMLDivElement>) { }: JSX.HTMLAttributes<HTMLDivElement>) {
return ( return (
<div <div
className={"ht-container " + (className || "") + (props.class || "")} className={"ht-container " + (className || "") + (c || "")}
{...props} {...props}
> >
{children} {children}

View File

@ -4,15 +4,15 @@ export default function Fab({
className, className,
children, children,
alignLeft, alignLeft,
class: c,
...props ...props
}: JSX.HTMLAttributes<HTMLButtonElement> & { alignLeft: boolean }) { }: JSX.HTMLAttributes<HTMLButtonElement> & {
alignLeft: boolean;
}) {
let cl = "ht-fab " + (alignLeft ? "ht-fab-left " : ""); let cl = "ht-fab " + (alignLeft ? "ht-fab-left " : "");
return ( return (
<button <button className={cl + (className || "") + (c || "")} {...props}>
className={cl + (className || "") + (props.class || "")}
{...props}
>
{children} {children}
</button> </button>
); );

View File

@ -5,11 +5,12 @@ import { h, JSX } from "preact";
export default function Header({ export default function Header({
children, children,
className, className,
class: c,
...props ...props
}: JSX.HTMLAttributes<HTMLDivElement>) { }: JSX.HTMLAttributes<HTMLDivElement>) {
return ( return (
<header <header
className={"ht-header " + (className || "") + (props.class || "")} className={"ht-header " + (className || "") + (c || "")}
{...props} {...props}
> >
{children} {children}

View File

@ -2,13 +2,12 @@ import { h, JSX } from "preact";
export default function IconButton({ export default function IconButton({
children, children,
className, className,
class: c,
...props ...props
}: JSX.HTMLAttributes<HTMLButtonElement>) { }: JSX.HTMLAttributes<HTMLButtonElement>) {
return ( return (
<button <button
className={ className={"ht-btn ht-btn-icon " + (className || "") + (c || "")}
"ht-btn ht-btn-icon " + (className || "") + (props.class || "")
}
{...props} {...props}
> >
{children} {children}

View File

@ -3,10 +3,11 @@ import { h, JSX } from "preact";
export function Input({ export function Input({
className, className,
children, children,
class: c,
...props ...props
}: JSX.HTMLAttributes<HTMLInputElement>) { }: JSX.HTMLAttributes<HTMLInputElement>) {
return ( return (
<input className={"ht-inp " + (className || "")} {...props}> <input className={"ht-inp " + (className || "") + (c || "")} {...props}>
{children} {children}
</input> </input>
); );
@ -15,10 +16,14 @@ export function Input({
export function TextArea({ export function TextArea({
className, className,
children, children,
class: c,
...props ...props
}: JSX.HTMLAttributes<HTMLTextAreaElement>) { }: JSX.HTMLAttributes<HTMLTextAreaElement>) {
return ( return (
<textarea className={"ht-inp " + (className || "")} {...props}> <textarea
className={"ht-inp " + (className || "") + (c || "")}
{...props}
>
{children} {children}
</textarea> </textarea>
); );
@ -27,10 +32,14 @@ export function TextArea({
export function InputGroup({ export function InputGroup({
className, className,
children, children,
class: c,
...props ...props
}: JSX.HTMLAttributes<HTMLDivElement>) { }: JSX.HTMLAttributes<HTMLDivElement>) {
return ( return (
<div className={"ht-input-group " + (className || "")} {...props}> <div
className={"ht-input-group " + (className || "") + (c || "")}
{...props}
>
{children} {children}
</div> </div>
); );
@ -70,11 +79,12 @@ export function InputRadio({
export function InputSelect({ export function InputSelect({
className, className,
class: c,
children, children,
...props ...props
}: JSX.HTMLAttributes<HTMLSelectElement>) { }: JSX.HTMLAttributes<HTMLSelectElement>) {
return ( return (
<select className={"ht-inp " + (className || "")} {...props}> <select className={"ht-inp " + (className || "") + c} {...props}>
{children} {children}
</select> </select>
); );

View File

@ -9,6 +9,7 @@ export default function List({
clickable, clickable,
divider, divider,
className, className,
class: c,
children, children,
...props ...props
}: JSX.HTMLAttributes<HTMLUListElement> & IListProps) { }: JSX.HTMLAttributes<HTMLUListElement> & IListProps) {
@ -18,7 +19,7 @@ export default function List({
if (divider) cl += "ht-list-divider "; if (divider) cl += "ht-list-divider ";
return ( return (
<ul className={cl + (className || "") + (props.class || "")} {...props}> <ul className={cl + (className || "") + c} {...props}>
{children} {children}
</ul> </ul>
); );

View File

@ -38,14 +38,13 @@ export function ModalTitle({
export function ModalContent({ export function ModalContent({
className, className,
class: c,
children, children,
...props ...props
}: JSX.HTMLAttributes<HTMLDivElement>) { }: JSX.HTMLAttributes<HTMLDivElement>) {
return ( return (
<div <div
className={ className={"ht-modal-content " + (className || "") + (c || "")}
"ht-modal-content " + (className || "") + (props.class || "")
}
{...props} {...props}
> >
{children} {children}
@ -55,14 +54,13 @@ export function ModalContent({
export function ModalActions({ export function ModalActions({
className, className,
class: c,
children, children,
...props ...props
}: JSX.HTMLAttributes<HTMLDivElement>) { }: JSX.HTMLAttributes<HTMLDivElement>) {
return ( return (
<div <div
className={ className={"ht-modal-action " + (className || "") + (c || "")}
"ht-modal-action " + (className || "") + (props.class || "")
}
{...props} {...props}
> >
{children} {children}

View File

@ -2,14 +2,12 @@ import { h, JSX } from "preact";
export default function Table({ export default function Table({
className, className,
class: c,
children, children,
...props ...props
}: JSX.HTMLAttributes<HTMLDivElement>) { }: JSX.HTMLAttributes<HTMLDivElement>) {
return ( return (
<div <div className={"ht-table " + (className || "") + (c || "")} {...props}>
className={"ht-table " + (className || "") + (props.class || "")}
{...props}
>
{children} {children}
</div> </div>
); );

View File

@ -1,18 +1,19 @@
import "@hibas123/theme/out/prefix.css"; import "@hibas123/theme/out/prefix.css";
import Button, { ButtonFormats, IButtonProps } from "./Button"; import Theme, {
import Card from "./Card"; IThemeProps,
ThemeModes,
IThemeContext,
ThemeContext,
} from "./Theme";
import Container from "./Container"; import Container from "./Container";
import Button, { ButtonFormats, IButtonProps } from "./Button";
import Fab from "./Fab"; import Fab from "./Fab";
import Card from "./Card";
import Header from "./Header"; import Header from "./Header";
import IconButton from "./IconButton"; import IconButton from "./IconButton";
import List from "./List"; import List from "./List";
export { Modal, ModalActions, ModalContent, ModalTitle } from "./Modal";
import Table from "./Table"; import Table from "./Table";
import Theme, {
IThemeContext,
IThemeProps,
ThemeContext,
ThemeModes,
} from "./Theme";
export { export {
IInputCheckboxProps, IInputCheckboxProps,
@ -24,11 +25,13 @@ export {
InputSelect, InputSelect,
TextArea, TextArea,
} from "./Input"; } from "./Input";
export { Modal, ModalActions, ModalContent, ModalTitle } from "./Modal";
export { export {
Theme, Theme,
IThemeProps, IThemeProps,
ThemeModes, ThemeModes,
IThemeContext,
ThemeContext,
Container, Container,
Button, Button,
ButtonFormats, ButtonFormats,
@ -39,6 +42,4 @@ export {
Header, Header,
List, List,
Table, Table,
IThemeContext,
ThemeContext,
}; };