From 12a9d992f341053b49382a5552c26dd2b5f60131 Mon Sep 17 00:00:00 2001 From: Vio Date: Sat, 17 Feb 2024 15:10:55 +0100 Subject: [PATCH 1/3] refactor(ui): Dropdown - use Button --- packages/ui/src/ui/dropdown/dropdown.jsx | 16 +++++------ .../ui/src/ui/dropdown/dropdown.module.css | 27 +------------------ 2 files changed, 9 insertions(+), 34 deletions(-) diff --git a/packages/ui/src/ui/dropdown/dropdown.jsx b/packages/ui/src/ui/dropdown/dropdown.jsx index 4270d6b271..86f566a6f5 100644 --- a/packages/ui/src/ui/dropdown/dropdown.jsx +++ b/packages/ui/src/ui/dropdown/dropdown.jsx @@ -3,8 +3,7 @@ import PropTypes from 'prop-types'; import cx from 'classnames'; import { Menu, MenuButton, MenuItem, useMenuState } from 'ariakit/menu'; -import { FlexStack } from '../../layout/flex-stack'; -import { Icon } from '../icon'; +import { Button, BUTTON_SIZE } from '../button'; import css from './dropdown.module.css'; const Item = ({ className = '', isActive = false, ...restProps }) => ( @@ -29,15 +28,16 @@ export const Dropdown = (props) => { return (
- - {glyph && } - {label && {label}} - + {label} {typeof children === 'function' diff --git a/packages/ui/src/ui/dropdown/dropdown.module.css b/packages/ui/src/ui/dropdown/dropdown.module.css index 0c5cb971fa..1a4db4bd20 100644 --- a/packages/ui/src/ui/dropdown/dropdown.module.css +++ b/packages/ui/src/ui/dropdown/dropdown.module.css @@ -1,31 +1,5 @@ -.root { - display: inline-block; -} - .button { - background: none; - border: none; - padding: 0; - - border: 1px solid var(--color-outline); - border-radius: var(--radius-small); - padding: calc(var(--space-xxsmall) - 1px); - - appearance: none; - background: none; - font-size: var(--size-small); - line-height: var(--space-small); white-space: nowrap; - color: var(--color-text-light); -} - -.button[aria-expanded=true], -.button:hover, -.button:focus, -.button:active { - outline: none; - box-shadow: var(--outline-hover); - color: var(--color-text); } .button[disabled] { @@ -62,6 +36,7 @@ font-size: var(--size-small); line-height: inherit; text-decoration: none; + cursor: default; } .item[data-active-item], From 37c32e2e695ab75931d959c3f56f01f503232dbc Mon Sep 17 00:00:00 2001 From: Vio Date: Sat, 17 Feb 2024 15:11:18 +0100 Subject: [PATCH 2/3] fix(ui): Button - correct small variation layout --- packages/ui/src/ui/button/button.module.css | 4 +- packages/ui/src/ui/button/button.stories.tsx | 46 ++++++++++---------- packages/ui/src/ui/button/button.tsx | 13 +++--- 3 files changed, 30 insertions(+), 33 deletions(-) diff --git a/packages/ui/src/ui/button/button.module.css b/packages/ui/src/ui/button/button.module.css index c66d182b50..683fefbf27 100644 --- a/packages/ui/src/ui/button/button.module.css +++ b/packages/ui/src/ui/button/button.module.css @@ -250,14 +250,12 @@ a.root { .small { font-size: var(--size-small); gap: var(--space-xxxsmall); - line-height: var(--space-xsmall); + line-height: var(--space-small); } .small .glyph { width: calc(var(--space-xsmall) + 2px); height: calc(var(--space-xsmall) + 2px); - margin-top: -1px; - margin-bottom: -1px; } .medium { diff --git a/packages/ui/src/ui/button/button.stories.tsx b/packages/ui/src/ui/button/button.stories.tsx index 9303666e54..6923fb85e0 100644 --- a/packages/ui/src/ui/button/button.stories.tsx +++ b/packages/ui/src/ui/button/button.stories.tsx @@ -4,7 +4,7 @@ import { Meta, Story } from '@storybook/react'; import { Stack } from '../../layout/stack'; import { FlexStack } from '../../layout/flex-stack'; import { Icon } from '../icon'; -import { Button } from '.'; +import { Button, BUTTON_SIZE, BUTTON_KIND } from '.'; export default { title: 'UI/Button', @@ -26,7 +26,7 @@ export const All = () => (

Size

- {Object.values(Button.SIZE).map((size) => ( + {Object.values(BUTTON_SIZE).map((size) => ( @@ -37,7 +37,7 @@ export const All = () => (

Kind

- {Object.values(Button.KIND).map((kind) => ( + {Object.values(BUTTON_KIND).map((kind) => ( @@ -45,7 +45,7 @@ export const All = () => (

Active

- {Object.values(Button.KIND).map((kind) => ( + {Object.values(BUTTON_KIND).map((kind) => ( @@ -53,7 +53,7 @@ export const All = () => (

As link

- {Object.values(Button.KIND).map((kind) => ( + {Object.values(BUTTON_KIND).map((kind) => ( @@ -61,7 +61,7 @@ export const All = () => (

With icon

- {Object.values(Button.KIND).map((kind) => ( + {Object.values(BUTTON_KIND).map((kind) => ( @@ -69,7 +69,7 @@ export const All = () => (

Disabled

- {Object.values(Button.KIND).map((kind) => ( + {Object.values(BUTTON_KIND).map((kind) => ( @@ -80,12 +80,12 @@ export const All = () => (

Outline & Kind

- {Object.values(Button.SIZE).map((size) => ( + {Object.values(BUTTON_SIZE).map((size) => ( - {Object.values(Button.KIND).map((kind) => ( + {Object.values(BUTTON_KIND).map((kind) => ( @@ -97,19 +97,19 @@ export const All = () => ( - {Object.values(Button.KIND).map((kind) => ( + {Object.values(BUTTON_KIND).map((kind) => ( ))}

With icon

- {Object.values(Button.SIZE).map((size) => ( + {Object.values(BUTTON_SIZE).map((size) => ( - {Object.values(Button.KIND).map((kind) => ( + {Object.values(BUTTON_KIND).map((kind) => ( - {Object.values(Button.KIND).map((kind) => ( + {Object.values(BUTTON_KIND).map((kind) => ( @@ -153,12 +153,12 @@ export const All = () => (

Solid & Kind

- {Object.values(Button.SIZE).map((size) => ( + {Object.values(BUTTON_SIZE).map((size) => ( - {Object.values(Button.KIND).map((kind) => ( + {Object.values(BUTTON_KIND).map((kind) => ( @@ -170,19 +170,19 @@ export const All = () => ( - {Object.values(Button.KIND).map((kind) => ( + {Object.values(BUTTON_KIND).map((kind) => ( ))}

With icon

- {Object.values(Button.SIZE).map((size) => ( + {Object.values(BUTTON_SIZE).map((size) => ( - {Object.values(Button.KIND).map((kind) => ( + {Object.values(BUTTON_KIND).map((kind) => ( - {Object.values(Button.KIND).map((kind) => ( + {Object.values(BUTTON_KIND).map((kind) => ( diff --git a/packages/ui/src/ui/button/button.tsx b/packages/ui/src/ui/button/button.tsx index 250a3f9102..d8a6146bf7 100644 --- a/packages/ui/src/ui/button/button.tsx +++ b/packages/ui/src/ui/button/button.tsx @@ -5,13 +5,13 @@ import { Button as ButtonBaseComponent } from 'ariakit/button'; import { Icon as BaseIcon } from '../icon'; import css from './button.module.css'; -const SIZE = { +export const BUTTON_SIZE = { SMALL: 'small', MEDIUM: 'medium', LARGE: 'large', } as const; -const KIND = { +export const BUTTON_KIND = { PRIMARY: 'primary', SECONDARY: 'secondary', DANGE: 'danger', @@ -20,8 +20,8 @@ const KIND = { SUCCES: 'success', } as const; -type Size = (typeof SIZE)[keyof typeof SIZE]; -type Kind = (typeof KIND)[keyof typeof KIND]; +type Size = (typeof BUTTON_SIZE)[keyof typeof BUTTON_SIZE]; +type Kind = (typeof BUTTON_KIND)[keyof typeof BUTTON_KIND]; interface ButtonProps { outline?: boolean; @@ -37,7 +37,7 @@ interface ButtonProps { rightGlyph?: React.ComponentProps['glyph']; } -export const Button = ( +const ButtonComponent = ( props: ButtonProps & Omit, keyof ButtonProps>, ) => { const { @@ -92,5 +92,4 @@ export const Button = ( ); }; -Button.SIZE = SIZE; -Button.KIND = KIND; +export const Button = React.forwardRef(ButtonComponent); From 28edfdf1e9c6bc9bea500571dc5b241a71702000 Mon Sep 17 00:00:00 2001 From: Vio Date: Sat, 17 Feb 2024 15:13:13 +0100 Subject: [PATCH 3/3] fix(ui): Filters - adjust line-height for only button --- packages/ui/src/ui/filters/filters.module.css | 1 + 1 file changed, 1 insertion(+) diff --git a/packages/ui/src/ui/filters/filters.module.css b/packages/ui/src/ui/filters/filters.module.css index f741eb1bd9..c578e4487a 100644 --- a/packages/ui/src/ui/filters/filters.module.css +++ b/packages/ui/src/ui/filters/filters.module.css @@ -33,6 +33,7 @@ transform: translateY(-50%); padding: var(--space-xxxsmall); font-size: var(--size-xsmall); + line-height: 1.1; } /** cover item text */