Skip to content

Commit

Permalink
docs: improve displaying the variant/size in the appearance demo (#4304)
Browse files Browse the repository at this point in the history
* docs: improve displaying the variant/size in the appearance demo

* udpate

* default all the things
  • Loading branch information
sebald authored Nov 20, 2024
1 parent 2ccd57a commit 8914fb0
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
20 changes: 16 additions & 4 deletions docs/ui/AppearanceDemo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,16 @@ export const AppearanceDemo = ({
const appearance = getAppearance(component, theme);

const [selected, setSelected] = useState({
variant: 'default',
size: 'default',
variant: appearance.variant.length
? appearance.variant.includes('default')
? 'default'
: appearance.variant[0]
: 'none',
size: appearance.size.length
? appearance.size.includes('default')
? 'default'
: appearance.size[0]
: 'none',
});

const Wrapper = ({ children }: { children: ReactNode }) =>
Expand Down Expand Up @@ -106,7 +114,9 @@ export const AppearanceDemo = ({
}
disabled={appearance.variant.length === 0 ? true : false}
>
<Select.Option id="default">default</Select.Option>
{appearance.variant.length === 0 ? (
<Select.Option id="none">default</Select.Option>
) : null}
{appearance.variant.map(v => (
<Select.Option key={v} id={v}>
{v}
Expand All @@ -124,7 +134,9 @@ export const AppearanceDemo = ({
}
disabled={appearance.size.length === 0 ? true : false}
>
<Select.Option id="default">default</Select.Option>
{appearance.size.length === 0 ? (
<Select.Option id="none">default</Select.Option>
) : null}
{appearance.size.map(v => (
<Select.Option key={v} id={v}>
{v}
Expand Down
6 changes: 6 additions & 0 deletions themes/theme-b2b/src/components/Button.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export const Button: ThemeComponent<'Button'> = cva(
{
variants: {
variant: {
default: '',
primary: [
'text-text-inverted bg-bg-accent',
'hover:bg-bg-accent-hover',
Expand Down Expand Up @@ -36,8 +37,13 @@ export const Button: ThemeComponent<'Button'> = cva(
],
},
size: {
default: '',
small: 'px-4 leading-8',
},
},
defaultVariants: {
variant: 'default',
size: 'default',
},
}
);
6 changes: 6 additions & 0 deletions themes/theme-core/src/components/Button.styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const Button: ThemeComponent<'Button'> = cva(
{
variants: {
variant: {
default: '',
primary: [
'border-border-brand bg-bg-brand text-text-inverted',
'hover:bg-bg-brand-hover hover:border-border-brand-hover',
Expand All @@ -32,8 +33,13 @@ export const Button: ThemeComponent<'Button'> = cva(
],
},
size: {
default: '',
small: 'py-1',
},
},
defaultVariants: {
variant: 'default',
size: 'default',
},
}
);

0 comments on commit 8914fb0

Please sign in to comment.