@blockle/blocks 0.8.5 → 0.8.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -18
- package/dist/index.cjs +60 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +63 -4
- package/dist/momotaro.chunk.d.ts +118 -94
- package/dist/styles/components/Switch/switch.css.cjs +26 -0
- package/dist/styles/components/Switch/switch.css.mjs +27 -0
- package/dist/styles/lib/css/atoms/atomicProperties.cjs +1 -0
- package/dist/styles/lib/css/atoms/atomicProperties.mjs +1 -0
- package/dist/styles/lib/css/style/style.cjs +28 -0
- package/dist/styles/lib/css/style/style.mjs +29 -0
- package/dist/styles/themes/momotaro/components/button.css.cjs +65 -76
- package/dist/styles/themes/momotaro/components/button.css.mjs +62 -73
- package/dist/styles/themes/momotaro/components/helpers.css.cjs +5 -5
- package/dist/styles/themes/momotaro/components/helpers.css.mjs +6 -6
- package/dist/styles/themes/momotaro/components/index.cjs +3 -1
- package/dist/styles/themes/momotaro/components/index.mjs +3 -1
- package/dist/styles/themes/momotaro/components/progress.css.cjs +15 -5
- package/dist/styles/themes/momotaro/components/progress.css.mjs +15 -5
- package/dist/styles/themes/momotaro/components/switch.css.cjs +58 -0
- package/dist/styles/themes/momotaro/components/switch.css.mjs +59 -0
- package/package.json +14 -13
package/README.md
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
# @blockle/blocks
|
|
1
|
+
# @blockle/blocks design system
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Blocks design system
|
|
3
|
+
Design system for react with vanilla-extract.
|
|
6
4
|
|
|
7
5
|
## Installation
|
|
8
6
|
|
|
9
7
|
```bash
|
|
10
|
-
|
|
8
|
+
yarn add @blockle/blocks
|
|
11
9
|
```
|
|
12
10
|
|
|
13
11
|
## Setup
|
|
@@ -16,15 +14,13 @@ npm install @blockle/blocks
|
|
|
16
14
|
import React from 'react';
|
|
17
15
|
|
|
18
16
|
import '@blockle/blocks/reset.css';
|
|
19
|
-
import {
|
|
17
|
+
import { BlocksProvider } from '@blockle/blocks';
|
|
20
18
|
import { momotaro } from '@blockle/blocks/themes/momotaro';
|
|
21
19
|
|
|
22
|
-
// const Link = makeLinkComponent(...)
|
|
23
|
-
|
|
24
20
|
const App = () => (
|
|
25
|
-
<
|
|
26
|
-
|
|
27
|
-
</
|
|
21
|
+
<BlocksProvider theme={momotaro}>
|
|
22
|
+
<div>Your app here</div>
|
|
23
|
+
</BlocksProvider>
|
|
28
24
|
);
|
|
29
25
|
```
|
|
30
26
|
|
|
@@ -34,7 +30,7 @@ const App = () => (
|
|
|
34
30
|
import React from 'react';
|
|
35
31
|
import { Button } from '@blockle/blocks';
|
|
36
32
|
|
|
37
|
-
const App = () => <Button>Click me</Button>;
|
|
33
|
+
const App = () => <Button variant="ghost">Click me</Button>;
|
|
38
34
|
```
|
|
39
35
|
|
|
40
36
|
## Theming
|
|
@@ -42,9 +38,11 @@ const App = () => <Button>Click me</Button>;
|
|
|
42
38
|
yourTheme.css.ts
|
|
43
39
|
|
|
44
40
|
```jsx
|
|
45
|
-
import {
|
|
41
|
+
import { ThemeTokens, makeComponentTheme, makeTheme, style } from "@blockle/blocks";
|
|
46
42
|
|
|
47
|
-
const tokens =
|
|
43
|
+
const tokens: ThemeTokens = {
|
|
44
|
+
// ...
|
|
45
|
+
};
|
|
48
46
|
|
|
49
47
|
const button = makeComponentTheme('button', {
|
|
50
48
|
base: style({
|
|
@@ -58,12 +56,15 @@ const button = makeComponentTheme('button', {
|
|
|
58
56
|
...
|
|
59
57
|
})
|
|
60
58
|
},
|
|
59
|
+
compoundVariants: [],
|
|
60
|
+
defaultVariants: {
|
|
61
|
+
variant: 'primary',
|
|
62
|
+
},
|
|
61
63
|
});
|
|
62
64
|
|
|
63
|
-
const theme = makeTheme({
|
|
65
|
+
export const theme = makeTheme({
|
|
66
|
+
name: 'Theme name',
|
|
64
67
|
tokens,
|
|
65
|
-
components
|
|
66
|
-
button
|
|
67
|
-
}
|
|
68
|
+
components,
|
|
68
69
|
});
|
|
69
70
|
```
|
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const styles_lib_css_atoms_breakpoints_cjs = require("./styles/lib/css/atoms/breakpoints.cjs");
|
|
4
|
+
const styles_lib_css_style_style_cjs = require("./styles/lib/css/style/style.cjs");
|
|
4
5
|
const styles_lib_theme_makeComponentTheme_cjs = require("./styles/lib/theme/makeComponentTheme.cjs");
|
|
5
6
|
const styles_lib_theme_makeTheme_cjs = require("./styles/lib/theme/makeTheme.cjs");
|
|
6
7
|
const styles_lib_theme_vars_css_cjs = require("./styles/lib/theme/vars.css.cjs");
|
|
@@ -15,6 +16,7 @@ const styles_components_Divider_divider_css_cjs = require("./styles/components/D
|
|
|
15
16
|
const styles_components_Heading_heading_css_cjs = require("./styles/components/Heading/heading.css.cjs");
|
|
16
17
|
const styles_components_Input_input_css_cjs = require("./styles/components/Input/input.css.cjs");
|
|
17
18
|
const styles_components_Radio_radio_css_cjs = require("./styles/components/Radio/radio.css.cjs");
|
|
19
|
+
const styles_components_Switch_switch_css_cjs = require("./styles/components/Switch/switch.css.cjs");
|
|
18
20
|
const styles_components_Text_text_css_cjs = require("./styles/components/Text/text.css.cjs");
|
|
19
21
|
const classnames = (...args) => {
|
|
20
22
|
const className = args.filter((arg) => arg && typeof arg === "string").join(" ");
|
|
@@ -659,7 +661,7 @@ const Progress = react.forwardRef(function Progress2({ value, max = 100, classNa
|
|
|
659
661
|
const containerClassName = useComponentStyles(
|
|
660
662
|
"progress",
|
|
661
663
|
{
|
|
662
|
-
|
|
664
|
+
base: true
|
|
663
665
|
},
|
|
664
666
|
false
|
|
665
667
|
);
|
|
@@ -733,10 +735,66 @@ const Stack = ({
|
|
|
733
735
|
}
|
|
734
736
|
);
|
|
735
737
|
};
|
|
738
|
+
const Switch = react.forwardRef(function Switch2({ className, checked, onChange, defaultChecked, ...restProps }, ref) {
|
|
739
|
+
const [isChecked, setIsChecked] = react.useState(defaultChecked || checked || false);
|
|
740
|
+
const baseClassName = useComponentStyles("switch", { base: true });
|
|
741
|
+
const sliderClassName = useComponentStyles("switch", { slider: true });
|
|
742
|
+
react.useEffect(() => {
|
|
743
|
+
if (checked !== void 0) {
|
|
744
|
+
setIsChecked(checked);
|
|
745
|
+
}
|
|
746
|
+
}, [checked]);
|
|
747
|
+
const toggle = react.useCallback(() => {
|
|
748
|
+
setIsChecked((checked2) => {
|
|
749
|
+
const newValue = !checked2;
|
|
750
|
+
if (onChange) {
|
|
751
|
+
onChange(newValue);
|
|
752
|
+
}
|
|
753
|
+
return newValue;
|
|
754
|
+
});
|
|
755
|
+
}, [onChange]);
|
|
756
|
+
const onChangeHandler = react.useCallback(
|
|
757
|
+
(event) => {
|
|
758
|
+
setIsChecked(event.target.checked);
|
|
759
|
+
if (onChange) {
|
|
760
|
+
onChange(event.target.checked);
|
|
761
|
+
}
|
|
762
|
+
},
|
|
763
|
+
[onChange]
|
|
764
|
+
);
|
|
765
|
+
return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
766
|
+
"div",
|
|
767
|
+
{
|
|
768
|
+
className: classnames(className, styles_components_Switch_switch_css_cjs.container, baseClassName),
|
|
769
|
+
"data-checked": isChecked,
|
|
770
|
+
onClick: (event) => {
|
|
771
|
+
if (event.target.tagName === "INPUT") {
|
|
772
|
+
return;
|
|
773
|
+
}
|
|
774
|
+
toggle();
|
|
775
|
+
},
|
|
776
|
+
children: [
|
|
777
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
778
|
+
"input",
|
|
779
|
+
{
|
|
780
|
+
ref,
|
|
781
|
+
type: "checkbox",
|
|
782
|
+
className: styles_components_Switch_switch_css_cjs.input,
|
|
783
|
+
checked: isChecked,
|
|
784
|
+
onChange: onChangeHandler,
|
|
785
|
+
...restProps
|
|
786
|
+
}
|
|
787
|
+
),
|
|
788
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: sliderClassName, "data-checked": isChecked })
|
|
789
|
+
]
|
|
790
|
+
}
|
|
791
|
+
) });
|
|
792
|
+
});
|
|
736
793
|
const Text = react.forwardRef(function Text2({ tag: Tag = "span", asChild, children, className, ...restProps }, ref) {
|
|
737
794
|
return /* @__PURE__ */ jsxRuntime.jsx(Box, { ref, asChild: true, className: classnames(styles_components_Text_text_css_cjs.text, className), ...restProps, children: asChild ? children : /* @__PURE__ */ jsxRuntime.jsx(Tag, { children }) });
|
|
738
795
|
});
|
|
739
796
|
exports.breakpointQuery = styles_lib_css_atoms_breakpoints_cjs.breakpointQuery;
|
|
797
|
+
exports.style = styles_lib_css_style_style_cjs.style;
|
|
740
798
|
exports.makeComponentTheme = styles_lib_theme_makeComponentTheme_cjs.makeComponentTheme;
|
|
741
799
|
exports.makeTheme = styles_lib_theme_makeTheme_cjs.makeTheme;
|
|
742
800
|
exports.vars = styles_lib_theme_vars_css_cjs.vars;
|
|
@@ -758,6 +816,7 @@ exports.Radio = Radio;
|
|
|
758
816
|
exports.Slot = Slot;
|
|
759
817
|
exports.Spinner = Spinner;
|
|
760
818
|
exports.Stack = Stack;
|
|
819
|
+
exports.Switch = Switch;
|
|
761
820
|
exports.Text = Text;
|
|
762
821
|
exports.classnames = classnames;
|
|
763
822
|
exports.createSlottable = createSlottable;
|
package/dist/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { BlocksProvider, BlocksProviderProps, Box, BoxProps, Button, ButtonProps, Checkbox, CheckboxProps, Dialog, DialogProps, Divider, DividerProps, Heading, HeadingProps, Inline, InlineProps, Input, InputProps, Label, LabelProps, Link, LinkProps, Portal, PortalProps, Progress, ProgressProps, Radio, RadioProps, Slot, Spinner, SpinnerProps, Stack, StackProps, Text, TextProps, ThemeComponentsStyles, ThemeTokens, atoms, breakpointQuery, classnames, createSlottable, makeComponentTheme, makeTheme, useComponentStyleDefaultProps, useComponentStyles, useIsomorphicLayoutEffect, useKeyboard, usePreventBodyScroll, vars } from './momotaro.chunk.js';
|
|
1
|
+
export { BlocksProvider, BlocksProviderProps, Box, BoxProps, Button, ButtonProps, Checkbox, CheckboxProps, Dialog, DialogProps, Divider, DividerProps, Heading, HeadingProps, Inline, InlineProps, Input, InputProps, Label, LabelProps, Link, LinkProps, Portal, PortalProps, Progress, ProgressProps, Radio, RadioProps, Slot, Spinner, SpinnerProps, Stack, StackProps, Switch, SwitchProps, Text, TextProps, ThemeComponentsStyles, ThemeTokens, atoms, breakpointQuery, classnames, createSlottable, makeComponentTheme, makeTheme, style, useComponentStyleDefaultProps, useComponentStyles, useIsomorphicLayoutEffect, useKeyboard, usePreventBodyScroll, vars } from './momotaro.chunk.js';
|
package/dist/index.mjs
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import { breakpointQuery } from "./styles/lib/css/atoms/breakpoints.mjs";
|
|
4
|
+
import { style } from "./styles/lib/css/style/style.mjs";
|
|
4
5
|
import { makeComponentTheme } from "./styles/lib/theme/makeComponentTheme.mjs";
|
|
5
6
|
import { makeTheme } from "./styles/lib/theme/makeTheme.mjs";
|
|
6
7
|
import { vars } from "./styles/lib/theme/vars.css.mjs";
|
|
7
8
|
import { atoms } from "./styles/lib/css/atoms/sprinkles.css.mjs";
|
|
8
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
9
10
|
import { createContext, forwardRef, Children, isValidElement, cloneElement, useContext, useEffect, useLayoutEffect, useRef, useState, useCallback, useId } from "react";
|
|
10
11
|
import { buttonReset } from "./styles/components/Button/Button.css.mjs";
|
|
11
12
|
import { container, input, icon } from "./styles/components/Checkbox/checkbox.css.mjs";
|
|
@@ -15,6 +16,7 @@ import { divider } from "./styles/components/Divider/divider.css.mjs";
|
|
|
15
16
|
import { heading } from "./styles/components/Heading/heading.css.mjs";
|
|
16
17
|
import { input as input$1 } from "./styles/components/Input/input.css.mjs";
|
|
17
18
|
import { container as container$1, input as input$2, icon as icon$1 } from "./styles/components/Radio/radio.css.mjs";
|
|
19
|
+
import { container as container$2, input as input$3 } from "./styles/components/Switch/switch.css.mjs";
|
|
18
20
|
import { text } from "./styles/components/Text/text.css.mjs";
|
|
19
21
|
const classnames = (...args) => {
|
|
20
22
|
const className = args.filter((arg) => arg && typeof arg === "string").join(" ");
|
|
@@ -446,8 +448,8 @@ function hasAnimationDuration(element) {
|
|
|
446
448
|
if (!element) {
|
|
447
449
|
return false;
|
|
448
450
|
}
|
|
449
|
-
const
|
|
450
|
-
return
|
|
451
|
+
const style2 = window.getComputedStyle(element);
|
|
452
|
+
return style2.transitionDuration !== "0s" || style2.animationDuration !== "0s";
|
|
451
453
|
}
|
|
452
454
|
const Portal = ({ children, container: container2 }) => {
|
|
453
455
|
const context = useTheme();
|
|
@@ -659,7 +661,7 @@ const Progress = forwardRef(function Progress2({ value, max = 100, className, ..
|
|
|
659
661
|
const containerClassName = useComponentStyles(
|
|
660
662
|
"progress",
|
|
661
663
|
{
|
|
662
|
-
|
|
664
|
+
base: true
|
|
663
665
|
},
|
|
664
666
|
false
|
|
665
667
|
);
|
|
@@ -733,6 +735,61 @@ const Stack = ({
|
|
|
733
735
|
}
|
|
734
736
|
);
|
|
735
737
|
};
|
|
738
|
+
const Switch = forwardRef(function Switch2({ className, checked, onChange, defaultChecked, ...restProps }, ref) {
|
|
739
|
+
const [isChecked, setIsChecked] = useState(defaultChecked || checked || false);
|
|
740
|
+
const baseClassName = useComponentStyles("switch", { base: true });
|
|
741
|
+
const sliderClassName = useComponentStyles("switch", { slider: true });
|
|
742
|
+
useEffect(() => {
|
|
743
|
+
if (checked !== void 0) {
|
|
744
|
+
setIsChecked(checked);
|
|
745
|
+
}
|
|
746
|
+
}, [checked]);
|
|
747
|
+
const toggle = useCallback(() => {
|
|
748
|
+
setIsChecked((checked2) => {
|
|
749
|
+
const newValue = !checked2;
|
|
750
|
+
if (onChange) {
|
|
751
|
+
onChange(newValue);
|
|
752
|
+
}
|
|
753
|
+
return newValue;
|
|
754
|
+
});
|
|
755
|
+
}, [onChange]);
|
|
756
|
+
const onChangeHandler = useCallback(
|
|
757
|
+
(event) => {
|
|
758
|
+
setIsChecked(event.target.checked);
|
|
759
|
+
if (onChange) {
|
|
760
|
+
onChange(event.target.checked);
|
|
761
|
+
}
|
|
762
|
+
},
|
|
763
|
+
[onChange]
|
|
764
|
+
);
|
|
765
|
+
return /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(
|
|
766
|
+
"div",
|
|
767
|
+
{
|
|
768
|
+
className: classnames(className, container$2, baseClassName),
|
|
769
|
+
"data-checked": isChecked,
|
|
770
|
+
onClick: (event) => {
|
|
771
|
+
if (event.target.tagName === "INPUT") {
|
|
772
|
+
return;
|
|
773
|
+
}
|
|
774
|
+
toggle();
|
|
775
|
+
},
|
|
776
|
+
children: [
|
|
777
|
+
/* @__PURE__ */ jsx(
|
|
778
|
+
"input",
|
|
779
|
+
{
|
|
780
|
+
ref,
|
|
781
|
+
type: "checkbox",
|
|
782
|
+
className: input$3,
|
|
783
|
+
checked: isChecked,
|
|
784
|
+
onChange: onChangeHandler,
|
|
785
|
+
...restProps
|
|
786
|
+
}
|
|
787
|
+
),
|
|
788
|
+
/* @__PURE__ */ jsx("div", { className: sliderClassName, "data-checked": isChecked })
|
|
789
|
+
]
|
|
790
|
+
}
|
|
791
|
+
) });
|
|
792
|
+
});
|
|
736
793
|
const Text = forwardRef(function Text2({ tag: Tag = "span", asChild, children, className, ...restProps }, ref) {
|
|
737
794
|
return /* @__PURE__ */ jsx(Box, { ref, asChild: true, className: classnames(text, className), ...restProps, children: asChild ? children : /* @__PURE__ */ jsx(Tag, { children }) });
|
|
738
795
|
});
|
|
@@ -754,6 +811,7 @@ export {
|
|
|
754
811
|
Slot,
|
|
755
812
|
Spinner,
|
|
756
813
|
Stack,
|
|
814
|
+
Switch,
|
|
757
815
|
Text,
|
|
758
816
|
atoms,
|
|
759
817
|
breakpointQuery,
|
|
@@ -761,6 +819,7 @@ export {
|
|
|
761
819
|
createSlottable,
|
|
762
820
|
makeComponentTheme,
|
|
763
821
|
makeTheme,
|
|
822
|
+
style,
|
|
764
823
|
useComponentStyleDefaultProps,
|
|
765
824
|
useComponentStyles,
|
|
766
825
|
useIsomorphicLayoutEffect,
|