Skip to content

Commit

Permalink
Merge pull request #126 from grucloud/toPropsAndChildren
Browse files Browse the repository at this point in the history
To props and children
  • Loading branch information
FredericHeem authored Nov 16, 2024
2 parents 2345523 + 78a1cf5 commit dbb3cf8
Show file tree
Hide file tree
Showing 45 changed files with 173 additions and 123 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,5 +110,6 @@ const bau = Bau();
const { div } = bau.tags;
```

- Bau reactive functions can return an array of elements, the equivalent of a React Fragment.
- Bau promotes only one paradigm: views derive from the state. Van could mix paradigms, imperative and state derived view. The imperative way is when your code directly maniplates the DOM, in the same way as vanilla js and jquery. This style of programming is error prone, therefore, preventing its use makes bau _hard to misuse_
- Bau supports undefined or null attribute, see [issue 39](https://github.com/vanjs-org/van/pull/39)
4 changes: 2 additions & 2 deletions bau-ui/alert/alert.js
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ export default function (context, options = {}) {
onRemove,
...props
},
...children
children,
] = toPropsAndChildren(args);

return div(
Expand All @@ -111,7 +111,7 @@ export default function (context, options = {}) {
role: "alert",
},
span({ class: "icon" }, severityMap[color]),
div({ class: "content" }, ...children),
div({ class: "content" }, children),
onRemove && CloseIcon({ onclick: onRemove })
);
};
Expand Down
2 changes: 1 addition & 1 deletion bau-ui/alertStack/alertStack.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export default (context, options = {}) => {
}
};

return function AlertStack(props = {}, ...children) {
return function AlertStack(props = {}) {
const remove = ({ id }) => {
setStatus({ id, status: "removing" });
const idx = messagesState.val.findIndex((message) => message.id === id);
Expand Down
2 changes: 1 addition & 1 deletion bau-ui/autocomplete/autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export default function (context, componentOptions = {}) {
loading,
...props
},
...children
children,
] = toPropsAndChildren(args);

const Popover = popover(context);
Expand Down
2 changes: 1 addition & 1 deletion bau-ui/avatar/avatar.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export default function (context, options = {}) {
alt,
...props
},
...children
children,
] = toPropsAndChildren(args);
const Skeleton = skeleton(context, {
class: [
Expand Down
4 changes: 2 additions & 2 deletions bau-ui/badge/badge.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@ export default function (context, options = {}) {
content,
...props
},
...children
children,
] = toPropsAndChildren(args);
return span(
{
...props,
class: ["badge", className, options?.class, props?.class],
},
span({ class: [color, variant, size] }, content),
...children
children
);
};
}
2 changes: 1 addition & 1 deletion bau-ui/breadcrumbs/breadcrumbs.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export default function (context, options = {}) {
items,
...props
},
...children
children,
] = toPropsAndChildren(args);
return ul(
{
Expand Down
2 changes: 1 addition & 1 deletion bau-ui/button/button.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export default function (context, options = {}) {
href,
...props
},
...children
children,
] = toPropsAndChildren(args);

const tagButton = href ? bau.tags.a : bau.tags.button;
Expand Down
4 changes: 2 additions & 2 deletions bau-ui/buttonGroup/buttonGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export default function (context, options = {}) {
color = options.color ?? "neutral",
...props
},
...children
children,
] = toPropsAndChildren(args);

return div(
Expand All @@ -69,7 +69,7 @@ export default function (context, options = {}) {
props?.class,
],
},
...children
children
);
};
}
4 changes: 2 additions & 2 deletions bau-ui/calendar/calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export default function (context, options = {}) {
color = options.color ?? "neutral",
...props
},
...children
children,
] = toPropsAndChildren(args);
return input(
{
Expand All @@ -49,7 +49,7 @@ export default function (context, options = {}) {
props?.class,
],
},
...children
children
);
};
}
2 changes: 1 addition & 1 deletion bau-ui/checkbox/checkbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export default function (context, options = {}) {
color = options.color ?? "neutral",
...props
},
...children
children,
] = toPropsAndChildren(args);

return input({
Expand Down
4 changes: 2 additions & 2 deletions bau-ui/chip/chip.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ export default function (context, options = {}) {
onclick,
...props
},
...children
children,
] = toPropsAndChildren(args);

return span(
Expand All @@ -56,7 +56,7 @@ export default function (context, options = {}) {
props.class,
],
},
...children
children
);
};
}
4 changes: 2 additions & 2 deletions bau-ui/divider/divider.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,14 @@ export default function (context, options = {}) {
color = options.color ?? "neutral",
...props
},
...children
children,
] = toPropsAndChildren(args);
return div(
{
...props,
class: ["divider", size, className, options?.class, props?.class],
},
div({ class: "content" }, ...children)
div({ class: "content" }, children)
);
};
}
6 changes: 2 additions & 4 deletions bau-ui/drawer/drawer.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,8 @@ export default function (context, options) {
`;

