Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better style of the basic components #681

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions packages/ui/Badge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ interface Props {
}

export const Badge: FC<Props> = ({ icon, children, onClick }) => {
const clickable = onClick != null;
return (
<div
role={clickable ? 'button' : undefined}
onClick={onClick}
className={clsx(
'Badge bg-surface-100 border-surface-300 inline-flex gap-1 rounded-lg border px-1 py-0.5 text-sm',
onClick != null ? 'hover:bg-surface-50 hover:border-surface-500 cursor-pointer select-none' : '',
'Badge bg-badge-bg border-badge-border inline-flex gap-1 rounded-sm border px-1 py-0.5 text-xs',
clickable && 'hover:bg-badge-hover cursor-pointer select-none active:translate-y-px',
)}
>
{icon}
Expand Down
16 changes: 12 additions & 4 deletions packages/ui/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,29 +18,37 @@ export const Button = React.forwardRef<HTMLButtonElement, ButtonProps>(function
return (
<button
className={clsx(
'enabled:cursor-pointer disabled:cursor-not-allowed',
'Button enabled:cursor-pointer disabled:cursor-not-allowed',
'select-none appearance-none focus-visible:outline-none',
'inline-flex items-center justify-center focus:ring',
'inline-flex items-center justify-center',
'm-0 gap-1 rounded-sm',
'active-enabled:shadow-none active-enabled:translate-y-px border shadow-sm',

small ? 'min-h-[1.75rem] px-[0.75rem] py-0.5 text-sm' : 'px-4 py-2 text-base',
(variant === 'default' || variant === 'detail') && [
'bg-button-default-bg text-button-default-text',
'hover:enabled:bg-button-default-hover-bg active-enabled:bg-button-default-active-bg',
'disabled:text-button-default-disabled-text disabled:bg-button-default-disabled-bg',
'border-button-default-border',
],
variant === 'danger' && [
'bg-button-danger-bg text-button-danger-text hover:enabled:bg-button-danger-hover-bg',
'active-enabled:bg-button-danger-active-bg border-button-danger-border',
],
variant === 'danger' &&
'bg-button-danger-bg text-button-danger-text hover:enabled:bg-button-danger-hover-bg active-enabled:bg-button-danger-active-bg',

variant === 'primary' && [
'bg-button-primary-bg text-button-primary-text',
'hover:enabled:bg-button-primary-hover-bg active-enabled:bg-button-primary-active-bg',
'disabled:bg-button-primary-disabled-bg disabled:text-button-primary-text',
'border-button-primary-border',
],
variant === 'switch' && [
'bg-button-switch-bg text-button-switch-text',
'hover:enabled:bg-button-switch-hover-bg active-enabled:bg-button-switch-active-bg',
'border-r-1 border-r-button-switch-off-hint',
'on:border-r-button-switch-on-hint on:bg-button-switch-on-bg on:hover:enabled:to-button-switch-bg',
'disabled:text-button-switch-disabled-text disabled:bg-button-switch-disabled-bg',
'border-button-switch-border-border',
],
className,
)}
Expand Down
4 changes: 2 additions & 2 deletions packages/ui/ButtonInline.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ export const ButtonInline = React.forwardRef<HTMLButtonElement, ButtonInlineProp
<button
className={clsx(
className,
'bg-button-inline-bg inline-block -translate-y-[1px] rounded px-[0.5em] transition-shadow duration-100 active:translate-y-0',
'shadow-button-inline-border/50 active:shadow-button-inline-border/25 shadow-[0_2px_0_0] active:shadow-[0_0px_0_1px]',
'ButtonInline bg-button-inline-bg inline-block -translate-y-[1px] rounded-sm px-[0.3em] transition-shadow duration-100 active:translate-y-0',
'shadow-[0_0_0_1px_rgba(0,0,0,0.2),0_2px_0_0_rgba(0,0,0,0.06)] active:shadow-[0_0_0_1px_rgba(0,0,0,1)]',
)}
ref={ref}
{...props}
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/TooltipBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const TooltipBox = forwardRef<HTMLDivElement, Props>(
ref={ref}
className={
defaultStyle
? 'TooltipBox bg-tooltip-bg text-tooltip-text shadow-tooltip-shadow/50 rounded-sm px-2 py-1 text-sm shadow-[1px_2px_0_0]'
? 'TooltipBox border-tooltip-border bg-tooltip-bg text-tooltip-text shadow-tooltip-shadow/50 rounded-sm border px-2 py-1 text-sm shadow-[3px_4px_0_0]'
: className
}
{...props}
Expand Down
7 changes: 7 additions & 0 deletions packages/ui/stories/base/Badge.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,10 @@ export const Basic: Story = {
children: 'New',
},
};

export const Clickable: Story = {
args: {
children: 'New',
onClick: () => alert('clicked'),
},
};
4 changes: 3 additions & 1 deletion packages/ui/stories/base/Button.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,9 @@ export default meta;
type Story = StoryObj<typeof Button>;

export const Basic: Story = {
args: {},
args: {
disabled: false,
},
};

export const Small: Story = {
Expand Down
49 changes: 29 additions & 20 deletions packages/ui/tailwind.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ const makeTheme = (name: 'dark' | 'light'): Config['theme'] => {
system: $(themeColor.light, themeColor.dark),
},
kbd: {
bg: $(white, neutral[700]),
bg: $(white, neutral[800]),
text: $(black, white),
shadow: $(neutral[200], neutral[800]),
shadow: $(neutral[400], neutral[900]),
},
brand,
green: $(green, revert(green)),
Expand All @@ -72,8 +72,14 @@ const makeTheme = (name: 'dark' | 'light'): Config['theme'] => {
dot: {
normal: blue[600],
},
badge: {
bg: $(neutral[50], neutral[700]),
hover: $(neutral[100], neutral[600]),
border: $(neutral[500], black),
},
tooltip: {
bg: $(black, neutral[600]),
bg: $(neutral[600], neutral[600]),
border: black,
text: white,
shadow: $(neutral[500], black),
},
Expand All @@ -91,14 +97,14 @@ const makeTheme = (name: 'dark' | 'light'): Config['theme'] => {
active: $(blue[500], blue[200]),
decoration: $(blue[400], blue[800]),
},
bg: $(neutral[50], neutral[800]),
bg: $(neutral[50], neutral[700]),
floating: {
bg: $(neutral[50], neutral[900]),
},
card: {
bg: $(white, neutral[900]),
border: $(neutral[200], neutral[800]),
shadow: $(neutral[100], neutral[900]),
bg: $(white, neutral[800]),
border: $(neutral[200], neutral[500]),
shadow: $(neutral[100], black),
},
errors: {
bg: $(red[50], red[900]),
Expand Down Expand Up @@ -186,10 +192,10 @@ const makeTheme = (name: 'dark' | 'light'): Config['theme'] => {
other: $(neutral[300], neutral[600]),
},
select: {
bg: $(neutral[50], neutral[700]),
border: $(neutral[100], neutral[700]),
bg: $(neutral[100], neutral[600]),
border: $(neutral[300], neutral[500]),
hover: {
border: $(neutral[200], neutral[600]),
border: $(neutral[500], neutral[400]),
},
open: {
border: $(lime[500], blue[500]),
Expand Down Expand Up @@ -381,7 +387,6 @@ const makeTheme = (name: 'dark' | 'light'): Config['theme'] => {
button: {
inline: {
bg: $(neutral[100], neutral[600]),
border: $(black, black),
},
light: {
hover: {
Expand All @@ -392,46 +397,50 @@ const makeTheme = (name: 'dark' | 'light'): Config['theme'] => {
},
},
default: {
bg: $(neutral[100], neutral[700]),
bg: $(neutral[50], neutral[600]),
text: $(black, white),
border: $(neutral[300], black),
hover: {
bg: $(neutral[200], neutral[700]),
bg: $(neutral[100], mix(neutral[500], neutral[600], 0.5)),
},
active: {
bg: $(neutral[300], neutral[600]),
bg: $(neutral[200], neutral[600]),
},
disabled: {
bg: $(neutral[400], neutral[500]),
text: $(neutral[600], neutral[400]),
},
},
danger: {
bg: $(red[600], red[500]),
text: $(white, black),
bg: $(red[500], red[500]),
text: $(white, white),
hover: {
bg: $(red[500], red[400]),
},
border: $(red[700], red[900]),
active: {
bg: $(red[400], red[300]),
},
},
primary: {
bg: brand[600],
bg: $(brand[600], brand[500]),
text: white,
hover: {
bg: brand[700],
bg: $(brand[500], brand[600]),
},
border: $(brand[700], brand[600]),
active: {
bg: brand[700],
bg: $(brand[700], brand[400]),
},
disabled: {
bg: brand[700],
bg: $(neutral[600], neutral[500]),
text: neutral[300],
},
},
switch: {
bg: $(neutral[100], neutral[700]),
text: $(black, white),
border: $(neutral[300], black),
on: {
hint: brand[400],
bg: $(neutral[300], neutral[600]),
Expand Down
Loading