Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
ba9eaed
fix(avatar): apply vanilla-extract (#143)
noahluftyang Apr 5, 2025
0570951
refactor(badge): apply vanilla-extract (#144)
froggy1014 Apr 19, 2025
efb5c5d
refactor(checkbox): migrate to vanilla-extract and refactor
froggy1014 Apr 29, 2025
551ff78
Merge branch 'release/v1' into refactor/checkbox-vanilla
froggy1014 Apr 29, 2025
e12b3b2
chore(checkbox): delete ref on Root
froggy1014 Apr 30, 2025
c49ba9f
chore(checkbox): add optional id prop to Checkbox component
froggy1014 Apr 30, 2025
a53cda9
refactor(checkbox): simplify useControllableState hook
froggy1014 May 1, 2025
5727106
chore(checkbox): delete unused hook
froggy1014 May 1, 2025
28c3fa9
refactor(checkbox): enhance props and structure
froggy1014 May 1, 2025
c5c5c36
refactor(checkbox): enhance storybook and test code
froggy1014 May 1, 2025
183e1a2
chore(checkbox): update dependency include vanilla extract recipes
froggy1014 May 1, 2025
bf7d393
Merge branch 'release/v1' into refactor/checkbox-vanilla
froggy1014 May 1, 2025
12b5014
Merge branch 'release/v1' into refactor/checkbox-vanilla
froggy1014 May 1, 2025
fb28dff
chore(checkbox): add user-event package in project
froggy1014 May 1, 2025
9dfd20e
chore: add module.css type declarations
froggy1014 May 1, 2025
e11a993
Merge branch 'release/v1' into refactor/checkbox-vanilla
froggy1014 May 7, 2025
7fb6eb4
refactor(checkbox): accept and update feedback
froggy1014 May 7, 2025
16de987
chore(checkbox): replace HTMLAttrivutes to ComponentProps
froggy1014 May 7, 2025
e0af761
chore(checkbox): delete useless code
froggy1014 May 7, 2025
8aab087
chore(checkbox): resolve type error
froggy1014 May 8, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions packages/checkbox/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
},
"type": "module",
"exports": "./src/index.ts",
"files": [
"dist"
],
"files": ["dist"],
"scripts": {
"build": "tsup",
"build:storybook": "storybook build",
Expand All @@ -23,9 +21,9 @@
"prepack": "pnpm run build"
},
"dependencies": {
"@radix-ui/react-slot": "^1.1.0",
"@sipe-team/tokens": "workspace:*",
"clsx": "^2.1.1",
"nanoid": "^5.0.9"
"@vanilla-extract/recipes": "^0.5.5"
},
"devDependencies": {
"@storybook/addon-essentials": "catalog:",
Expand All @@ -37,7 +35,9 @@
"@storybook/test": "catalog:",
"@testing-library/jest-dom": "catalog:",
"@testing-library/react": "catalog:",
"@testing-library/user-event": "catalog:",
"@types/react": "^18.3.12",
"@vanilla-extract/css": "^1.17.1",
"happy-dom": "catalog:",
"react": "^18.3.1",
"react-dom": "^18.3.1",
Expand Down
201 changes: 201 additions & 0 deletions packages/checkbox/src/Checkbox.css.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,201 @@
import { color } from '@sipe-team/tokens';
import type { RecipeVariants } from '@vanilla-extract/recipes';
import { recipe } from '@vanilla-extract/recipes';
import { CheckboxSize } from './Checkbox';

export const CHECKBOX_SIZES = {
[CheckboxSize.small]: {
inputSize: '16px',
fontSize: '14px',
containerPadding: '8px',
containerMargin: '4px',
},
[CheckboxSize.medium]: {
inputSize: '20px',
fontSize: '16px',
containerPadding: '10px',
containerMargin: '6px',
},
[CheckboxSize.large]: {
inputSize: '24px',
fontSize: '18px',
containerPadding: '12px',
containerMargin: '8px',
},
} as const;

const BORDER_RADIUS_PX = 4;
const BORDER_WIDTH_PX = 1;
const CONTAINER_GAP_PX = 8;

const COLORS = {
border: color.gray300 || '#D1D5DB',
background: color.white || '#FFFFFF',
checked: '#3B82F6',
disabled: color.gray200 || '#E5E7EB',
hover: color.gray100 || '#F3F4F6',
};

const CHECKBOX_STYLE = {
borderRadius: BORDER_RADIUS_PX,
borderWidth: BORDER_WIDTH_PX,
borderColor: COLORS.border,
backgroundColor: COLORS.background,
checkedColor: COLORS.checked,
disabledColor: COLORS.disabled,
hoverColor: COLORS.hover,
backgroundSize: '100%',
backgroundPosition: 'center',
backgroundRepeat: 'no-repeat',
transition: 'all 0.15s ease-in-out',
} as const;

export const container = recipe({
base: {
display: 'flex',
alignItems: 'center',
gap: `${CONTAINER_GAP_PX}px`,
},
variants: {
size: {
[CheckboxSize.small]: {
padding: CHECKBOX_SIZES[CheckboxSize.small].containerPadding,
margin: CHECKBOX_SIZES[CheckboxSize.small].containerMargin,
},
[CheckboxSize.medium]: {
padding: CHECKBOX_SIZES[CheckboxSize.medium].containerPadding,
margin: CHECKBOX_SIZES[CheckboxSize.medium].containerMargin,
},
[CheckboxSize.large]: {
padding: CHECKBOX_SIZES[CheckboxSize.large].containerPadding,
margin: CHECKBOX_SIZES[CheckboxSize.large].containerMargin,
},
},
disabled: {
true: {},
false: {},
},
},
defaultVariants: {
size: CheckboxSize.medium,
disabled: false,
},
});
export type ContainerVariants = RecipeVariants<typeof container>;

export const input = recipe({
base: {
appearance: 'none',
border: `${CHECKBOX_STYLE.borderWidth}px solid ${CHECKBOX_STYLE.borderColor}`,
backgroundColor: CHECKBOX_STYLE.backgroundColor,
backgroundSize: CHECKBOX_STYLE.backgroundSize,
backgroundPosition: CHECKBOX_STYLE.backgroundPosition,
backgroundRepeat: CHECKBOX_STYLE.backgroundRepeat,
transition: CHECKBOX_STYLE.transition,
cursor: 'pointer',
},
variants: {
size: {
[CheckboxSize.small]: {
width: CHECKBOX_SIZES[CheckboxSize.small].inputSize,
height: CHECKBOX_SIZES[CheckboxSize.small].inputSize,
borderRadius: `${CHECKBOX_STYLE.borderRadius}px`,
},
[CheckboxSize.medium]: {
width: CHECKBOX_SIZES[CheckboxSize.medium].inputSize,
height: CHECKBOX_SIZES[CheckboxSize.medium].inputSize,
borderRadius: `${CHECKBOX_STYLE.borderRadius}px`,
},
[CheckboxSize.large]: {
width: CHECKBOX_SIZES[CheckboxSize.large].inputSize,
height: CHECKBOX_SIZES[CheckboxSize.large].inputSize,
borderRadius: `${CHECKBOX_STYLE.borderRadius}px`,
},
},
checked: {
true: {
backgroundColor: CHECKBOX_STYLE.checkedColor,
borderColor: CHECKBOX_STYLE.checkedColor,
backgroundImage: `url("public/check.svg")`,
},
},
indeterminate: {
true: {
backgroundColor: CHECKBOX_STYLE.checkedColor,
borderColor: CHECKBOX_STYLE.checkedColor,
backgroundImage: `url("public/indeterminate.svg")`,
},
},
disabled: {
true: {
backgroundColor: CHECKBOX_STYLE.disabledColor,
borderColor: CHECKBOX_STYLE.disabledColor,
cursor: 'not-allowed',
},
false: {},
},
},
compoundVariants: [
{
variants: {
checked: true,
disabled: true,
},
style: {
backgroundColor: CHECKBOX_STYLE.disabledColor,
borderColor: CHECKBOX_STYLE.disabledColor,
backgroundImage: `url("public/check.svg")`,
opacity: 0.6,
},
},
{
variants: {
indeterminate: true,
disabled: true,
},
style: {
backgroundColor: CHECKBOX_STYLE.disabledColor,
borderColor: CHECKBOX_STYLE.disabledColor,
backgroundImage: `url("public/indeterminate.svg")`,
opacity: 0.6,
},
},
],
defaultVariants: {
size: CheckboxSize.medium,
disabled: false,
},
});
export type InputVariants = RecipeVariants<typeof input>;

// Label recipe
export const label = recipe({
base: {
cursor: 'pointer',
},
variants: {
size: {
[CheckboxSize.small]: {
fontSize: CHECKBOX_SIZES[CheckboxSize.small].fontSize,
},
[CheckboxSize.medium]: {
fontSize: CHECKBOX_SIZES[CheckboxSize.medium].fontSize,
},
[CheckboxSize.large]: {
fontSize: CHECKBOX_SIZES[CheckboxSize.large].fontSize,
},
},
disabled: {
true: {
cursor: 'not-allowed',
opacity: 0.6,
},
false: {},
},
},
defaultVariants: {
size: CheckboxSize.medium,
disabled: false,
},
});
export type LabelVariants = RecipeVariants<typeof label>;
47 changes: 0 additions & 47 deletions packages/checkbox/src/Checkbox.module.css

This file was deleted.

Loading