Fix empty classname resulting in undefined class of result element

This commit is contained in:
Fabian Stamm 2020-04-10 19:58:41 +02:00
parent b56e59f6d4
commit 3dbbc5b67a
10 changed files with 20 additions and 18 deletions

View File

@ -5,7 +5,7 @@ export enum ButtonFormats {
PRIMARY, PRIMARY,
SECONDARY, SECONDARY,
ERROR, ERROR,
SUCCESS SUCCESS,
} }
export interface IButtonProps extends JSX.HTMLAttributes<HTMLButtonElement> { export interface IButtonProps extends JSX.HTMLAttributes<HTMLButtonElement> {
@ -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 || "");
switch (format) { switch (format) {
case ButtonFormats.DEFAULT: case ButtonFormats.DEFAULT:

View File

@ -5,7 +5,7 @@ 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}>
{children} {children}
</div> </div>
); );

View File

@ -5,7 +5,7 @@ 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}>
{children} {children}
</div> </div>
); );

View File

@ -9,7 +9,7 @@ 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}>
{children} {children}
</button> </button>
); );

View File

@ -8,7 +8,7 @@ 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}>
{children} {children}
</header> </header>
); );

View File

@ -5,7 +5,7 @@ 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}>
{children} {children}
</button> </button>
); );

View File

@ -6,7 +6,7 @@ export function Input({
...props ...props
}: JSX.HTMLAttributes<HTMLInputElement>) { }: JSX.HTMLAttributes<HTMLInputElement>) {
return ( return (
<input className={"ht-inp " + className} {...props}> <input className={"ht-inp " + (className || "")} {...props}>
{children} {children}
</input> </input>
); );
@ -18,7 +18,7 @@ export function TextArea({
...props ...props
}: JSX.HTMLAttributes<HTMLTextAreaElement>) { }: JSX.HTMLAttributes<HTMLTextAreaElement>) {
return ( return (
<textarea className={"ht-inp " + className} {...props}> <textarea className={"ht-inp " + (className || "")} {...props}>
{children} {children}
</textarea> </textarea>
); );
@ -30,7 +30,7 @@ export function InputGroup({
...props ...props
}: JSX.HTMLAttributes<HTMLDivElement>) { }: JSX.HTMLAttributes<HTMLDivElement>) {
return ( return (
<div className={"ht-input-group " + className} {...props}> <div className={"ht-input-group " + (className || "")} {...props}>
{children} {children}
</div> </div>
); );
@ -74,7 +74,7 @@ export function InputSelect({
...props ...props
}: JSX.HTMLAttributes<HTMLSelectElement>) { }: JSX.HTMLAttributes<HTMLSelectElement>) {
return ( return (
<select className={"ht-inp " + className} {...props}> <select className={"ht-inp " + (className || "")} {...props}>
{children} {children}
</select> </select>
); );

View File

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

View File

@ -8,7 +8,9 @@ export function Modal({
}: JSX.HTMLAttributes<HTMLDivElement> & { hidden?: boolean }) { }: JSX.HTMLAttributes<HTMLDivElement> & { hidden?: boolean }) {
return ( return (
<div <div
className={"ht-modal " + className + (hidden ? "ht-modal-hidden" : "")} className={
"ht-modal " + (className || "") + (hidden ? "ht-modal-hidden" : "")
}
{...props} {...props}
> >
{children} {children}
@ -22,7 +24,7 @@ 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}>
{children} {children}
</div> </div>
); );
@ -34,7 +36,7 @@ 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}>
{children} {children}
</div> </div>
); );
@ -46,7 +48,7 @@ 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}>
{children} {children}
</div> </div>
); );

View File

@ -6,7 +6,7 @@ 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}>
{children} {children}
</div> </div>
); );