-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: reimplementing Box and Stack with sprinkles and intrinsic attri…
…bues
- Loading branch information
Showing
7 changed files
with
141 additions
and
80 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,45 @@ | ||
import clsx from 'clsx'; | ||
import React from 'react'; | ||
|
||
import { sprinkles, type Sprinkles } from '../../styles/sprinkles.css'; | ||
import { stack, type RecipeStackProps } from '../../styles/stack.css'; | ||
|
||
import { | ||
variantColourSwatch, | ||
type VariantColourSwatchProps, | ||
} from './styles.css'; | ||
|
||
type ElementAttributes = React.ComponentPropsWithoutRef<'div'>; | ||
type FilteredAttributes = Pick<ElementAttributes, 'className' | 'style'>; | ||
type ComponentProps<P> = React.PropsWithChildren<P & FilteredAttributes>; | ||
|
||
export const Box = ({ | ||
children, | ||
className, | ||
style, | ||
...props | ||
}: ComponentProps<Sprinkles>) => ( | ||
<div className={clsx([sprinkles(props), className])} style={style}> | ||
{children} | ||
</div> | ||
); | ||
|
||
export const Stack = ({ | ||
children, | ||
className, | ||
style, | ||
...props | ||
}: RecipeStackProps & { children: React.ReactNode }) => ( | ||
<div className={stack(props)}>{children}</div> | ||
}: ComponentProps<RecipeStackProps>) => ( | ||
<div className={clsx([stack(props), className])} style={style}> | ||
{children} | ||
</div> | ||
); | ||
|
||
type ColourSwatchProps = ComponentProps< | ||
Omit<Sprinkles, 'size'> & VariantColourSwatchProps | ||
>; | ||
export const ColourSwatch = ({ shape, size, ...props }: ColourSwatchProps) => ( | ||
<Box {...props} className={variantColourSwatch({ shape, size })}></Box> | ||
); | ||
|
||
export { type Sprinkles } from '../../styles/sprinkles.css'; |
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,45 @@ | ||
import { style } from '@vanilla-extract/css'; | ||
import { recipe, type RecipeVariants } from '@vanilla-extract/recipes'; | ||
|
||
import { themeContractVars as vars } from '../../themes/theme.css'; | ||
|
||
export const titles = style({ | ||
marginTop: '11px', | ||
}); | ||
|
||
export const labels = style({ | ||
textTransform: 'capitalize', | ||
}); | ||
|
||
export const hexPill = style({ | ||
backgroundColor: 'hsl(0 0 100 / 75%)', | ||
borderRadius: '100px', | ||
display: 'inline-block', | ||
fontSize: '11px', | ||
padding: '1px 8px', | ||
position: 'absolute', | ||
textTransform: 'uppercase', | ||
top: '5px', | ||
}); | ||
|
||
export const variantColourSwatch = recipe({ | ||
base: { position: 'relative' }, | ||
variants: { | ||
size: { | ||
sm: { height: vars.space[7], width: vars.space[7] }, | ||
md: { height: vars.space[8], width: vars.space[8] }, | ||
lg: { height: vars.space[9], width: vars.space[9] }, | ||
}, | ||
shape: { | ||
circle: { borderRadius: '100%' }, | ||
}, | ||
}, | ||
defaultVariants: { | ||
size: 'md', | ||
shape: 'circle', | ||
}, | ||
}); | ||
|
||
export type VariantColourSwatchProps = NonNullable< | ||
RecipeVariants<typeof variantColourSwatch> | ||
>; |
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
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