Skip to content

Commit

Permalink
class property supports array
Browse files Browse the repository at this point in the history
  • Loading branch information
FredericHeem committed May 18, 2024
1 parent e49b086 commit 1a21717
Show file tree
Hide file tree
Showing 68 changed files with 243 additions and 372 deletions.
2 changes: 0 additions & 2 deletions bau-css/bau-css.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,3 @@ export default function BauCss(input?: {
keyframes: (any) => string;
createGlobalStyles: (any) => any;
};

export function classNames(...cn: string[]): string;
3 changes: 0 additions & 3 deletions bau-css/classNames.d.ts

This file was deleted.

3 changes: 0 additions & 3 deletions bau-css/classNames.js

This file was deleted.

4 changes: 1 addition & 3 deletions bau-css/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@
"license": "BSD",
"files": [
"bau-css.js",
"bau-css.d.ts",
"classNames.js",
"classNames.d.ts"
"bau-css.d.ts"
],
"types": "bau-css.d.ts",
"keywords": [
Expand Down
7 changes: 3 additions & 4 deletions bau-ui/accordion/accordion.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { toPropsAndChildren } from "@grucloud/bau/bau.js";
import classNames from "@grucloud/bau-css/classNames.js";
import collapsible from "../collapsible";
import { Colors } from "../constants.js";

Expand Down Expand Up @@ -97,7 +96,7 @@ export default function (context, options = {}) {
const AccordionHeader = () =>
h3(
{
class: () => classNames(itemNameState.val == name && "active"),
class: () => itemNameState.val == name && "active",
},
button(
{
Expand All @@ -123,15 +122,15 @@ export default function (context, options = {}) {

return li(
{
class: classNames(color, variant, size),
class: [color, variant, size],
onclick: onclick(name),
},
Collapsible({ Header: AccordionHeader, Content: AccordionContent })
);
};
return div(
{
class: classNames("accordion", className, options?.class, props.class),
class: ["accordion", className, options?.class, props.class],
},
ul(data.map(AccordionItem))
);
Expand Down
7 changes: 3 additions & 4 deletions bau-ui/alert/alert.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { toPropsAndChildren } from "@grucloud/bau/bau.js";
import classNames from "@grucloud/bau-css/classNames.js";
import { Colors } from "../constants.js";

import button from "../button";
Expand Down Expand Up @@ -97,16 +96,16 @@ export default function (context, options = {}) {
return div(
{
...props,
class: classNames(
class: [
"alert",
`alert-${variant}`,
options.class,
variant,
color,
size,
className,
props.class
),
props.class,
],
role: "alert",
},
i({ class: "icon" }, severityMap[color]),
Expand Down
5 changes: 1 addition & 4 deletions bau-ui/alertStack/alertStack.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
import { toPropsAndChildren } from "@grucloud/bau/bau.js";
import classNames from "@grucloud/bau-css/classNames.js";

export default (context, options = {}) => {
const { bau, css, keyframes } = context;
const { limit = 10, deleteAfterDuration = 15e3 } = options;
Expand Down Expand Up @@ -87,7 +84,7 @@ export default (context, options = {}) => {

return div(
{
class: classNames(styles.stack, options?.class, props.class),
class: [styles.stack, options?.class, props.class],
},
bau.loop(messagesState, div(), AlertItem)
);
Expand Down
4 changes: 1 addition & 3 deletions bau-ui/animate/animate.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import classNames from "@grucloud/bau-css/classNames.js";

export default function (context, options = {}) {
const { bau, window } = context;
const { div } = bau.tags;
Expand All @@ -11,7 +9,7 @@ export default function (context, options = {}) {
) {
return div(
{
class: classNames("animate", options?.class, props.class),
class: ["animate", options?.class, props.class],
bauChildMutated: ({ record, element }) => {
// Removed Nodes
[...record.removedNodes].forEach((childNode) => {
Expand Down
20 changes: 9 additions & 11 deletions bau-ui/autocomplete/autocomplete.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import classNames from "@grucloud/bau-css/classNames.js";
import { toPropsAndChildren } from "@grucloud/bau/bau.js";
import popover from "../popover/popover.js";
import button from "../button/button.js";
Expand Down Expand Up @@ -238,19 +237,18 @@ export default function (context, componentOptions = {}) {
});

const contentEl = div(
{ class: classNames(variant, color, size, "content") },
{ class: [variant, color, size, "content"] },
inputEl,
() =>
List(
{ class: classNames(variant, color, size) },
{ class: [variant, color, size] },
optionsFilteredState.val.map((option, index) =>
li(
{
class: () =>
classNames(
itemIndexActive.val == index && "active",
isOptionSelected(selectedState)(option) && "selected"
),
class: () => [
itemIndexActive.val == index && "active",
isOptionSelected(selectedState)(option) && "selected",
],
onclick: onclickItem({ option, index }),
},
Option(option)
Expand All @@ -272,12 +270,12 @@ export default function (context, componentOptions = {}) {
return div(
{
...props,
class: classNames(
class: [
"autocomplete",
className,
componentOptions?.class,
props?.class
),
props?.class,
],
},
bau.bind({
deps: [selectedState],
Expand Down
30 changes: 14 additions & 16 deletions bau-ui/avatar/avatar.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { toPropsAndChildren } from "@grucloud/bau/bau.js";
import classNames from "@grucloud/bau-css/classNames.js";
import skeleton from "../skeleton";

export default function (context, options = {}) {
Expand Down Expand Up @@ -60,7 +59,7 @@ export default function (context, options = {}) {
...children
] = toPropsAndChildren(args);
const Skeleton = skeleton(context, {
class: classNames(
class: [
css`
position: absolute;
top: 0;
Expand All @@ -69,12 +68,12 @@ export default function (context, options = {}) {
width: ${width}px;
`,
options?.class,
props.class
),
props.class,
],
});

return div(
{ class: classNames(className, options?.class, props.class) },
{ class: [className, options?.class, props.class] },
() => loadingState.val && Skeleton(),
() => errorState.val && alt,
img({
Expand All @@ -83,17 +82,16 @@ export default function (context, options = {}) {
height,
onload,
onerror,
class: () =>
classNames(
!loadingState.val && "visible",
errorState.val && "hide",
color,
variant,
size,
className,
options?.class,
props.class
),
class: () => [
!loadingState.val && "visible",
errorState.val && "hide",
color,
variant,
size,
className,
options?.class,
props.class,
],
...props,
})
);
Expand Down
5 changes: 2 additions & 3 deletions bau-ui/badge/badge.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import classNames from "@grucloud/bau-css/classNames.js";
import { toPropsAndChildren } from "@grucloud/bau/bau.js";

export default function (context, options = {}) {
Expand Down Expand Up @@ -40,9 +39,9 @@ export default function (context, options = {}) {
return span(
{
...props,
class: classNames("badge", className, options?.class, props?.class),
class: ["badge", className, options?.class, props?.class],
},
span({ class: classNames(color, variant, size) }, content),
span({ class: [color, variant, size] }, content),
...children
);
};
Expand Down
5 changes: 2 additions & 3 deletions bau-ui/breadcrumbs/breadcrumbs.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { toPropsAndChildren } from "@grucloud/bau/bau.js";
import classNames from "@grucloud/bau-css/classNames.js";
import button from "../button/button.js";

export default function (context, options = {}) {
Expand Down Expand Up @@ -54,7 +53,7 @@ export default function (context, options = {}) {
return ul(
{
...props,
class: classNames(className, options?.class, props?.class),
class: [className, options?.class, props?.class],
},
items.map(({ href, name }) =>
li(
Expand All @@ -64,7 +63,7 @@ export default function (context, options = {}) {
color,
variant,
size,
class: classNames(color, variant, size),
class: [color, variant, size],
},
name
)
Expand Down
7 changes: 3 additions & 4 deletions bau-ui/button/button.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { toPropsAndChildren } from "@grucloud/bau/bau.js";
import classNames from "@grucloud/bau-css/classNames.js";

import { Colors } from "../constants.js";

Expand Down Expand Up @@ -101,15 +100,15 @@ export default function (context, options = {}) {
{
...(!href && { type: "button" }),
...props,
class: classNames(
class: [
"button",
options.class,
variant,
size,
color,
className,
props.class
),
props.class,
],
href,
},
children
Expand Down
7 changes: 3 additions & 4 deletions bau-ui/buttonGroup/buttonGroup.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import classNames from "@grucloud/bau-css/classNames.js";
import { toPropsAndChildren } from "@grucloud/bau/bau.js";
import { Colors } from "../constants.js";

Expand Down Expand Up @@ -60,15 +59,15 @@ export default function (context, options = {}) {
return div(
{
...props,
class: classNames(
class: [
"button-group",
variant,
color,
size,
className,
options?.class,
props?.class
),
props?.class,
],
},
...children
);
Expand Down
7 changes: 3 additions & 4 deletions bau-ui/calendar/calendar.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import classNames from "@grucloud/bau-css/classNames.js";
import { toPropsAndChildren } from "@grucloud/bau/bau.js";
import { Colors } from "../constants.js";

Expand Down Expand Up @@ -40,15 +39,15 @@ export default function (context, options = {}) {
{
...props,
type: "date",
class: classNames(
class: [
"calendar",
className,
color,
variant,
size,
options?.class,
props?.class
),
props?.class,
],
},
...children
);
Expand Down
13 changes: 3 additions & 10 deletions bau-ui/carousel/carousel.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import classNames from "@grucloud/bau-css/classNames.js";
import { toPropsAndChildren } from "@grucloud/bau/bau.js";

export default function (context, options = {}) {
Expand Down Expand Up @@ -76,25 +75,19 @@ export default function (context, options = {}) {
return div(
{
...props,
class: classNames(
"carousel",
size,
className,
options?.class,
props?.class
),
class: ["carousel", size, className, options?.class, props?.class],
},

div(
{
class: classNames("control", "control-previous"),
class: ["control", "control-previous"],
onclick: onclickPrevious,
},
Previous()
),
div(
{
class: classNames("control", "control-next"),
class: ["control", "control-next"],
onclick: onclickNext,
},
Next()
Expand Down
10 changes: 1 addition & 9 deletions bau-ui/checkbox/checkbox.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { toPropsAndChildren } from "@grucloud/bau/bau.js";
import classNames from "@grucloud/bau-css/classNames.js";

export default function (context, options = {}) {
const { bau, css } = context;
Expand Down Expand Up @@ -79,14 +78,7 @@ export default function (context, options = {}) {
return input({
type: "checkbox",
...props,
class: classNames(
className,
color,
variant,
size,
options?.class,
props?.class
),
class: [className, color, variant, size, options?.class, props?.class],
});
};
}
Loading

0 comments on commit 1a21717

Please sign in to comment.