ui(button): s/isDisabled/disabled

pull/305/head
Yangshun Tay 2 years ago
parent 6e5ffb3c77
commit 0a3fb2503d

2
.gitignore vendored

@ -18,3 +18,5 @@ public/dist
!.yarn/releases !.yarn/releases
!.yarn/sdks !.yarn/sdks
!.yarn/versions !.yarn/versions
tsconfig.tsbuildinfo

@ -6,10 +6,9 @@ import type {
ButtonDisplay, ButtonDisplay,
ButtonSize, ButtonSize,
ButtonType, ButtonType,
ButtonVariant} from '@tih/ui'; ButtonVariant,
import {
Button
} from '@tih/ui'; } from '@tih/ui';
import { Button } from '@tih/ui';
const buttonTypes: ReadonlyArray<ButtonType> = ['button', 'reset', 'submit']; const buttonTypes: ReadonlyArray<ButtonType> = ['button', 'reset', 'submit'];
const buttonSizes: ReadonlyArray<ButtonSize> = ['sm', 'md', 'lg']; const buttonSizes: ReadonlyArray<ButtonSize> = ['sm', 'md', 'lg'];
@ -32,13 +31,13 @@ export default {
control: { type: 'select' }, control: { type: 'select' },
options: buttonAddOnPositions, options: buttonAddOnPositions,
}, },
disabled: {
control: 'boolean',
},
display: { display: {
control: { type: 'select' }, control: { type: 'select' },
options: buttonDisplays, options: buttonDisplays,
}, },
isDisabled: {
control: 'boolean',
},
isLoading: { isLoading: {
control: 'boolean', control: 'boolean',
}, },
@ -112,7 +111,7 @@ export function Disabled() {
{buttonVariants.map((variant) => ( {buttonVariants.map((variant) => (
<Button <Button
key={variant} key={variant}
isDisabled={true} disabled={true}
label="Click Me" label="Click Me"
size="md" size="md"
variant={variant} variant={variant}
@ -140,7 +139,7 @@ export function Loading() {
{buttonVariants.map((variant) => ( {buttonVariants.map((variant) => (
<Button <Button
key={variant} key={variant}
isDisabled={true} disabled={true}
isLoading={true} isLoading={true}
label="Click Me" label="Click Me"
size="md" size="md"
@ -166,8 +165,8 @@ export function Icons() {
/> />
))} ))}
<Button <Button
disabled={true}
icon={EnvelopeIcon} icon={EnvelopeIcon}
isDisabled={true}
label="Click Me" label="Click Me"
size="lg" size="lg"
variant="primary" variant="primary"
@ -186,8 +185,8 @@ export function Icons() {
))} ))}
<Button <Button
addonPosition="start" addonPosition="start"
disabled={true}
icon={EnvelopeIcon} icon={EnvelopeIcon}
isDisabled={true}
label="Click Me" label="Click Me"
size="lg" size="lg"
variant="primary" variant="primary"
@ -205,9 +204,9 @@ export function Icons() {
/> />
))} ))}
<Button <Button
disabled={true}
display="block" display="block"
icon={EnvelopeIcon} icon={EnvelopeIcon}
isDisabled={true}
label="Click Me" label="Click Me"
size="lg" size="lg"
variant="primary" variant="primary"
@ -231,8 +230,8 @@ export function HiddenLabel() {
/> />
))} ))}
<Button <Button
disabled={true}
icon={EnvelopeIcon} icon={EnvelopeIcon}
isDisabled={true}
isLabelHidden={true} isLabelHidden={true}
label="Click Me" label="Click Me"
size="lg" size="lg"

File diff suppressed because one or more lines are too long

@ -19,10 +19,10 @@ type Props = Readonly<{
addonPosition?: ButtonAddOnPosition; addonPosition?: ButtonAddOnPosition;
'aria-controls'?: string; 'aria-controls'?: string;
className?: string; className?: string;
disabled?: boolean;
display?: ButtonDisplay; display?: ButtonDisplay;
href?: UrlObject | string; href?: UrlObject | string;
icon?: (props: React.ComponentProps<'svg'>) => JSX.Element; icon?: (props: React.ComponentProps<'svg'>) => JSX.Element;
isDisabled?: boolean;
isLabelHidden?: boolean; isLabelHidden?: boolean;
isLoading?: boolean; isLoading?: boolean;
label: string; label: string;
@ -92,7 +92,7 @@ export default function Button({
display = 'inline', display = 'inline',
href, href,
icon: Icon, icon: Icon,
isDisabled = false, disabled = false,
isLabelHidden = false, isLabelHidden = false,
isLoading = false, isLoading = false,
label, label,
@ -133,13 +133,13 @@ export default function Button({
className: clsx( className: clsx(
display === 'block' ? 'flex w-full justify-center' : 'inline-flex', display === 'block' ? 'flex w-full justify-center' : 'inline-flex',
'whitespace-nowrap items-center border font-medium focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary-500', 'whitespace-nowrap items-center border font-medium focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-primary-500',
isDisabled ? variantDisabledClasses[variant] : variantClasses[variant], disabled ? variantDisabledClasses[variant] : variantClasses[variant],
isDisabled && 'pointer-events-none', disabled && 'pointer-events-none',
isLabelHidden ? iconOnlySizeClasses[size] : sizeClasses[size], isLabelHidden ? iconOnlySizeClasses[size] : sizeClasses[size],
baseClasses[size], baseClasses[size],
className, className,
), ),
disabled: isDisabled, disabled,
onClick, onClick,
}; };

Loading…
Cancel
Save