Skip to content

Commit a1dfb28

Browse files
committed
Merge branch 'dev' into shadcn-mobile-menu
2 parents 81370fe + 9361453 commit a1dfb28

File tree

8 files changed

+200
-2
lines changed

8 files changed

+200
-2
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
"@emotion/styled": "^11.11.0",
3636
"@hookform/resolvers": "^3.8.0",
3737
"@radix-ui/react-accordion": "^1.2.0",
38+
"@radix-ui/react-checkbox": "^1.1.1",
3839
"@radix-ui/react-dialog": "^1.1.1",
3940
"@radix-ui/react-navigation-menu": "^1.2.0",
4041
"@radix-ui/react-popover": "^1.1.1",

src/layouts/BaseLayout.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ export const BaseLayout = ({
5252
* layout on initial load.
5353
*/}
5454
<SkipLink />
55-
<div className="max-w-screen-2xl mx-auto">
55+
<div className="mx-auto max-w-screen-2xl">
5656
<Nav />
5757

5858
{/* TODO: FIX TRANSLATION BANNER LOGIC FOR https://github.com/ethereum/ethereum-org-website/issues/11305 */}

tailwind.config.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { Config } from "tailwindcss"
2+
import plugin from "tailwindcss/plugin"
23

34
const config = {
45
darkMode: ["class"],
@@ -189,7 +190,24 @@ const config = {
189190
},
190191
},
191192
},
192-
plugins: [require("tailwindcss-animate")],
193+
plugins: [
194+
require("tailwindcss-animate"),
195+
plugin(function ({ matchVariant }) {
196+
// The :not() pseudo-class. `i.e. not-[:checked]`
197+
matchVariant(
198+
"not",
199+
(value) => {
200+
return `&:not(${value})`
201+
},
202+
{
203+
values: {
204+
// not-disabled => ":not(:disabled)"
205+
disabled: ":disabled",
206+
},
207+
}
208+
)
209+
}),
210+
],
193211
} satisfies Config
194212

195213
export default config

tailwind/ui/Checkbox.tsx

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import * as React from "react"
2+
import { RxCheck } from "react-icons/rx"
3+
import * as CheckboxPrimitive from "@radix-ui/react-checkbox"
4+
5+
import { cn } from "@/lib/utils/cn"
6+
7+
export type CheckboxProps = React.ComponentPropsWithoutRef<
8+
typeof CheckboxPrimitive.Root
9+
>
10+
11+
const Checkbox = React.forwardRef<
12+
React.ElementRef<typeof CheckboxPrimitive.Root>,
13+
CheckboxProps
14+
>(({ className, ...props }, ref) => (
15+
<CheckboxPrimitive.Root
16+
ref={ref}
17+
className={cn(
18+
"size-4 rounded-sm border border-body-medium text-background hover:border-primary-high-contrast hover:bg-body-light focus-visible:outline-offset-4 focus-visible:outline-primary-hover disabled:cursor-not-allowed disabled:border-disabled disabled:bg-disabled aria-[invalid]:border-error aria-[invalid]:bg-error-light data-[state='checked']:not-disabled:border-primary data-[state='checked']:not-disabled:bg-primary data-[state='checked']:hover:not-disabled:bg-primary-hover",
19+
className
20+
)}
21+
{...props}
22+
>
23+
<CheckboxPrimitive.Indicator className="flex items-center justify-center">
24+
<RxCheck className="text-sm" />
25+
</CheckboxPrimitive.Indicator>
26+
</CheckboxPrimitive.Root>
27+
))
28+
Checkbox.displayName = CheckboxPrimitive.Root.displayName
29+
30+
export default Checkbox

