Skip to content

Commit

Permalink
Fix dropdown indicator size, allow left alignment of button label
Browse files Browse the repository at this point in the history
  • Loading branch information
calebjacob committed Jan 29, 2025
1 parent 7718eb8 commit 8e8b560
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@near-pagoda/ui",
"version": "3.1.2",
"version": "3.1.3",
"description": "A React component library that implements the official NEAR design system.",
"license": "MIT",
"repository": {
Expand Down
10 changes: 10 additions & 0 deletions src/components/Button.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -236,6 +236,16 @@
}
}
}

&[data-label-alignment='left'] {
.inner {
flex-grow: 1;
}
.label {
flex-grow: 1;
text-align: left;
}
}
}

.inner {
Expand Down
3 changes: 3 additions & 0 deletions src/components/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ type Props = Omit<ComponentPropsWithRef<'button'>, 'size'> & {
iconLeft?: ReactElement;
iconRight?: ReactElement;
label: string;
labelAlignment?: 'center' | 'left';
loading?: boolean;
size?: Size;
variant?: Variant;
Expand All @@ -35,6 +36,7 @@ export const Button = forwardRef<HTMLButtonElement, Props>(
iconLeft,
iconRight,
label,
labelAlignment,
loading,
size = 'default',
type = 'button',
Expand Down Expand Up @@ -67,6 +69,7 @@ export const Button = forwardRef<HTMLButtonElement, Props>(
data-loading={loading}
data-size={size}
data-variant={variant}
data-label-alignment={labelAlignment}
ref={ref}
{...conditionalAttributes}
{...forwardedProps}
Expand Down
2 changes: 1 addition & 1 deletion src/components/Dropdown/Dropdown.README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { Button, Dropdown, SvgIcon } from '~/components/lib/Dropdown';

<Dropdown.Root>
<Dropdown.Trigger asChild>
<Button label="My Dropdown" iconRight={<Dropdown.Indicator />} />
<Button label="My Dropdown" labelAlignment="left" iconRight={<Dropdown.Indicator />} />
</Dropdown.Trigger>

<Dropdown.Content>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Dropdown/Dropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export const Item = forwardRef<
Item.displayName = 'Item';

export const Indicator = () => {
return <SvgIcon icon={<CaretDown weight="bold" />} className={s.indicator} />;
return <SvgIcon icon={<CaretDown weight="bold" />} className={s.indicator} size="stretch" />;
};

export const Section = ({ children }: { children: ReactNode }) => {
Expand Down
5 changes: 5 additions & 0 deletions src/components/ImageIcon.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@
height: var(--icon-size-xl);
padding: 8px;
}
&[data-size='stretch'] {
width: 100%;
height: 100%;
padding: 8px;
}

&[data-parent-clickable='true'] {
a:focus-visible &,
Expand Down
4 changes: 4 additions & 0 deletions src/components/SvgIcon.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,8 @@
width: var(--icon-size-xl);
height: var(--icon-size-xl);
}
&[data-size='stretch'] {
width: 100%;
height: 100%;
}
}
2 changes: 1 addition & 1 deletion src/utils/theme.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export type ThemeInputVariant = 'default' | 'success' | 'error';
export type ThemeIconSize = '2xs' | 'xs' | 's' | 'm' | 'l' | 'xl';
export type ThemeIconSize = '2xs' | 'xs' | 's' | 'm' | 'l' | 'xl' | 'stretch';
export type ThemeGap = 'none' | 'xs' | 's' | 'm' | 'l' | 'xl' | '2xl' | '3xl';

export type ThemeBreakpointProps<T> = T & {
Expand Down

0 comments on commit 8e8b560

Please sign in to comment.