-
Notifications
You must be signed in to change notification settings - Fork 639
Add truncation features to the LabelGroup component #3264
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
Merged
Merged
Changes from all commits
Commits
Show all changes
46 commits
Select commit
Hold shift + click to select a range
5bcd432
adds props to LabelGroup to support truncation
mperrotti 4338301
adds tests and gets IntersectionObserver re-rendering with correct bt…
mperrotti 0d9f6ea
fixes bug where expand button width was not being accounted for in th…
mperrotti 2a53152
writes tests, fixes bugs, updates stories to use Label children
mperrotti 6f618e1
fixes type errors and removes code copied from primer/behaviors
mperrotti e10de4b
code cleanup
mperrotti 7eb79fd
Merge branch 'main' into mp/labelgroup-truncation
mperrotti 51d3b7e
Update generated/components.json
mperrotti 05f1a4f
Create blue-dragons-marry.md
mperrotti fa6d686
fixes typos
mperrotti fb35767
Merge branch 'mp/labelgroup-truncation' of github.com:primer/react in…
mperrotti 012d4e2
Merge branch 'main' of github.com:primer/react into mp/labelgroup-tru…
mperrotti f5ec9a2
tests focus mgmt when expanding inline interactive tokens
mperrotti 9c04f80
fixes lint errors and overlay sizing issues
mperrotti d62b112
Merge branch 'main' into mp/labelgroup-truncation
mperrotti b0d57d4
Merge branch 'main' into mp/labelgroup-truncation
mperrotti 6c56373
Merge branch 'main' into mp/labelgroup-truncation
mperrotti 4c0b108
Merge branch 'main' of github.com:primer/react into mp/labelgroup-tru…
mperrotti d76b018
updates inline collapse button to use text, not an icon
mperrotti e70d5e9
test(vrt): update snapshots
mperrotti 67873a8
rm defaultProps
mperrotti 046a7fb
Merge branch 'mp/labelgroup-truncation' of github.com:primer/react in…
mperrotti b2a730d
Merge branch 'main' of github.com:primer/react into mp/labelgroup-tru…
mperrotti 83173bd
Merge branch 'main' into mp/labelgroup-truncation
mperrotti 9d48bd3
Merge branch 'main' into mp/labelgroup-truncation
mperrotti 14c7467
Merge branch 'main' into mp/labelgroup-truncation
mperrotti 9799398
Merge branch 'main' into mp/labelgroup-truncation
mperrotti d2336a3
Merge branch 'main' into mp/labelgroup-truncation
mperrotti d50b56d
Merge branch 'main' into mp/labelgroup-truncation
mperrotti d8d1ba6
disables focusZone in the overlay
mperrotti 6780fa1
Merge branch 'main' of github.com:primer/react into mp/labelgroup-tru…
mperrotti 44f4917
updates changeset
mperrotti 614cfdb
updates changeset again
mperrotti aaecaad
adds count to visually hidden content
mperrotti 3e665c6
Merge branch 'main' of github.com:primer/react into mp/labelgroup-tru…
mperrotti ebd150c
Merge branch 'main' of github.com:primer/react into mp/labelgroup-tru…
mperrotti 150549a
layout refinements
mperrotti bf2bd18
Merge branch 'main' into mp/labelgroup-truncation
mperrotti 9cf6b50
Merge branch 'main' of github.com:primer/react into mp/labelgroup-tru…
mperrotti a93200c
Merge branch 'mp/labelgroup-truncation' of github.com:primer/react in…
mperrotti 2565f7e
Merge branch 'main' into mp/labelgroup-truncation
mperrotti b0fe2da
Merge branch 'main' into mp/labelgroup-truncation
mperrotti e4180ef
Merge branch 'main' into mp/labelgroup-truncation
mperrotti 729d0df
Merge branch 'main' into mp/labelgroup-truncation
mperrotti 923f605
Merge branch 'main' into mp/labelgroup-truncation
mperrotti 674274b
Merge branch 'main' into mp/labelgroup-truncation
mperrotti File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
"@primer/react": patch | ||
--- | ||
|
||
Adds truncation features to the LabelGroup component: | ||
- truncate LabelGroup children after a static number of children (for example, truncate after the 5th label) | ||
- truncate LabelGroup children to fit in the width of the parent | ||
- show full list in an Overlay | ||
- show full list inline | ||
|
||
<!-- Changed components: LabelGroup --> |
Binary file modified
BIN
-851 Bytes
(94%)
...nents/LabelGroup.test.ts-snapshots/LabelGroup-Default-dark-colorblind-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-1023 Bytes
(93%)
...omponents/LabelGroup.test.ts-snapshots/LabelGroup-Default-dark-dimmed-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-1.48 KB
(89%)
...ts/LabelGroup.test.ts-snapshots/LabelGroup-Default-dark-high-contrast-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-1.39 KB
(90%)
...shots/components/LabelGroup.test.ts-snapshots/LabelGroup-Default-dark-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-1.22 KB
(91%)
...nents/LabelGroup.test.ts-snapshots/LabelGroup-Default-dark-tritanopia-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-1.43 KB
(90%)
...ents/LabelGroup.test.ts-snapshots/LabelGroup-Default-light-colorblind-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-1.46 KB
(89%)
...s/LabelGroup.test.ts-snapshots/LabelGroup-Default-light-high-contrast-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-1.44 KB
(89%)
...hots/components/LabelGroup.test.ts-snapshots/LabelGroup-Default-light-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
-1.43 KB
(90%)
...ents/LabelGroup.test.ts-snapshots/LabelGroup-Default-light-tritanopia-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+1.17 KB
(110%)
...ts/LabelGroup.test.ts-snapshots/LabelGroup-Playground-dark-colorblind-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+948 Bytes
(110%)
...onents/LabelGroup.test.ts-snapshots/LabelGroup-Playground-dark-dimmed-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+564 Bytes
(100%)
...LabelGroup.test.ts-snapshots/LabelGroup-Playground-dark-high-contrast-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+576 Bytes
(100%)
...ts/components/LabelGroup.test.ts-snapshots/LabelGroup-Playground-dark-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+797 Bytes
(110%)
...ts/LabelGroup.test.ts-snapshots/LabelGroup-Playground-dark-tritanopia-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+479 Bytes
(100%)
...s/LabelGroup.test.ts-snapshots/LabelGroup-Playground-light-colorblind-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+502 Bytes
(100%)
...abelGroup.test.ts-snapshots/LabelGroup-Playground-light-high-contrast-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+496 Bytes
(100%)
...s/components/LabelGroup.test.ts-snapshots/LabelGroup-Playground-light-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified
BIN
+478 Bytes
(100%)
...s/LabelGroup.test.ts-snapshots/LabelGroup-Playground-light-tritanopia-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+14.4 KB
.../LabelGroup.test.ts-snapshots/LabelGroup-TruncateAuto-dark-colorblind-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+14.3 KB
...ents/LabelGroup.test.ts-snapshots/LabelGroup-TruncateAuto-dark-dimmed-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+14.3 KB
...belGroup.test.ts-snapshots/LabelGroup-TruncateAuto-dark-high-contrast-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+14.1 KB
.../components/LabelGroup.test.ts-snapshots/LabelGroup-TruncateAuto-dark-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+14.4 KB
.../LabelGroup.test.ts-snapshots/LabelGroup-TruncateAuto-dark-tritanopia-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+14.1 KB
...LabelGroup.test.ts-snapshots/LabelGroup-TruncateAuto-light-colorblind-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+14.2 KB
...elGroup.test.ts-snapshots/LabelGroup-TruncateAuto-light-high-contrast-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+14.2 KB
...components/LabelGroup.test.ts-snapshots/LabelGroup-TruncateAuto-light-linux.png
Oops, something went wrong.
Binary file added
BIN
+14.1 KB
...LabelGroup.test.ts-snapshots/LabelGroup-TruncateAuto-light-tritanopia-linux.png
Oops, something went wrong.
Binary file added
BIN
+14.4 KB
...abelGroup.test.ts-snapshots/LabelGroup-TruncateToFive-dark-colorblind-linux.png
Oops, something went wrong.
Binary file added
BIN
+14.3 KB
...ts/LabelGroup.test.ts-snapshots/LabelGroup-TruncateToFive-dark-dimmed-linux.png
Oops, something went wrong.
Binary file added
BIN
+14.3 KB
...lGroup.test.ts-snapshots/LabelGroup-TruncateToFive-dark-high-contrast-linux.png
Oops, something went wrong.
Binary file added
BIN
+14.1 KB
...omponents/LabelGroup.test.ts-snapshots/LabelGroup-TruncateToFive-dark-linux.png
Oops, something went wrong.
Binary file added
BIN
+14.4 KB
...abelGroup.test.ts-snapshots/LabelGroup-TruncateToFive-dark-tritanopia-linux.png
Oops, something went wrong.
Binary file added
BIN
+14.1 KB
...belGroup.test.ts-snapshots/LabelGroup-TruncateToFive-light-colorblind-linux.png
Oops, something went wrong.
Binary file added
BIN
+14.2 KB
...Group.test.ts-snapshots/LabelGroup-TruncateToFive-light-high-contrast-linux.png
Oops, something went wrong.
Binary file added
BIN
+14.2 KB
...mponents/LabelGroup.test.ts-snapshots/LabelGroup-TruncateToFive-light-linux.png
Oops, something went wrong.
Binary file added
BIN
+14.1 KB
...belGroup.test.ts-snapshots/LabelGroup-TruncateToFive-light-tritanopia-linux.png
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
import React from 'react' | ||
import styled from 'styled-components' | ||
import LabelGroup from './LabelGroup' | ||
import {Meta, Story} from '@storybook/react' | ||
import Token from '../Token/Token' | ||
import Label from '../Label/Label' | ||
|
||
const meta: Meta = { | ||
title: 'Components/LabelGroup/Features', | ||
component: LabelGroup, | ||
decorators: [ | ||
Story => { | ||
return ( | ||
<> | ||
<Story /> | ||
</> | ||
) | ||
}, | ||
], | ||
} | ||
|
||
const ResizableContainer = styled.div` | ||
outline: 1px solid black; | ||
overflow: auto; | ||
padding: 0.25rem; | ||
resize: horizontal; | ||
width: 600px; | ||
` | ||
|
||
export const TruncateAuto: Story = () => ( | ||
<ResizableContainer> | ||
<LabelGroup visibleChildCount="auto"> | ||
<Label>One</Label> | ||
<Label>Two</Label> | ||
<Label>Three</Label> | ||
<Label>Four</Label> | ||
<Label>Five</Label> | ||
<Label>Six</Label> | ||
<Label>Seven</Label> | ||
<Label>Eight</Label> | ||
<Label>Nine</Label> | ||
<Label>Ten</Label> | ||
<Label>Eleven</Label> | ||
<Label>Twelve</Label> | ||
<Label>Thirteen</Label> | ||
<Label>Fourteen</Label> | ||
<Label>Fifteen</Label> | ||
<Label>Sixteen</Label> | ||
</LabelGroup> | ||
</ResizableContainer> | ||
) | ||
|
||
export const TruncateAutoWithInteractiveTokens: Story = () => ( | ||
<ResizableContainer> | ||
<LabelGroup visibleChildCount="auto"> | ||
<Token as="button" text="One" /> | ||
<Token as="button" text="Two" /> | ||
<Token as="button" text="Three" /> | ||
<Token as="button" text="Four" /> | ||
<Token as="button" text="Five" /> | ||
<Token as="button" text="Six" /> | ||
<Token as="button" text="Seven" /> | ||
<Token as="button" text="Eight" /> | ||
<Token as="button" text="Nine" /> | ||
<Token as="button" text="Ten" /> | ||
<Token as="button" text="Eleven" /> | ||
<Token as="button" text="Twelve" /> | ||
<Token as="button" text="Thirteen" /> | ||
<Token as="button" text="Fourteen" /> | ||
<Token as="button" text="Fifteen" /> | ||
<Token as="button" text="Sixteen" /> | ||
</LabelGroup> | ||
</ResizableContainer> | ||
) | ||
|
||
export const TruncateAfterFive: Story = () => ( | ||
<LabelGroup visibleChildCount={5}> | ||
<Label>One</Label> | ||
<Label>Two</Label> | ||
<Label>Three</Label> | ||
<Label>Four</Label> | ||
<Label>Five</Label> | ||
<Label>Six</Label> | ||
<Label>Seven</Label> | ||
<Label>Eight</Label> | ||
<Label>Nine</Label> | ||
<Label>Ten</Label> | ||
<Label>Eleven</Label> | ||
<Label>Twelve</Label> | ||
<Label>Thirteen</Label> | ||
<Label>Fourteen</Label> | ||
<Label>Fifteen</Label> | ||
<Label>Sixteen</Label> | ||
</LabelGroup> | ||
) | ||
|
||
export const TruncateAutoExpandInline: Story = () => ( | ||
<ResizableContainer> | ||
<LabelGroup visibleChildCount="auto" overflowStyle="inline"> | ||
<Label>One</Label> | ||
<Label>Two</Label> | ||
<Label>Three</Label> | ||
<Label>Four</Label> | ||
<Label>Five</Label> | ||
<Label>Six</Label> | ||
<Label>Seven</Label> | ||
<Label>Eight</Label> | ||
<Label>Nine</Label> | ||
<Label>Ten</Label> | ||
<Label>Eleven</Label> | ||
<Label>Twelve</Label> | ||
<Label>Thirteen</Label> | ||
<Label>Fourteen</Label> | ||
<Label>Fifteen</Label> | ||
<Label>Sixteen</Label> | ||
</LabelGroup> | ||
</ResizableContainer> | ||
) | ||
|
||
export const TruncateAutoExpandInlineWithInteractiveTokens: Story = () => ( | ||
<ResizableContainer> | ||
<LabelGroup visibleChildCount="auto" overflowStyle="inline"> | ||
<Token as="button" text="One" /> | ||
<Token as="button" text="Two" /> | ||
<Token as="button" text="Three" /> | ||
<Token as="button" text="Four" /> | ||
<Token as="button" text="Five" /> | ||
<Token as="button" text="Six" /> | ||
<Token as="button" text="Seven" /> | ||
<Token as="button" text="Eight" /> | ||
<Token as="button" text="Nine" /> | ||
<Token as="button" text="Ten" /> | ||
<Token as="button" text="Eleven" /> | ||
<Token as="button" text="Twelve" /> | ||
<Token as="button" text="Thirteen" /> | ||
<Token as="button" text="Fourteen" /> | ||
<Token as="button" text="Fifteen" /> | ||
<Token as="button" text="Sixteen" /> | ||
</LabelGroup> | ||
</ResizableContainer> | ||
) | ||
|
||
export default meta |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.