-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove react emotion lib and add typescript to rollup
- Loading branch information
1 parent
cfd2126
commit bd23742
Showing
10 changed files
with
187 additions
and
40 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import type { Meta, StoryObj } from "@storybook/react" | ||
import { Dot } from "./Dot" | ||
|
||
type Story = StoryObj<typeof Dot> | ||
|
||
const themes = [ | ||
"blue", | ||
"orange", | ||
"yellow", | ||
"red", | ||
"green", | ||
"purple", | ||
"pink", | ||
"teal", | ||
"gray", | ||
] as const | ||
|
||
const sizes = ["sm", "md", "lg"] as const | ||
const variants = ["solid", "soft", "outline"] as const | ||
|
||
// Meta | ||
export default { | ||
title: "Design System/Dot", | ||
component: Dot, | ||
tags: ["autodocs"], | ||
} satisfies Meta | ||
|
||
// Stories | ||
export const Default = { | ||
args: {}, | ||
} satisfies Story | ||
|
||
export const AsChild = { | ||
args: { | ||
asChild: true, | ||
children: <a href="/" />, | ||
}, | ||
} satisfies Story | ||
|
||
export const AllSizes = () => { | ||
return ( | ||
<div className="flex items-center flex-wrap gap-4"> | ||
{sizes.map((s) => ( | ||
<Dot key={s} size={s} /> | ||
))} | ||
</div> | ||
) | ||
} | ||
|
||
export const AllThemes = () => { | ||
return ( | ||
<div className="flex items-center flex-wrap gap-4"> | ||
{themes.map((t) => ( | ||
<Dot key={t} theme={t} /> | ||
))} | ||
</div> | ||
) | ||
} | ||
|
||
export const AllVariants = () => { | ||
return ( | ||
<div className="flex items-center flex-wrap gap-4"> | ||
{variants.map((v) => ( | ||
<Dot key={v} variant={v} /> | ||
))} | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { Slot } from "@radix-ui/react-slot" | ||
import { VariantProps } from "cva" | ||
import { isValidElement, type HTMLAttributes, forwardRef } from "react" | ||
import { dotVariants } from "./Dot.variants" | ||
|
||
export type DotElement = HTMLSpanElement | ||
|
||
export type DotProps = Omit<HTMLAttributes<DotElement>, "size"> & | ||
VariantProps<typeof dotVariants> & { | ||
/** | ||
* If set to `true`, the button will be rendered as a child within the component. | ||
* This child component must be a valid React component. | ||
*/ | ||
asChild?: boolean | ||
} | ||
|
||
export const Dot = forwardRef<DotElement, DotProps>((props, ref) => { | ||
const { className, asChild, theme, variant, size, ...rest } = props | ||
|
||
const useAsChild = asChild && isValidElement(rest.children) | ||
const Component = useAsChild ? Slot : "span" | ||
|
||
return ( | ||
<Component className={dotVariants({ theme, variant, size, className })} ref={ref} {...rest} /> | ||
) | ||
}) | ||
|
||
Dot.defaultProps = { | ||
theme: "blue", | ||
variant: "solid", | ||
size: "md", | ||
asChild: false, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import { cva } from "~/shared/cva" | ||
|
||
export const dotVariants = cva({ | ||
base: "block rounded-full border border-transparent text-white", | ||
|
||
variants: { | ||
theme: { | ||
blue: "", | ||
orange: "", | ||
red: "", | ||
yellow: "", | ||
green: "", | ||
purple: "", | ||
pink: "", | ||
teal: "", | ||
gray: "", | ||
}, | ||
variant: { | ||
solid: "", | ||
soft: "", | ||
outline: "", | ||
}, | ||
size: { | ||
sm: "size-1.5", | ||
md: "size-2", | ||
lg: "size-2.5", | ||
}, | ||
}, | ||
|
||
compoundVariants: [ | ||
// Blue | ||
{ theme: "blue", variant: "solid", class: "bg-blue" }, | ||
{ theme: "blue", variant: "soft", class: "bg-blue-light" }, | ||
{ theme: "blue", variant: "outline", class: "border-blue-dark" }, | ||
|
||
// Orange | ||
{ theme: "orange", variant: "solid", class: "bg-orange" }, | ||
{ theme: "orange", variant: "soft", class: "bg-orange-light" }, | ||
{ theme: "orange", variant: "outline", class: "border-orange-dark" }, | ||
|
||
// Red | ||
{ theme: "red", variant: "solid", class: "bg-red" }, | ||
{ theme: "red", variant: "soft", class: "bg-red-light" }, | ||
{ theme: "red", variant: "outline", class: "border-red-dark" }, | ||
|
||
// Yellow | ||
{ theme: "yellow", variant: "solid", class: "bg-yellow" }, | ||
{ theme: "yellow", variant: "soft", class: "bg-yellow-light" }, | ||
{ theme: "yellow", variant: "outline", class: "border-yellow-dark" }, | ||
|
||
// Green | ||
{ theme: "green", variant: "solid", class: "bg-green" }, | ||
{ theme: "green", variant: "soft", class: "bg-green-light" }, | ||
{ theme: "green", variant: "outline", class: "border-green-dark" }, | ||
|
||
// Purple | ||
{ theme: "purple", variant: "solid", class: "bg-purple" }, | ||
{ theme: "purple", variant: "soft", class: "bg-purple-light" }, | ||
{ theme: "purple", variant: "outline", class: "border-purple-dark" }, | ||
|
||
// Pink | ||
{ theme: "pink", variant: "solid", class: "bg-pink" }, | ||
{ theme: "pink", variant: "soft", class: "bg-pink-light" }, | ||
{ theme: "pink", variant: "outline", class: "border-pink-dark" }, | ||
|
||
// Teal | ||
{ theme: "teal", variant: "solid", class: "bg-teal" }, | ||
{ theme: "teal", variant: "soft", class: "bg-teal-light" }, | ||
{ theme: "teal", variant: "outline", class: "border-teal-dark" }, | ||
|
||
// Gray | ||
{ theme: "gray", variant: "solid", class: "bg-gray-700" }, | ||
{ theme: "gray", variant: "soft", class: "bg-gray-200" }, | ||
{ theme: "gray", variant: "outline", class: "border-gray-700" }, | ||
], | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export * from "./Dot" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters