forked from cerc-io/snowballtools-base
♻️ refactor: add disabled button example page
This commit is contained in:
parent
6df094bf2e
commit
9dec48d67c
@ -10,6 +10,7 @@ import { renderBadges } from './renders/badge';
|
|||||||
import {
|
import {
|
||||||
renderButtonIcons,
|
renderButtonIcons,
|
||||||
renderButtons,
|
renderButtons,
|
||||||
|
renderDisabledButtons,
|
||||||
renderLinks,
|
renderLinks,
|
||||||
} from './renders/button';
|
} from './renders/button';
|
||||||
import {
|
import {
|
||||||
@ -53,6 +54,27 @@ const Page = () => {
|
|||||||
{renderButtonIcons()}
|
{renderButtonIcons()}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
{/* Link */}
|
||||||
|
<div className="flex flex-col gap-10 items-center justify-between">
|
||||||
|
<h1 className="text-2xl font-bold">Link</h1>
|
||||||
|
<div className="flex gap-4 items-center justify-center">
|
||||||
|
{renderLinks()}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
{/* Disabled button, icon only, and link */}
|
||||||
|
<div className="flex flex-col gap-10 items-center justify-between">
|
||||||
|
<div className="flex flex-col gap-2">
|
||||||
|
<h1 className="text-2xl font-bold text-center">Disabled</h1>
|
||||||
|
<p className="text-lg text-center text-gray-500">
|
||||||
|
Button – icon only – link
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<div className="flex gap-10 items-center justify-center">
|
||||||
|
{renderDisabledButtons()}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div className="w-full h border border-gray-200 px-20 my-10" />
|
<div className="w-full h border border-gray-200 px-20 my-10" />
|
||||||
|
|
||||||
{/* Badge */}
|
{/* Badge */}
|
||||||
@ -139,16 +161,6 @@ const Page = () => {
|
|||||||
{renderInlineNotificationWithDescriptions()}
|
{renderInlineNotificationWithDescriptions()}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="w-full h border border-gray-200 px-20 my-10" />
|
|
||||||
|
|
||||||
{/* Link */}
|
|
||||||
<div className="flex flex-col gap-10 items-center justify-between">
|
|
||||||
<h1 className="text-2xl font-bold">Link</h1>
|
|
||||||
<div className="flex gap-4 items-center justify-center">
|
|
||||||
{renderLinks()}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -2,44 +2,45 @@ import { Button, ButtonTheme } from 'components/shared/Button';
|
|||||||
import { PlusIcon } from 'components/shared/CustomIcon';
|
import { PlusIcon } from 'components/shared/CustomIcon';
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
|
||||||
export const renderButtons = () => {
|
const buttonVariants = ['primary', 'secondary', 'tertiary', 'danger'] as const;
|
||||||
return ['primary', 'secondary', 'tertiary', 'danger'].map(
|
const buttonSizes = ['lg', 'md', 'sm', 'xs'] as const;
|
||||||
(variant, index) => (
|
const iconOnlyVariants = [
|
||||||
<div className="flex gap-5 flex-wrap" key={index}>
|
|
||||||
{['lg', 'md', 'sm', 'xs', 'disabled'].map((size) => (
|
|
||||||
<Button
|
|
||||||
leftIcon={<PlusIcon />}
|
|
||||||
rightIcon={<PlusIcon />}
|
|
||||||
variant={variant as ButtonTheme['variant']}
|
|
||||||
size={size !== 'disabled' ? (size as ButtonTheme['size']) : 'md'}
|
|
||||||
key={`${variant}-${size}`}
|
|
||||||
disabled={size === 'disabled'}
|
|
||||||
>
|
|
||||||
Button
|
|
||||||
</Button>
|
|
||||||
))}
|
|
||||||
</div>
|
|
||||||
),
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
export const renderButtonIcons = () => {
|
|
||||||
return [
|
|
||||||
'primary',
|
'primary',
|
||||||
'secondary',
|
'secondary',
|
||||||
'tertiary',
|
'tertiary',
|
||||||
'ghost',
|
'ghost',
|
||||||
'danger',
|
'danger',
|
||||||
'danger-ghost',
|
'danger-ghost',
|
||||||
].map((variant, index) => (
|
] as const;
|
||||||
|
const linkVariants = ['link', 'link-emphasized'] as const;
|
||||||
|
|
||||||
|
export const renderButtons = () => {
|
||||||
|
return buttonVariants.map((variant, index) => (
|
||||||
<div className="flex gap-5 flex-wrap" key={index}>
|
<div className="flex gap-5 flex-wrap" key={index}>
|
||||||
{['lg', 'md', 'sm', 'xs', 'disabled'].map((size) => (
|
{buttonSizes.map((size) => (
|
||||||
|
<Button
|
||||||
|
leftIcon={<PlusIcon />}
|
||||||
|
rightIcon={<PlusIcon />}
|
||||||
|
variant={variant as ButtonTheme['variant']}
|
||||||
|
size={size as ButtonTheme['size']}
|
||||||
|
key={`${variant}-${size}`}
|
||||||
|
>
|
||||||
|
Button
|
||||||
|
</Button>
|
||||||
|
))}
|
||||||
|
</div>
|
||||||
|
));
|
||||||
|
};
|
||||||
|
|
||||||
|
export const renderButtonIcons = () => {
|
||||||
|
return iconOnlyVariants.map((variant, index) => (
|
||||||
|
<div className="flex gap-5 flex-wrap" key={index}>
|
||||||
|
{buttonSizes.map((size) => (
|
||||||
<Button
|
<Button
|
||||||
iconOnly
|
iconOnly
|
||||||
variant={variant as ButtonTheme['variant']}
|
variant={variant as ButtonTheme['variant']}
|
||||||
size={size !== 'disabled' ? (size as ButtonTheme['size']) : 'md'}
|
size={size as ButtonTheme['size']}
|
||||||
key={`${variant}-${size}`}
|
key={`${variant}-${size}`}
|
||||||
disabled={size === 'disabled'}
|
|
||||||
>
|
>
|
||||||
<PlusIcon />
|
<PlusIcon />
|
||||||
</Button>
|
</Button>
|
||||||
@ -49,17 +50,38 @@ export const renderButtonIcons = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const renderLinks = () => {
|
export const renderLinks = () => {
|
||||||
return ['link', 'link-emphasized', 'disabled'].map((variant) => (
|
return linkVariants.map((variant) => (
|
||||||
<Button
|
<Button
|
||||||
variant={
|
variant={variant}
|
||||||
variant !== 'disabled' ? (variant as ButtonTheme['variant']) : 'link'
|
|
||||||
}
|
|
||||||
key={variant}
|
key={variant}
|
||||||
leftIcon={<PlusIcon />}
|
leftIcon={<PlusIcon />}
|
||||||
rightIcon={<PlusIcon />}
|
rightIcon={<PlusIcon />}
|
||||||
disabled={variant === 'disabled'}
|
|
||||||
>
|
>
|
||||||
Link
|
Link
|
||||||
</Button>
|
</Button>
|
||||||
));
|
));
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const renderDisabledButtons = () => {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{/* Button variants */}
|
||||||
|
<Button leftIcon={<PlusIcon />} rightIcon={<PlusIcon />} disabled>
|
||||||
|
Button
|
||||||
|
</Button>
|
||||||
|
{/* Icon only variants */}
|
||||||
|
<Button iconOnly disabled>
|
||||||
|
<PlusIcon />
|
||||||
|
</Button>
|
||||||
|
{/* Link variantws */}
|
||||||
|
<Button
|
||||||
|
variant="link"
|
||||||
|
disabled
|
||||||
|
leftIcon={<PlusIcon />}
|
||||||
|
rightIcon={<PlusIcon />}
|
||||||
|
>
|
||||||
|
Link
|
||||||
|
</Button>
|
||||||
|
</>
|
||||||
|
);
|
||||||
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user