Allow using classname and class

This commit is contained in:
Fabian Stamm 2020-04-10 20:08:21 +02:00
parent 4cae31a72d
commit 20aaa80626
11 changed files with 51 additions and 17 deletions

View File

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

View File

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

View File

@ -5,7 +5,10 @@ export default function Card({
...props ...props
}: JSX.HTMLAttributes<HTMLDivElement>) { }: JSX.HTMLAttributes<HTMLDivElement>) {
return ( return (
<div className={"ht-card " + (className || "")} {...props}> <div
className={"ht-card " + (className || "") + (props.class || "")}
{...props}
>
{children} {children}
</div> </div>
); );

View File

@ -5,7 +5,10 @@ export default function Container({
...props ...props
}: JSX.HTMLAttributes<HTMLDivElement>) { }: JSX.HTMLAttributes<HTMLDivElement>) {
return ( return (
<div className={"ht-container " + (className || "")} {...props}> <div
className={"ht-container " + (className || "") + (props.class || "")}
{...props}
>
{children} {children}
</div> </div>
); );

View File

@ -9,7 +9,10 @@ export default function Fab({
let cl = "ht-fab " + (alignLeft ? "ht-fab-left " : ""); let cl = "ht-fab " + (alignLeft ? "ht-fab-left " : "");
return ( return (
<button className={cl + (className || "")} {...props}> <button
className={cl + (className || "") + (props.class || "")}
{...props}
>
{children} {children}
</button> </button>
); );

View File

@ -8,7 +8,10 @@ export default function Header({
...props ...props
}: JSX.HTMLAttributes<HTMLDivElement>) { }: JSX.HTMLAttributes<HTMLDivElement>) {
return ( return (
<header className={"ht-header " + (className || "")} {...props}> <header
className={"ht-header " + (className || "") + (props.class || "")}
{...props}
>
{children} {children}
</header> </header>
); );

View File

@ -5,7 +5,12 @@ export default function IconButton({
...props ...props
}: JSX.HTMLAttributes<HTMLButtonElement>) { }: JSX.HTMLAttributes<HTMLButtonElement>) {
return ( return (
<button className={"ht-btn ht-btn-icon " + (className || "")} {...props}> <button
className={
"ht-btn ht-btn-icon " + (className || "") + (props.class || "")
}
{...props}
>
{children} {children}
</button> </button>
); );

View File

@ -17,10 +17,8 @@ export default function List({
if (divider) cl += "ht-list-divider "; if (divider) cl += "ht-list-divider ";
cl += className || "";
return ( return (
<ul className={cl} {...props}> <ul className={cl + (className || "") + (props.class || "")} {...props}>
{children} {children}
</ul> </ul>
); );

View File

@ -9,7 +9,10 @@ export function Modal({
return ( return (
<div <div
className={ className={
"ht-modal " + (className || "") + (hidden ? "ht-modal-hidden" : "") "ht-modal " +
(className || "") +
(props.class || "") +
(hidden ? "ht-modal-hidden" : "")
} }
{...props} {...props}
> >
@ -24,7 +27,10 @@ export function ModalTitle({
...props ...props
}: JSX.HTMLAttributes<HTMLDivElement>) { }: JSX.HTMLAttributes<HTMLDivElement>) {
return ( return (
<div className={"ht-modal-title " + (className || "")} {...props}> <div
className={"ht-modal-title " + (className || "") + (props.class || "")}
{...props}
>
{children} {children}
</div> </div>
); );
@ -36,7 +42,12 @@ export function ModalContent({
...props ...props
}: JSX.HTMLAttributes<HTMLDivElement>) { }: JSX.HTMLAttributes<HTMLDivElement>) {
return ( return (
<div className={"ht-modal-content " + (className || "")} {...props}> <div
className={
"ht-modal-content " + (className || "") + (props.class || "")
}
{...props}
>
{children} {children}
</div> </div>
); );
@ -48,7 +59,12 @@ export function ModalActions({
...props ...props
}: JSX.HTMLAttributes<HTMLDivElement>) { }: JSX.HTMLAttributes<HTMLDivElement>) {
return ( return (
<div className={"ht-modal-action " + (className || "")} {...props}> <div
className={
"ht-modal-action " + (className || "") + (props.class || "")
}
{...props}
>
{children} {children}
</div> </div>
); );

View File

@ -6,7 +6,10 @@ export default function Table({
...props ...props
}: JSX.HTMLAttributes<HTMLDivElement>) { }: JSX.HTMLAttributes<HTMLDivElement>) {
return ( return (
<div className={"ht-table " + (className || "")} {...props}> <div
className={"ht-table " + (className || "") + (props.class || "")}
{...props}
>
{children} {children}
</div> </div>
); );

View File

@ -4,7 +4,7 @@ import { useEffect, useState, useMemo } from "preact/hooks";
export enum ThemeModes { export enum ThemeModes {
AUTO, AUTO,
LIGHT, LIGHT,
DARK DARK,
} }
export interface IThemeProps { export interface IThemeProps {
@ -95,7 +95,7 @@ export default function Theme({ mode, children, ...colors }: IThemeProps) {
colors.onPrimary, colors.onPrimary,
colors.onSecondary, colors.onSecondary,
colors.onError, colors.onError,
colors.onSuccess colors.onSuccess,
]); ]);
return ( return (