Skip to content
Merged
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
8 changes: 8 additions & 0 deletions .changeset/nice-lies-share.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
"@ultraviolet/ui": patch
---

`TagList`: overflow can dynamically adapt to the container width.

⚠️ Note that this may break some existing tests (a visually hidden div containing the tags is added and not removed). A data-testid has been added to help prevent test failures.

7 changes: 7 additions & 0 deletions packages/ui/src/components/Popup/styles.css.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import { theme } from '@ultraviolet/themes'
import { keyframes, styleVariants } from '@vanilla-extract/css'
import { recipe } from '@vanilla-extract/recipes'

import { tagListStyle } from '../TagList/styles.css'

import { DEFAULT_ARROW_WIDTH } from './helpers'
import {
animationDurationPopup,
Expand Down Expand Up @@ -112,6 +114,11 @@ const animation = styleVariants({
const childrenContainer = recipe({
base: {
display: 'inherit',
selectors: {
[`${tagListStyle.ellipsisChild} > &`]: {
minWidth: 0,
},
},
},
variants: {
fullHeight: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,23 +1,47 @@
import { useState } from 'react'

import { TagList } from '..'
import { Slider } from '../../Slider'
import { Stack } from '../../Stack'

import type { StoryFn } from '@storybook/react-vite'

export const ParentWithDefinedWidth: StoryFn<typeof TagList> = args => (
<Stack gap={2}>
<div style={{ border: '1px solid gray', padding: '10px', width: '250px' }}>
<TagList {...args} />
</div>

<div style={{ border: '1px solid gray', padding: '10px', width: '100px' }}>
<TagList {...args} />
</div>

<div style={{ border: '1px solid gray', padding: '10px', width: '100px' }}>
<TagList {...args} tags={['Looooooooooooong']} />
</div>
</Stack>
)
export const ParentWithDefinedWidth: StoryFn<typeof TagList> = args => {
const [width, setWidth] = useState(298)

return (
<Stack gap={2}>
<Slider
label="Change container width"
max={500}
min={2}
onChange={setWidth}
value={width}
/>
<div
style={{
border: '1px solid gray',
padding: '10px',
width: `${width}px`,
}}
>
<TagList {...args} />
</div>

<div
style={{ border: '1px solid gray', padding: '10px', width: '100px' }}
>
<TagList {...args} />
</div>

<div
style={{ border: '1px solid gray', padding: '10px', width: '100px' }}
>
<TagList {...args} tags={['Looooooooooooong']} />
</div>
</Stack>
)
}

ParentWithDefinedWidth.parameters = {
docs: {
Expand Down
Loading
Loading