mirror of
https://github.com/snowball-tools/snowballtools-base.git
synced 2024-12-22 20:47:44 +00:00
♻️ 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';
|
||||||
|
|
||||||
|
const buttonVariants = ['primary', 'secondary', 'tertiary', 'danger'] as const;
|
||||||
|
const buttonSizes = ['lg', 'md', 'sm', 'xs'] as const;
|
||||||
|
const iconOnlyVariants = [
|
||||||
|
'primary',
|
||||||
|
'secondary',
|
||||||
|
'tertiary',
|
||||||
|
'ghost',
|
||||||
|
'danger',
|
||||||
|
'danger-ghost',
|
||||||
|
] as const;
|
||||||
|
const linkVariants = ['link', 'link-emphasized'] as const;
|
||||||
|
|
||||||
export const renderButtons = () => {
|
export const renderButtons = () => {
|
||||||
return ['primary', 'secondary', 'tertiary', 'danger'].map(
|
return buttonVariants.map((variant, index) => (
|
||||||
(variant, index) => (
|
<div className="flex gap-5 flex-wrap" key={index}>
|
||||||
<div className="flex gap-5 flex-wrap" key={index}>
|
{buttonSizes.map((size) => (
|
||||||
{['lg', 'md', 'sm', 'xs', 'disabled'].map((size) => (
|
<Button
|
||||||
<Button
|
leftIcon={<PlusIcon />}
|
||||||
leftIcon={<PlusIcon />}
|
rightIcon={<PlusIcon />}
|
||||||
rightIcon={<PlusIcon />}
|
variant={variant as ButtonTheme['variant']}
|
||||||
variant={variant as ButtonTheme['variant']}
|
size={size as ButtonTheme['size']}
|
||||||
size={size !== 'disabled' ? (size as ButtonTheme['size']) : 'md'}
|
key={`${variant}-${size}`}
|
||||||
key={`${variant}-${size}`}
|
>
|
||||||
disabled={size === 'disabled'}
|
Button
|
||||||
>
|
</Button>
|
||||||
Button
|
))}
|
||||||
</Button>
|
</div>
|
||||||
))}
|
));
|
||||||
</div>
|
|
||||||
),
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export const renderButtonIcons = () => {
|
export const renderButtonIcons = () => {
|
||||||
return [
|
return iconOnlyVariants.map((variant, index) => (
|
||||||
'primary',
|
|
||||||
'secondary',
|
|
||||||
'tertiary',
|
|
||||||
'ghost',
|
|
||||||
'danger',
|
|
||||||
'danger-ghost',
|
|
||||||
].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
|
<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