return function Drawer(...args) {
let [
{ color, variant = "outline", size, openState, ...props },
...children
] = toPropsAndChildren(args);
let [{ color, variant = "outline", size, openState, ...props }, children] =
toPropsAndChildren(args);
return div(
{ class: [className, options?.class, props.class] },
// Overlay
Expand Down
2 changes: 1 addition & 1 deletion bau-ui/dropdownMenu/dropdownMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default function (context, componentOptions = {}) {
items,
...props
},
...children
children,
] = toPropsAndChildren(args);

const itemIndexActive = bau.state(0);
Expand Down
2 changes: 1 addition & 1 deletion bau-ui/examples/bau-storybook/src/landingPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default function (context) {
gap: 1rem;
`,
},
...children
children
)
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export default (context: Context) => {
}
`,
},
...children
children
);

return () => {
Expand Down
2 changes: 1 addition & 1 deletion bau-ui/fileInput/fileInput.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export default function (context, options = {}) {
`,
};

return function FileInput(props, ...children) {
return function FileInput(props) {
const {
size = options.size ?? "md",
variant = options.variant ?? "outline",
Expand Down
4 changes: 2 additions & 2 deletions bau-ui/form/form.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export default function (context, options = {}) {
content,
...props
},
...children
children,
] = toPropsAndChildren(args);
return form(
{
Expand All @@ -72,7 +72,7 @@ export default function (context, options = {}) {
props?.class,
],
},
...children
children
);
};
}
4 changes: 2 additions & 2 deletions bau-ui/keyValueList/keyValueList.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,14 @@ export default function (context, options = {}) {
color = options.color ?? "neutral",
...props
},
...children
children,
] = toPropsAndChildren(args);
return ul(
{
...props,
class: ["keyValueList", className, options?.class, props?.class],
},
...children
children
);
};
}
4 changes: 2 additions & 2 deletions bau-ui/list/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default function (context, options = {}) {
color = options.color ?? "neutral",
...props
},
...children
children,
] = toPropsAndChildren(args);
return ul(
{
Expand All @@ -57,7 +57,7 @@ export default function (context, options = {}) {
props?.class.join(" "),
],
},
...children
children
);
};
}
2 changes: 1 addition & 1 deletion bau-ui/loadingButton/loadingButton.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export default function (context, options = {}) {
loading,
...props
},
...children
children,
] = toPropsAndChildren(args);

const Button = button(context);
Expand Down
2 changes: 1 addition & 1 deletion bau-ui/modal/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export default function (context, options = {}) {
color = options.color ?? "neutral",
...props
},
...children
children,
] = toPropsAndChildren(args);

const dialogEl = dialog(
Expand Down
2 changes: 1 addition & 1 deletion bau-ui/multiSelect/multiSelect.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export default function (context, componentOptions = {}) {
loading,
...props
},
...children
children,
] = toPropsAndChildren(args);

const Spinner = spinner(context, { variant, color, size });
Expand Down
4 changes: 2 additions & 2 deletions bau-ui/paper/paper.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,14 @@ export default function (context, options = {}) {
color = options.color ?? "neutral",
...props
},
...children
children,
] = toPropsAndChildren(args);
return div(
{
...props,
class: ["paper", size, className, options?.class, props?.class],
},
...children
children
);
};
}
6 changes: 3 additions & 3 deletions bau-ui/resizable/resizable.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ export default function (context, options = {}) {
`;

function PanelGroup(...args) {
let [props, ...children] = toPropsAndChildren(args);
let [props, children] = toPropsAndChildren(args);

return section(
{
Expand All @@ -54,7 +54,7 @@ export default function (context, options = {}) {
}

function Panel(...args) {
let [props, ...children] = toPropsAndChildren(args);
let [props, children] = toPropsAndChildren(args);

return article(
{
Expand All @@ -66,7 +66,7 @@ export default function (context, options = {}) {
}

function Handle(...args) {
let [props, ...children] = toPropsAndChildren(args);
let [props, children] = toPropsAndChildren(args);

// The current position of mouse
let _x = 0;
Expand Down
2 changes: 1 addition & 1 deletion bau-ui/select/select.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ export default function (context, componentOptions = {}) {
loading,
...props
},
...children
children,
] = toPropsAndChildren(args);

const Spinner = spinner(context, { variant, color, size });
Expand Down
2 changes: 1 addition & 1 deletion bau-ui/selectNative/selectNative.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default function (context, componentOptions = {}) {
color = componentOptions.color ?? "neutral",
...props
},
...children
children,
] = toPropsAndChildren(args);

return select(
Expand Down
4 changes: 2 additions & 2 deletions bau-ui/skeleton/skeleton.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ export default function (context, options = {}) {
color = options.color ?? "neutral",
...props
},
...children
children,
] = toPropsAndChildren(args);
return div(
{
...props,
class: ["skeleton", size, className, options?.class, props?.class],
},
...children
children
);
};
}
4 changes: 2 additions & 2 deletions bau-ui/slider/slider.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default function (context, options = {}) {
color = options.color ?? "neutral",
...props
},
...children
children,
] = toPropsAndChildren(args);

return input(
Expand All @@ -44,7 +44,7 @@ export default function (context, options = {}) {
props.class,
],
},
...children
children
);
};
}
Loading

0 comments on commit dbb3cf8

Please sign in to comment.