tailwind/ui/Input.tsx

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import * as React from "react"
2+
import { cva, type VariantProps } from "class-variance-authority"
3+
4+
import { cn } from "@/lib/utils/cn"
5+
6+
const inputVariants = cva(
7+
"rounded border border-body placeholder:text-disabled hover:not-disabled:border-primary-hover focus-visible:outline focus-visible:outline-primary-hover focus-visible:outline-[3px] focus-visible:-outline-offset-2 disabled:cursor-not-allowed disabled:border-disabled bg-background",
8+
{
9+
variants: {
10+
size: {
11+
md: "p-2",
12+
sm: "p-1 text-sm",
13+
},
14+
},
15+
defaultVariants: {
16+
size: "md",
17+
},
18+
}
19+
)
20+
21+
export interface InputProps
22+
extends Omit<React.InputHTMLAttributes<HTMLInputElement>, "size">,
23+
VariantProps<typeof inputVariants> {}
24+
25+
const Input = React.forwardRef<HTMLInputElement, InputProps>(
26+
({ className, type, size, ...props }, ref) => {
27+
return (
28+
<input
29+
type={type}
30+
className={cn(inputVariants({ size, className }))}
31+
ref={ref}
32+
{...props}
33+
/>
34+
)
35+
}
36+
)
37+
Input.displayName = "Input"
38+
39+
export default Input
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import type { Meta, StoryObj } from "@storybook/react/*"
2+
3+
import { HStack, VStack } from "../../../src/components/ui/flex"
4+
import CheckboxComponent, { type CheckboxProps } from "../Checkbox"
5+
6+
const meta = {
7+
title: "Atoms / Form / ShadCN Checkbox",
8+
component: CheckboxComponent,
9+
} satisfies Meta<typeof CheckboxComponent>
10+
11+
export default meta
12+
13+
const checkboxDataSet: (CheckboxProps & { label: string })[] = [
14+
{
15+
id: "default",
16+
value: "default",
17+
label: "default",
18+
},
19+
{
20+
id: "checked",
21+
value: "checked",
22+
label: "checked",
23+
checked: true,
24+
},
25+
{
26+
id: "disabled",
27+
value: "disabled",
28+
label: "disabled",
29+
disabled: true,
30+
},
31+
{
32+
id: "disabled-checked",
33+
value: "disabled-checked",
34+
label: "disabled-checked",
35+
disabled: true,
36+
checked: true,
37+
},
38+
{
39+
id: "invalid",
40+
value: "invalid",
41+
label: "invalid",
42+
"aria-invalid": true,
43+
},
44+
]
45+
46+
export const Checkbox: StoryObj<typeof meta> = {
47+
render: () => (
48+
<VStack className="items-start gap-4">
49+
{checkboxDataSet.map(({ label, ...props }) => (
50+
<HStack key={props.id} asChild>
51+
<label>
52+
<CheckboxComponent {...props} />
53+
{label}
54+
</label>
55+
</HStack>
56+
))}
57+
</VStack>
58+
),
59+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import type { Meta, StoryObj } from "@storybook/react/*"
2+
3+
import { VStack } from "../../../src/components/ui/flex"
4+
import Input from "../Input"
5+
6+
const meta = {
7+
title: "Atoms / Form / ShadCN Input",
8+
component: Input,
9+
} satisfies Meta<typeof Input>
10+
11+
export default meta
12+
13+
type Story = StoryObj<typeof meta>
14+
15+
export const Sizes: Story = {
16+
args: {
17+
placeholder: "Search",
18+
},
19+
render: (args) => (
20+
<VStack className="w-[154px]">
21+
<Input {...args} />
22+
<Input {...args} size="sm" />
23+
</VStack>
24+
),
25+
}
26+
27+
export const ElementVariations: Story = {
28+
args: {
29+
placeholder: "input text",
30+
},
31+
render: (args) => (
32+
<VStack className="w-[258px] gap-4">
33+
<Input {...args} autoFocus />
34+
<Input {...args} disabled />
35+
</VStack>
36+
),
37+
}

yarn.lock

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3789,6 +3789,20 @@
37893789
dependencies:
37903790
"@radix-ui/react-primitive" "2.0.0"
37913791

3792+
"@radix-ui/react-checkbox@^1.1.1":
3793+
version "1.1.1"
3794+
resolved "https://registry.yarnpkg.com/@radix-ui/react-checkbox/-/react-checkbox-1.1.1.tgz#a559c4303957d797acee99914480b755aa1f27d6"
3795+
integrity sha512-0i/EKJ222Afa1FE0C6pNJxDq1itzcl3HChE9DwskA4th4KRse8ojx8a1nVcOjwJdbpDLcz7uol77yYnQNMHdKw==
3796+
dependencies:
3797+
"@radix-ui/primitive" "1.1.0"
3798+
"@radix-ui/react-compose-refs" "1.1.0"
3799+
"@radix-ui/react-context" "1.1.0"
3800+
"@radix-ui/react-presence" "1.1.0"
3801+
"@radix-ui/react-primitive" "2.0.0"
3802+
"@radix-ui/react-use-controllable-state" "1.1.0"
3803+
"@radix-ui/react-use-previous" "1.1.0"
3804+
"@radix-ui/react-use-size" "1.1.0"
3805+
37923806
"@radix-ui/[email protected]":
37933807
version "1.1.0"
37943808
resolved "https://registry.yarnpkg.com/@radix-ui/react-collapsible/-/react-collapsible-1.1.0.tgz#4d49ddcc7b7d38f6c82f1fd29674f6fab5353e77"

0 commit comments

Comments
 (0)