@jongh/ui 1.6.5
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/.storybook/index.css +1 -0
- package/.storybook/main.ts +40 -0
- package/.storybook/preview.ts +16 -0
- package/.storybook/vitest.setup.ts +9 -0
- package/.turbo/turbo-build.log +79 -0
- package/CHANGELOG.md +54 -0
- package/chromatic.config.json +6 -0
- package/eslint.config.mjs +14 -0
- package/index.html +13 -0
- package/package.json +58 -0
- package/panda.config.ts +13 -0
- package/postcss.config.cjs +3 -0
- package/preset.ts +134 -0
- package/src/component/accordion/ui/index.tsx +80 -0
- package/src/component/accordion/ui/recipe.ts +65 -0
- package/src/component/avatar/ui/index.tsx +47 -0
- package/src/component/avatar/ui/recipe.ts +30 -0
- package/src/component/button/ui/index.tsx +29 -0
- package/src/component/button/ui/recipe.ts +102 -0
- package/src/component/chip/ui/index.tsx +30 -0
- package/src/component/chip/ui/recipe.ts +112 -0
- package/src/component/dialog/ui/index.tsx +73 -0
- package/src/component/dialog/ui/recipe.ts +92 -0
- package/src/component/select/ui/index.tsx +128 -0
- package/src/component/select/ui/recipe.ts +142 -0
- package/src/component/slider/ui/index.tsx +61 -0
- package/src/component/slider/ui/recipe.ts +52 -0
- package/src/component/tabs/ui/index.tsx +61 -0
- package/src/component/tabs/ui/recipe.ts +59 -0
- package/src/hooks/createContext.tsx +34 -0
- package/src/hooks/useComposedRefs.ts +20 -0
- package/src/hooks/useControllableState.ts +87 -0
- package/src/hooks/useKeyboardEvent.ts +58 -0
- package/src/stories/accordion.stories.tsx +63 -0
- package/src/stories/avatar.stories.tsx +33 -0
- package/src/stories/button.stories.tsx +53 -0
- package/src/stories/chip.stories.tsx +69 -0
- package/src/stories/dialog.stories.tsx +134 -0
- package/src/stories/select.stories.tsx +35 -0
- package/src/stories/slider.stories.tsx +31 -0
- package/src/stories/tabs.stories.tsx +63 -0
- package/src/test/accordion.test.tsx +66 -0
- package/src/test/tabs.test.tsx +30 -0
- package/src/types/index.ts +1 -0
- package/src/utils/createStyleContext.tsx +108 -0
- package/src/utils/defineSafe.ts +46 -0
- package/src/utils/getObjectKeys.ts +20 -0
- package/src/vite-env.d.ts +1 -0
- package/storybook-static/assets/Color-F6OSRLHC-CrKta8Qx.js +1 -0
- package/storybook-static/assets/DocsRenderer-CFRXHY34-Crd9Mepd.js +586 -0
- package/storybook-static/assets/_commonjsHelpers-Cpj98o6Y.js +1 -0
- package/storybook-static/assets/accordion.stories-0Om0AnMm.js +50 -0
- package/storybook-static/assets/avatar.stories-DMDsrSks.js +16 -0
- package/storybook-static/assets/axe-Dzet_oDA.js +30 -0
- package/storybook-static/assets/button.stories-CuVC-3x-.js +40 -0
- package/storybook-static/assets/chip.stories-FBIp8XNi.js +48 -0
- package/storybook-static/assets/chunk-XP5HYGXS-D5tuasO7.js +1 -0
- package/storybook-static/assets/createLucideIcon-DmXe7Z8R.js +21 -0
- package/storybook-static/assets/dialog.stories-3WsEvXt4.js +106 -0
- package/storybook-static/assets/entry-preview-Bkgdgq1b.js +10 -0
- package/storybook-static/assets/entry-preview-docs-zLz1Es7d.js +46 -0
- package/storybook-static/assets/iframe-LPPPXabV.js +199 -0
- package/storybook-static/assets/index-Bklpsb39.js +1 -0
- package/storybook-static/assets/index-BrlJLjep.js +24 -0
- package/storybook-static/assets/index-C2tRLqin.js +41 -0
- package/storybook-static/assets/index-CBft-ReK.js +8 -0
- package/storybook-static/assets/index-CSbWd7UJ.js +1 -0
- package/storybook-static/assets/index-ClcD9ViR.js +9 -0
- package/storybook-static/assets/index-Cu4lwwaE.js +1 -0
- package/storybook-static/assets/index-Cvkemp2J.js +1 -0
- package/storybook-static/assets/index-D59aU5s_.js +240 -0
- package/storybook-static/assets/index-DNo8LKN3.js +1 -0
- package/storybook-static/assets/index-DUy19JZU.js +1 -0
- package/storybook-static/assets/index-D_35mznO.js +1 -0
- package/storybook-static/assets/index-DrFu-skq.js +6 -0
- package/storybook-static/assets/index-DvbTp2M2.js +1 -0
- package/storybook-static/assets/index-rtmQni2k.js +1 -0
- package/storybook-static/assets/jsx-runtime-BYYWji4R.js +9 -0
- package/storybook-static/assets/matchers-57EZJSQE-oeXCqs4p.js +14 -0
- package/storybook-static/assets/preview-1l6V4UsQ.js +1 -0
- package/storybook-static/assets/preview-B3PTUHS7.js +1 -0
- package/storybook-static/assets/preview-BBWR9nbA.js +1 -0
- package/storybook-static/assets/preview-BCV5r-Ja.js +1 -0
- package/storybook-static/assets/preview-BWzBA1C2.js +396 -0
- package/storybook-static/assets/preview-Bb56VplF.js +2 -0
- package/storybook-static/assets/preview-Bl8rsKRy.js +1 -0
- package/storybook-static/assets/preview-Bm-a94Ct.js +2 -0
- package/storybook-static/assets/preview-Br-h4d84.js +1 -0
- package/storybook-static/assets/preview-D77C14du.js +34 -0
- package/storybook-static/assets/preview-DC8N7cZb.css +1 -0
- package/storybook-static/assets/preview-DGUiP6tS.js +7 -0
- package/storybook-static/assets/react-18-BPs3tMGP.js +1 -0
- package/storybook-static/assets/select.stories-AN8Hb81Z.js +20 -0
- package/storybook-static/assets/slider.stories-CxOczq0y.js +12 -0
- package/storybook-static/assets/tabs.stories-BbTU4QU3.js +28 -0
- package/storybook-static/favicon.svg +1 -0
- package/storybook-static/iframe.html +666 -0
- package/storybook-static/index.html +193 -0
- package/storybook-static/index.json +1 -0
- package/storybook-static/nunito-sans-bold-italic.woff2 +0 -0
- package/storybook-static/nunito-sans-bold.woff2 +0 -0
- package/storybook-static/nunito-sans-italic.woff2 +0 -0
- package/storybook-static/nunito-sans-regular.woff2 +0 -0
- package/storybook-static/project.json +1 -0
- package/storybook-static/sb-addons/a11y-12/manager-bundle.js +3 -0
- package/storybook-static/sb-addons/a11y-12/manager-bundle.js.LEGAL.txt +0 -0
- package/storybook-static/sb-addons/chromatic-com-storybook-10/manager-bundle.js +331 -0
- package/storybook-static/sb-addons/chromatic-com-storybook-10/manager-bundle.js.LEGAL.txt +51 -0
- package/storybook-static/sb-addons/controls-11/manager-bundle.js +391 -0
- package/storybook-static/sb-addons/controls-11/manager-bundle.js.LEGAL.txt +0 -0
- package/storybook-static/sb-addons/essentials-actions-3/manager-bundle.js +3 -0
- package/storybook-static/sb-addons/essentials-actions-3/manager-bundle.js.LEGAL.txt +0 -0
- package/storybook-static/sb-addons/essentials-backgrounds-5/manager-bundle.js +12 -0
- package/storybook-static/sb-addons/essentials-backgrounds-5/manager-bundle.js.LEGAL.txt +0 -0
- package/storybook-static/sb-addons/essentials-controls-2/manager-bundle.js +391 -0
- package/storybook-static/sb-addons/essentials-controls-2/manager-bundle.js.LEGAL.txt +0 -0
- package/storybook-static/sb-addons/essentials-docs-4/manager-bundle.js +230 -0
- package/storybook-static/sb-addons/essentials-docs-4/manager-bundle.js.LEGAL.txt +0 -0
- package/storybook-static/sb-addons/essentials-measure-8/manager-bundle.js +3 -0
- package/storybook-static/sb-addons/essentials-measure-8/manager-bundle.js.LEGAL.txt +0 -0
- package/storybook-static/sb-addons/essentials-outline-9/manager-bundle.js +3 -0
- package/storybook-static/sb-addons/essentials-outline-9/manager-bundle.js.LEGAL.txt +0 -0
- package/storybook-static/sb-addons/essentials-toolbars-7/manager-bundle.js +3 -0
- package/storybook-static/sb-addons/essentials-toolbars-7/manager-bundle.js.LEGAL.txt +0 -0
- package/storybook-static/sb-addons/essentials-viewport-6/manager-bundle.js +3 -0
- package/storybook-static/sb-addons/essentials-viewport-6/manager-bundle.js.LEGAL.txt +0 -0
- package/storybook-static/sb-addons/links-1/manager-bundle.js +3 -0
- package/storybook-static/sb-addons/links-1/manager-bundle.js.LEGAL.txt +0 -0
- package/storybook-static/sb-addons/storybook-core-core-server-presets-0/common-manager-bundle.js +3 -0
- package/storybook-static/sb-addons/storybook-core-core-server-presets-0/common-manager-bundle.js.LEGAL.txt +0 -0
- package/storybook-static/sb-addons/storybook-experimental-addon-test-13/manager-bundle.js +211 -0
- package/storybook-static/sb-addons/storybook-experimental-addon-test-13/manager-bundle.js.LEGAL.txt +0 -0
- package/storybook-static/sb-common-assets/favicon.svg +1 -0
- package/storybook-static/sb-common-assets/nunito-sans-bold-italic.woff2 +0 -0
- package/storybook-static/sb-common-assets/nunito-sans-bold.woff2 +0 -0
- package/storybook-static/sb-common-assets/nunito-sans-italic.woff2 +0 -0
- package/storybook-static/sb-common-assets/nunito-sans-regular.woff2 +0 -0
- package/storybook-static/sb-manager/globals-module-info.js +1037 -0
- package/storybook-static/sb-manager/globals-runtime.js +40857 -0
- package/storybook-static/sb-manager/globals.js +48 -0
- package/storybook-static/sb-manager/runtime.js +11963 -0
- package/styled-system/css/conditions.mjs +36 -0
- package/styled-system/css/css.d.ts +22 -0
- package/styled-system/css/css.mjs +45 -0
- package/styled-system/css/cva.d.ts +6 -0
- package/styled-system/css/cva.mjs +87 -0
- package/styled-system/css/cx.d.ts +5 -0
- package/styled-system/css/cx.mjs +15 -0
- package/styled-system/css/index.d.ts +5 -0
- package/styled-system/css/index.mjs +4 -0
- package/styled-system/css/sva.d.ts +4 -0
- package/styled-system/css/sva.mjs +41 -0
- package/styled-system/helpers.mjs +336 -0
- package/styled-system/jsx/aspect-ratio.d.ts +10 -0
- package/styled-system/jsx/aspect-ratio.mjs +14 -0
- package/styled-system/jsx/bleed.d.ts +10 -0
- package/styled-system/jsx/bleed.mjs +14 -0
- package/styled-system/jsx/box.d.ts +10 -0
- package/styled-system/jsx/box.mjs +14 -0
- package/styled-system/jsx/center.d.ts +10 -0
- package/styled-system/jsx/center.mjs +14 -0
- package/styled-system/jsx/circle.d.ts +10 -0
- package/styled-system/jsx/circle.mjs +14 -0
- package/styled-system/jsx/container.d.ts +10 -0
- package/styled-system/jsx/container.mjs +14 -0
- package/styled-system/jsx/cq.d.ts +10 -0
- package/styled-system/jsx/cq.mjs +14 -0
- package/styled-system/jsx/divider.d.ts +10 -0
- package/styled-system/jsx/divider.mjs +14 -0
- package/styled-system/jsx/factory-helper.mjs +22 -0
- package/styled-system/jsx/factory.d.ts +3 -0
- package/styled-system/jsx/factory.mjs +80 -0
- package/styled-system/jsx/flex.d.ts +10 -0
- package/styled-system/jsx/flex.mjs +14 -0
- package/styled-system/jsx/float.d.ts +10 -0
- package/styled-system/jsx/float.mjs +14 -0
- package/styled-system/jsx/grid-item.d.ts +10 -0
- package/styled-system/jsx/grid-item.mjs +14 -0
- package/styled-system/jsx/grid.d.ts +10 -0
- package/styled-system/jsx/grid.mjs +14 -0
- package/styled-system/jsx/hstack.d.ts +10 -0
- package/styled-system/jsx/hstack.mjs +14 -0
- package/styled-system/jsx/index.d.ts +24 -0
- package/styled-system/jsx/index.mjs +22 -0
- package/styled-system/jsx/is-valid-prop.d.ts +11 -0
- package/styled-system/jsx/is-valid-prop.mjs +17 -0
- package/styled-system/jsx/link-overlay.d.ts +10 -0
- package/styled-system/jsx/link-overlay.mjs +14 -0
- package/styled-system/jsx/spacer.d.ts +10 -0
- package/styled-system/jsx/spacer.mjs +14 -0
- package/styled-system/jsx/square.d.ts +10 -0
- package/styled-system/jsx/square.mjs +14 -0
- package/styled-system/jsx/stack.d.ts +10 -0
- package/styled-system/jsx/stack.mjs +14 -0
- package/styled-system/jsx/visually-hidden.d.ts +10 -0
- package/styled-system/jsx/visually-hidden.mjs +14 -0
- package/styled-system/jsx/vstack.d.ts +10 -0
- package/styled-system/jsx/vstack.mjs +14 -0
- package/styled-system/jsx/wrap.d.ts +10 -0
- package/styled-system/jsx/wrap.mjs +14 -0
- package/styled-system/patterns/aspect-ratio.d.ts +21 -0
- package/styled-system/patterns/aspect-ratio.mjs +38 -0
- package/styled-system/patterns/bleed.d.ts +22 -0
- package/styled-system/patterns/bleed.mjs +24 -0
- package/styled-system/patterns/box.d.ts +21 -0
- package/styled-system/patterns/box.mjs +15 -0
- package/styled-system/patterns/center.d.ts +21 -0
- package/styled-system/patterns/center.mjs +21 -0
- package/styled-system/patterns/circle.d.ts +21 -0
- package/styled-system/patterns/circle.mjs +25 -0
- package/styled-system/patterns/container.d.ts +21 -0
- package/styled-system/patterns/container.mjs +21 -0
- package/styled-system/patterns/cq.d.ts +22 -0
- package/styled-system/patterns/cq.mjs +21 -0
- package/styled-system/patterns/divider.d.ts +23 -0
- package/styled-system/patterns/divider.mjs +25 -0
- package/styled-system/patterns/flex.d.ts +27 -0
- package/styled-system/patterns/flex.mjs +26 -0
- package/styled-system/patterns/float.d.ts +24 -0
- package/styled-system/patterns/float.mjs +52 -0
- package/styled-system/patterns/grid-item.d.ts +26 -0
- package/styled-system/patterns/grid-item.mjs +25 -0
- package/styled-system/patterns/grid.d.ts +25 -0
- package/styled-system/patterns/grid.mjs +27 -0
- package/styled-system/patterns/hstack.d.ts +22 -0
- package/styled-system/patterns/hstack.mjs +24 -0
- package/styled-system/patterns/index.d.ts +21 -0
- package/styled-system/patterns/index.mjs +20 -0
- package/styled-system/patterns/link-overlay.d.ts +21 -0
- package/styled-system/patterns/link-overlay.mjs +24 -0
- package/styled-system/patterns/spacer.d.ts +21 -0
- package/styled-system/patterns/spacer.mjs +21 -0
- package/styled-system/patterns/square.d.ts +21 -0
- package/styled-system/patterns/square.mjs +24 -0
- package/styled-system/patterns/stack.d.ts +24 -0
- package/styled-system/patterns/stack.mjs +24 -0
- package/styled-system/patterns/visually-hidden.d.ts +21 -0
- package/styled-system/patterns/visually-hidden.mjs +18 -0
- package/styled-system/patterns/vstack.d.ts +22 -0
- package/styled-system/patterns/vstack.mjs +24 -0
- package/styled-system/patterns/wrap.d.ts +25 -0
- package/styled-system/patterns/wrap.mjs +25 -0
- package/styled-system/tokens/index.d.ts +9 -0
- package/styled-system/tokens/index.mjs +1992 -0
- package/styled-system/tokens/tokens.d.ts +60 -0
- package/styled-system/types/composition.d.ts +164 -0
- package/styled-system/types/conditions.d.ts +274 -0
- package/styled-system/types/csstype.d.ts +21298 -0
- package/styled-system/types/global.d.ts +20 -0
- package/styled-system/types/index.d.ts +8 -0
- package/styled-system/types/jsx.d.ts +52 -0
- package/styled-system/types/parts.d.ts +8 -0
- package/styled-system/types/pattern.d.ts +78 -0
- package/styled-system/types/prop-type.d.ts +235 -0
- package/styled-system/types/recipe.d.ts +181 -0
- package/styled-system/types/selectors.d.ts +59 -0
- package/styled-system/types/static-css.d.ts +56 -0
- package/styled-system/types/style-props.d.ts +7468 -0
- package/styled-system/types/system-types.d.ts +109 -0
- package/tsconfig.json +13 -0
- package/turbo/generators/config.cjs +7 -0
- package/turbo/generators/stories.cjs +23 -0
- package/turbo/generators/templates/stories.tsx.hbs +16 -0
- package/turbo/generators/templates/ui.tsx.hbs +8 -0
- package/turbo/generators/ui.cjs +19 -0
- package/vite.config.ts +7 -0
- package/vitest.config.ts +45 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { sva } from "@styled-system/css"
|
|
2
|
+
|
|
3
|
+
export const recipe = sva({
|
|
4
|
+
slots: ["root", "image", "fallback"],
|
|
5
|
+
base: {
|
|
6
|
+
root: {
|
|
7
|
+
position: "relative",
|
|
8
|
+
display: "flex",
|
|
9
|
+
h: "12",
|
|
10
|
+
w: "12",
|
|
11
|
+
flexShrink: "0",
|
|
12
|
+
overflow: "hidden",
|
|
13
|
+
rounded: "full",
|
|
14
|
+
},
|
|
15
|
+
image: {
|
|
16
|
+
aspectRatio: "square",
|
|
17
|
+
h: "full",
|
|
18
|
+
w: "full",
|
|
19
|
+
},
|
|
20
|
+
fallback: {
|
|
21
|
+
display: "flex",
|
|
22
|
+
h: "full",
|
|
23
|
+
w: "full",
|
|
24
|
+
alignItems: "center",
|
|
25
|
+
justifyContent: "center",
|
|
26
|
+
rounded: "full",
|
|
27
|
+
bg: "muted",
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
})
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { css, cx } from "@styled-system/css"
|
|
2
|
+
import { Slot } from "radix-ui"
|
|
3
|
+
import type { ComponentPropsWithoutRef } from "react"
|
|
4
|
+
import { forwardRef } from "react"
|
|
5
|
+
|
|
6
|
+
import { ButtonVariantProps, recipe } from "./recipe"
|
|
7
|
+
|
|
8
|
+
export type ButtonProps = ComponentPropsWithoutRef<"button"> & {
|
|
9
|
+
asChild?: boolean
|
|
10
|
+
} & ButtonVariantProps
|
|
11
|
+
|
|
12
|
+
export const Button = forwardRef<HTMLButtonElement, ButtonProps>(
|
|
13
|
+
({ asChild, className, ...props }, ref) => {
|
|
14
|
+
const Comp = asChild ? Slot.Root : "button"
|
|
15
|
+
const [variantProps, componentProps] = recipe.splitVariantProps(props)
|
|
16
|
+
const styles = recipe.raw(variantProps)
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<Comp
|
|
20
|
+
role="button"
|
|
21
|
+
ref={ref}
|
|
22
|
+
className={cx(css(styles), className)}
|
|
23
|
+
{...componentProps}
|
|
24
|
+
/>
|
|
25
|
+
)
|
|
26
|
+
},
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
Button.displayName = "Button"
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { cva, type RecipeVariantProps } from "@styled-system/css"
|
|
2
|
+
|
|
3
|
+
export type ButtonVariantProps = RecipeVariantProps<typeof recipe>
|
|
4
|
+
export const recipe = cva({
|
|
5
|
+
base: {
|
|
6
|
+
display: "inline-flex",
|
|
7
|
+
alignItems: "center",
|
|
8
|
+
justifyContent: "center",
|
|
9
|
+
rounded: "md",
|
|
10
|
+
textStyle: "sm",
|
|
11
|
+
fontWeight: "medium",
|
|
12
|
+
transition: "colors",
|
|
13
|
+
cursor: "pointer",
|
|
14
|
+
gap: "2",
|
|
15
|
+
_focusVisible: {
|
|
16
|
+
ringWidth: "1",
|
|
17
|
+
ringColor: "ring",
|
|
18
|
+
ringOffset: "1",
|
|
19
|
+
},
|
|
20
|
+
|
|
21
|
+
_disabled: {
|
|
22
|
+
cursor: "not-allowed",
|
|
23
|
+
opacity: "50%",
|
|
24
|
+
},
|
|
25
|
+
},
|
|
26
|
+
variants: {
|
|
27
|
+
variant: {
|
|
28
|
+
default: {
|
|
29
|
+
bg: "primary",
|
|
30
|
+
color: "primary.foreground",
|
|
31
|
+
|
|
32
|
+
_hover: {
|
|
33
|
+
bg: "primary/90",
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
destructive: {
|
|
37
|
+
bg: "destructive",
|
|
38
|
+
color: "destructive.foreground",
|
|
39
|
+
|
|
40
|
+
_hover: {
|
|
41
|
+
bg: "destructive/90",
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
outline: {
|
|
45
|
+
border: "input",
|
|
46
|
+
bg: "background",
|
|
47
|
+
|
|
48
|
+
_hover: {
|
|
49
|
+
bg: "accent",
|
|
50
|
+
color: "accent.foreground",
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
secondary: {
|
|
54
|
+
bg: "secondary",
|
|
55
|
+
color: "secondary.foreground",
|
|
56
|
+
|
|
57
|
+
_hover: {
|
|
58
|
+
bga: "secondary/90",
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
ghost: {
|
|
62
|
+
_hover: {
|
|
63
|
+
bg: "accent",
|
|
64
|
+
color: "accent.foreground",
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
link: {
|
|
68
|
+
color: "primary",
|
|
69
|
+
textUnderlineOffset: "4px",
|
|
70
|
+
|
|
71
|
+
_hover: {
|
|
72
|
+
textDecoration: "underline",
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
size: {
|
|
77
|
+
default: {
|
|
78
|
+
h: "10",
|
|
79
|
+
px: "4",
|
|
80
|
+
py: "2",
|
|
81
|
+
},
|
|
82
|
+
sm: {
|
|
83
|
+
h: "9",
|
|
84
|
+
rounded: "md",
|
|
85
|
+
px: "3",
|
|
86
|
+
},
|
|
87
|
+
lg: {
|
|
88
|
+
h: "11",
|
|
89
|
+
rounded: "md",
|
|
90
|
+
px: "8",
|
|
91
|
+
},
|
|
92
|
+
icon: {
|
|
93
|
+
h: "10",
|
|
94
|
+
w: "10",
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
defaultVariants: {
|
|
99
|
+
variant: "default",
|
|
100
|
+
size: "default",
|
|
101
|
+
},
|
|
102
|
+
})
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { css, cx } from "@styled-system/css"
|
|
2
|
+
import { Slot } from "radix-ui"
|
|
3
|
+
import { type ComponentPropsWithoutRef, forwardRef } from "react"
|
|
4
|
+
|
|
5
|
+
import { type ChipVariantProps, recipe } from "./recipe"
|
|
6
|
+
|
|
7
|
+
export type ChipProps = ComponentPropsWithoutRef<"button"> &
|
|
8
|
+
ChipVariantProps & {
|
|
9
|
+
asChild?: boolean
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const Chip = forwardRef<HTMLButtonElement, ChipProps>(
|
|
13
|
+
({ asChild, className, children, ...props }, ref) => {
|
|
14
|
+
const Comp = asChild ? Slot.Root : "button"
|
|
15
|
+
const [variantProps, componentProps] = recipe.splitVariantProps(props)
|
|
16
|
+
const styles = recipe.raw(variantProps)
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<Comp
|
|
20
|
+
ref={ref}
|
|
21
|
+
className={cx(css(styles), className)}
|
|
22
|
+
{...componentProps}
|
|
23
|
+
>
|
|
24
|
+
{children}
|
|
25
|
+
</Comp>
|
|
26
|
+
)
|
|
27
|
+
},
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
Chip.displayName = "Chip"
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { cva, type RecipeVariantProps } from "@styled-system/css"
|
|
2
|
+
|
|
3
|
+
export type ChipVariantProps = RecipeVariantProps<typeof recipe>
|
|
4
|
+
export const recipe = cva({
|
|
5
|
+
base: {
|
|
6
|
+
display: "inline-flex",
|
|
7
|
+
alignItems: "center",
|
|
8
|
+
justifyContent: "center",
|
|
9
|
+
borderRadius: "full",
|
|
10
|
+
transition: "colors",
|
|
11
|
+
cursor: "pointer",
|
|
12
|
+
_focusVisible: {
|
|
13
|
+
ringWidth: "1",
|
|
14
|
+
ringColor: "ring",
|
|
15
|
+
ringOffset: "1",
|
|
16
|
+
},
|
|
17
|
+
"& svg": {
|
|
18
|
+
flexShrink: 0,
|
|
19
|
+
},
|
|
20
|
+
_disabled: {
|
|
21
|
+
opacity: 0.5,
|
|
22
|
+
cursor: "not-allowed",
|
|
23
|
+
},
|
|
24
|
+
},
|
|
25
|
+
variants: {
|
|
26
|
+
variant: {
|
|
27
|
+
filled: {
|
|
28
|
+
bg: "secondary",
|
|
29
|
+
color: "secondary.foreground",
|
|
30
|
+
_hover: {
|
|
31
|
+
bg: "secondary/80",
|
|
32
|
+
},
|
|
33
|
+
},
|
|
34
|
+
outlined: {
|
|
35
|
+
border: "base",
|
|
36
|
+
bg: "background",
|
|
37
|
+
color: "foreground",
|
|
38
|
+
_hover: {
|
|
39
|
+
bg: "secondary",
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
size: {
|
|
44
|
+
sm: {
|
|
45
|
+
height: "7",
|
|
46
|
+
fontSize: "sm",
|
|
47
|
+
"& svg": {
|
|
48
|
+
width: "3",
|
|
49
|
+
height: "3",
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
md: {
|
|
53
|
+
height: "9",
|
|
54
|
+
fontSize: "lg",
|
|
55
|
+
"& svg": {
|
|
56
|
+
width: "4",
|
|
57
|
+
height: "4",
|
|
58
|
+
},
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
layout: {
|
|
62
|
+
withText: {},
|
|
63
|
+
iconOnly: {
|
|
64
|
+
px: "2",
|
|
65
|
+
"& svg": {
|
|
66
|
+
m: "0",
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
compoundVariants: [
|
|
72
|
+
{
|
|
73
|
+
layout: "iconOnly",
|
|
74
|
+
size: "sm",
|
|
75
|
+
css: {
|
|
76
|
+
width: "7",
|
|
77
|
+
height: "7",
|
|
78
|
+
},
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
layout: "iconOnly",
|
|
82
|
+
size: "md",
|
|
83
|
+
css: {
|
|
84
|
+
width: "9",
|
|
85
|
+
height: "9",
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
layout: "withText",
|
|
90
|
+
size: "sm",
|
|
91
|
+
css: {
|
|
92
|
+
px: "2",
|
|
93
|
+
py: "1",
|
|
94
|
+
gap: "1",
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
layout: "withText",
|
|
99
|
+
size: "md",
|
|
100
|
+
css: {
|
|
101
|
+
px: "3",
|
|
102
|
+
py: "2",
|
|
103
|
+
gap: "2",
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
],
|
|
107
|
+
defaultVariants: {
|
|
108
|
+
variant: "filled",
|
|
109
|
+
size: "md",
|
|
110
|
+
layout: "withText",
|
|
111
|
+
},
|
|
112
|
+
})
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { css } from "@styled-system/css"
|
|
2
|
+
import { createStyleContext } from "@utils/createStyleContext"
|
|
3
|
+
import { X } from "lucide-react"
|
|
4
|
+
import { Dialog } from "radix-ui"
|
|
5
|
+
import {
|
|
6
|
+
type ComponentProps,
|
|
7
|
+
type ComponentPropsWithoutRef,
|
|
8
|
+
type ElementRef,
|
|
9
|
+
forwardRef,
|
|
10
|
+
} from "react"
|
|
11
|
+
|
|
12
|
+
import { recipe } from "./recipe"
|
|
13
|
+
|
|
14
|
+
const { withRootProvider, withContext } = createStyleContext(recipe)
|
|
15
|
+
|
|
16
|
+
export const Root = withRootProvider(Dialog.Root)
|
|
17
|
+
|
|
18
|
+
export const Portal = withRootProvider(Dialog.Portal)
|
|
19
|
+
export const Overlay = withContext<
|
|
20
|
+
ElementRef<typeof Dialog.Overlay>,
|
|
21
|
+
Dialog.DialogOverlayProps
|
|
22
|
+
>(Dialog.Overlay, "overlay")
|
|
23
|
+
|
|
24
|
+
export const Close = withContext<
|
|
25
|
+
ElementRef<typeof Dialog.Close>,
|
|
26
|
+
Dialog.DialogCloseProps
|
|
27
|
+
>(Dialog.Close, "close")
|
|
28
|
+
|
|
29
|
+
export const ContentPrimitive = forwardRef<
|
|
30
|
+
React.ElementRef<typeof Dialog.Content>,
|
|
31
|
+
React.ComponentPropsWithoutRef<typeof Dialog.Content>
|
|
32
|
+
>(({ children, ...props }, ref) => (
|
|
33
|
+
<Portal>
|
|
34
|
+
<Overlay />
|
|
35
|
+
<Dialog.Content ref={ref} {...props}>
|
|
36
|
+
{children}
|
|
37
|
+
<Close>
|
|
38
|
+
<X />
|
|
39
|
+
<span className={css({ srOnly: true })}>Close</span>
|
|
40
|
+
</Close>
|
|
41
|
+
</Dialog.Content>
|
|
42
|
+
</Portal>
|
|
43
|
+
))
|
|
44
|
+
|
|
45
|
+
export const Content = withContext<
|
|
46
|
+
ElementRef<typeof ContentPrimitive>,
|
|
47
|
+
ComponentProps<typeof ContentPrimitive>
|
|
48
|
+
>(ContentPrimitive, "content")
|
|
49
|
+
|
|
50
|
+
export const Trigger = withContext<
|
|
51
|
+
ElementRef<typeof Dialog.Trigger>,
|
|
52
|
+
Dialog.DialogTriggerProps
|
|
53
|
+
>(Dialog.Trigger, "trigger")
|
|
54
|
+
|
|
55
|
+
export const Header = withContext<
|
|
56
|
+
HTMLDivElement,
|
|
57
|
+
ComponentPropsWithoutRef<"div">
|
|
58
|
+
>("div", "header")
|
|
59
|
+
|
|
60
|
+
export const Footer = withContext<
|
|
61
|
+
HTMLDivElement,
|
|
62
|
+
ComponentPropsWithoutRef<"div">
|
|
63
|
+
>("div", "footer")
|
|
64
|
+
|
|
65
|
+
export const Title = withContext<
|
|
66
|
+
ElementRef<typeof Dialog.Title>,
|
|
67
|
+
Dialog.DialogTitleProps
|
|
68
|
+
>(Dialog.Title, "title")
|
|
69
|
+
|
|
70
|
+
export const Description = withContext<
|
|
71
|
+
ElementRef<typeof Dialog.Description>,
|
|
72
|
+
Dialog.DialogDescriptionProps
|
|
73
|
+
>(Dialog.Description, "description")
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { sva } from "@styled-system/css"
|
|
2
|
+
|
|
3
|
+
export const recipe = sva({
|
|
4
|
+
slots: [
|
|
5
|
+
"root",
|
|
6
|
+
"trigger",
|
|
7
|
+
"portal",
|
|
8
|
+
"overlay",
|
|
9
|
+
"close",
|
|
10
|
+
"content",
|
|
11
|
+
"header",
|
|
12
|
+
"footer",
|
|
13
|
+
"title",
|
|
14
|
+
"description",
|
|
15
|
+
],
|
|
16
|
+
base: {
|
|
17
|
+
overlay: {
|
|
18
|
+
position: "fixed",
|
|
19
|
+
inset: "0",
|
|
20
|
+
bg: "black/90",
|
|
21
|
+
},
|
|
22
|
+
content: {
|
|
23
|
+
bg: "background",
|
|
24
|
+
border: "input",
|
|
25
|
+
borderRadius: "md",
|
|
26
|
+
position: "fixed",
|
|
27
|
+
top: "[50%]",
|
|
28
|
+
left: "[50%]",
|
|
29
|
+
transform: "translate(-50%,-50%)",
|
|
30
|
+
width: "[100%]",
|
|
31
|
+
maxWidth: "[32rem]",
|
|
32
|
+
maxHeight: "[85vh]",
|
|
33
|
+
padding: "4",
|
|
34
|
+
"&[data-state=open]": {
|
|
35
|
+
animationName: "contentShow",
|
|
36
|
+
animationDuration: "slow",
|
|
37
|
+
},
|
|
38
|
+
|
|
39
|
+
"&[data-state=closed]": {
|
|
40
|
+
animationName: "fadeOut",
|
|
41
|
+
animationDuration: "slow",
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
close: {
|
|
45
|
+
position: "absolute",
|
|
46
|
+
right: "4",
|
|
47
|
+
top: "4",
|
|
48
|
+
rounded: "sm",
|
|
49
|
+
opacity: "0.7",
|
|
50
|
+
transition: "opacity",
|
|
51
|
+
cursor: "pointer",
|
|
52
|
+
|
|
53
|
+
_hover: {
|
|
54
|
+
opacity: "1",
|
|
55
|
+
},
|
|
56
|
+
|
|
57
|
+
_focus: {
|
|
58
|
+
ringWidth: "1",
|
|
59
|
+
ringColor: "ring",
|
|
60
|
+
ringOffset: "1",
|
|
61
|
+
},
|
|
62
|
+
|
|
63
|
+
_disabled: {
|
|
64
|
+
pointerEvents: "none",
|
|
65
|
+
},
|
|
66
|
+
|
|
67
|
+
"&[data-state=open]": {
|
|
68
|
+
bg: "accent",
|
|
69
|
+
color: "muted.foreground",
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
header: {
|
|
73
|
+
display: "flex",
|
|
74
|
+
flexDirection: "column",
|
|
75
|
+
gap: "1.5",
|
|
76
|
+
},
|
|
77
|
+
footer: {
|
|
78
|
+
display: "flex",
|
|
79
|
+
flexDirection: "column-reverse",
|
|
80
|
+
},
|
|
81
|
+
title: {
|
|
82
|
+
fontSize: "lg",
|
|
83
|
+
fontWeight: "semibold",
|
|
84
|
+
lineHeight: "none",
|
|
85
|
+
letterSpacing: "tight",
|
|
86
|
+
},
|
|
87
|
+
description: {
|
|
88
|
+
fontSize: "sm",
|
|
89
|
+
color: "foreground",
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
})
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { css, cx } from "@styled-system/css"
|
|
2
|
+
import { Select as SelectPrimitive } from "radix-ui"
|
|
3
|
+
import { ComponentPropsWithoutRef, ElementRef, forwardRef } from "react"
|
|
4
|
+
|
|
5
|
+
import { recipe } from "./recipe"
|
|
6
|
+
|
|
7
|
+
const BaseTrigger = forwardRef<
|
|
8
|
+
ElementRef<typeof SelectPrimitive.Trigger>,
|
|
9
|
+
ComponentPropsWithoutRef<typeof SelectPrimitive.Trigger>
|
|
10
|
+
>(({ children, ...props }, ref) => (
|
|
11
|
+
<SelectPrimitive.Trigger ref={ref} {...props}>
|
|
12
|
+
{children}
|
|
13
|
+
<SelectPrimitive.Icon asChild></SelectPrimitive.Icon>
|
|
14
|
+
</SelectPrimitive.Trigger>
|
|
15
|
+
))
|
|
16
|
+
|
|
17
|
+
BaseTrigger.displayName = SelectPrimitive.Trigger.displayName
|
|
18
|
+
|
|
19
|
+
export const Root = SelectPrimitive.Root
|
|
20
|
+
export const Group = SelectPrimitive.Group
|
|
21
|
+
export const Value = SelectPrimitive.Value
|
|
22
|
+
|
|
23
|
+
export const Trigger = forwardRef<
|
|
24
|
+
ElementRef<typeof BaseTrigger>,
|
|
25
|
+
ComponentPropsWithoutRef<typeof BaseTrigger>
|
|
26
|
+
>(({ className, ...props }, ref) => {
|
|
27
|
+
const styles = recipe.raw()
|
|
28
|
+
return (
|
|
29
|
+
<BaseTrigger
|
|
30
|
+
ref={ref}
|
|
31
|
+
className={cx(css(styles.trigger), className)}
|
|
32
|
+
{...props}
|
|
33
|
+
/>
|
|
34
|
+
)
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
export const Content = forwardRef<
|
|
38
|
+
ElementRef<typeof SelectPrimitive.Content>,
|
|
39
|
+
ComponentPropsWithoutRef<typeof SelectPrimitive.Content>
|
|
40
|
+
>(({ className, position = "popper", children, ...props }, ref) => {
|
|
41
|
+
const styles = recipe.raw()
|
|
42
|
+
return (
|
|
43
|
+
<SelectPrimitive.Portal>
|
|
44
|
+
<SelectPrimitive.Content
|
|
45
|
+
ref={ref}
|
|
46
|
+
position={position}
|
|
47
|
+
data-position={position}
|
|
48
|
+
className={cx(css(styles.content), className)}
|
|
49
|
+
{...props}
|
|
50
|
+
>
|
|
51
|
+
<Viewport data-position={position}>{children}</Viewport>
|
|
52
|
+
</SelectPrimitive.Content>
|
|
53
|
+
</SelectPrimitive.Portal>
|
|
54
|
+
)
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
export const Viewport = forwardRef<
|
|
58
|
+
ElementRef<typeof SelectPrimitive.Viewport>,
|
|
59
|
+
ComponentPropsWithoutRef<typeof SelectPrimitive.Viewport>
|
|
60
|
+
>(({ className, ...props }, ref) => {
|
|
61
|
+
const styles = recipe.raw()
|
|
62
|
+
return (
|
|
63
|
+
<SelectPrimitive.Viewport
|
|
64
|
+
ref={ref}
|
|
65
|
+
{...props}
|
|
66
|
+
className={cx(css(styles.viewport), className)}
|
|
67
|
+
/>
|
|
68
|
+
)
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
export const Item = forwardRef<
|
|
72
|
+
ElementRef<typeof SelectPrimitive.Item>,
|
|
73
|
+
ComponentPropsWithoutRef<typeof SelectPrimitive.Item>
|
|
74
|
+
>(({ className, children, ...props }, ref) => {
|
|
75
|
+
const styles = recipe.raw()
|
|
76
|
+
return (
|
|
77
|
+
<SelectPrimitive.Item
|
|
78
|
+
ref={ref}
|
|
79
|
+
className={cx(css(styles.item), className)}
|
|
80
|
+
{...props}
|
|
81
|
+
>
|
|
82
|
+
<Indicator />
|
|
83
|
+
<SelectPrimitive.ItemText>{children}</SelectPrimitive.ItemText>
|
|
84
|
+
</SelectPrimitive.Item>
|
|
85
|
+
)
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
export const Label = forwardRef<
|
|
89
|
+
ElementRef<typeof SelectPrimitive.Label>,
|
|
90
|
+
ComponentPropsWithoutRef<typeof SelectPrimitive.Label>
|
|
91
|
+
>(({ className, ...props }, ref) => {
|
|
92
|
+
const styles = recipe.raw()
|
|
93
|
+
return (
|
|
94
|
+
<SelectPrimitive.Label
|
|
95
|
+
ref={ref}
|
|
96
|
+
className={cx(css(styles.label), className)}
|
|
97
|
+
{...props}
|
|
98
|
+
/>
|
|
99
|
+
)
|
|
100
|
+
})
|
|
101
|
+
|
|
102
|
+
export const Separator = forwardRef<
|
|
103
|
+
ElementRef<typeof SelectPrimitive.Separator>,
|
|
104
|
+
ComponentPropsWithoutRef<typeof SelectPrimitive.Separator>
|
|
105
|
+
>(({ className, ...props }, ref) => {
|
|
106
|
+
const styles = recipe.raw()
|
|
107
|
+
return (
|
|
108
|
+
<SelectPrimitive.Separator
|
|
109
|
+
ref={ref}
|
|
110
|
+
className={cx(css(styles.separator), className)}
|
|
111
|
+
{...props}
|
|
112
|
+
/>
|
|
113
|
+
)
|
|
114
|
+
})
|
|
115
|
+
|
|
116
|
+
export const Indicator = forwardRef<
|
|
117
|
+
ElementRef<typeof SelectPrimitive.ItemIndicator>,
|
|
118
|
+
ComponentPropsWithoutRef<typeof SelectPrimitive.ItemIndicator>
|
|
119
|
+
>(({ className, ...props }, ref) => {
|
|
120
|
+
const styles = recipe.raw()
|
|
121
|
+
return (
|
|
122
|
+
<SelectPrimitive.ItemIndicator
|
|
123
|
+
ref={ref}
|
|
124
|
+
className={cx(css(styles.itemIndicator), className)}
|
|
125
|
+
{...props}
|
|
126
|
+
/>
|
|
127
|
+
)
|
|
128
|
+
})
|