Skip to content

Commit

Permalink
feat: Allow small text for unordered lists (#1217)
Browse files Browse the repository at this point in the history
Co-authored-by: Vincent Smedinga <[email protected]>
  • Loading branch information
alimpens and VincentSmedinga authored May 7, 2024
1 parent 5778cb7 commit 5012851
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@
color: var(--ams-unordered-list-inverse-color);
}

.ams-unordered-list--small:not(.ams-unordered-list--no-markers) {
font-size: var(--ams-unordered-list-small-font-size);
line-height: var(--ams-unordered-list-small-line-height);
}

/** A nested list has a different marker and less indentation for correct alignment. */
:is(.ams-ordered-list, .ams-unordered-list) .ams-unordered-list {
list-style-type: var(--ams-unordered-list-unordered-list-list-style-type);
Expand Down
5 changes: 4 additions & 1 deletion packages/react/src/UnorderedList/UnorderedList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ export type UnorderedListProps = {
/** Changes the text color for readability on a dark background. */
inverseColor?: boolean
markers?: boolean
/** The size of the unordered list. */
size?: 'small'
} & PropsWithChildren<HTMLAttributes<HTMLUListElement>>

const UnorderedListRoot = forwardRef(
(
{ children, className, inverseColor, markers = true, ...restProps }: UnorderedListProps,
{ children, className, inverseColor, markers = true, size, ...restProps }: UnorderedListProps,
ref: ForwardedRef<HTMLUListElement>,
) => {
return (
Expand All @@ -26,6 +28,7 @@ const UnorderedListRoot = forwardRef(
'ams-unordered-list',
inverseColor && 'ams-unordered-list--inverse-color',
!markers && 'ams-unordered-list--no-markers',
size && `ams-unordered-list--${size}`,
className,
)}
{...restProps}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@
"comment": "The total level >=2 indentation for Amsterdam is 28 pixels, or 1.75rem."
}
}
},
"small": {
"font-size": { "value": "{ams.text.level.6.font-size}" },
"line-height": { "value": "{ams.text.level.6.line-height}" }
}
}
}
Expand Down
6 changes: 6 additions & 0 deletions storybook/src/components/UnorderedList/UnorderedList.docs.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -46,3 +46,9 @@ This ensures the colour of the text provides enough contrast.
When nesting lists, set the prop on all lists.

<Canvas of={UnorderedListStories.InverseColor} />

### Small

Use a list with a smaller font size in form descriptions and captions and the like.

<Canvas of={UnorderedListStories.Small} />
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,9 @@ export const InverseColor: Story = {
</UnorderedList>
),
}

export const Small: Story = {
args: {
size: 'small',
},
}

0 comments on commit 5012851

Please sign in to comment.