-
Notifications
You must be signed in to change notification settings - Fork 538
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support passing React.ReactElements for icons (#4994)
* Support passing React.ReactElements for icons * Add changeset * Fix types * Woops, fix tests * Add type tests
- Loading branch information
Showing
10 changed files
with
113 additions
and
27 deletions.
There are no files selected for viewing
This file contains 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,5 @@ | ||
--- | ||
'@primer/react': minor | ||
--- | ||
|
||
[SegmentedControl, Autocomplete] Support passing React.ReactElements for icons. |
This file contains 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 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 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 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 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
21 changes: 21 additions & 0 deletions
21
packages/react/src/SegmentedControl/SegmentedControl.types.test.tsx
This file contains 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,21 @@ | ||
import {LogoGithubIcon} from '@primer/octicons-react' | ||
import {SegmentedControl} from './SegmentedControl' | ||
import React from 'react' | ||
|
||
export function buttonWithLeadingIconElement() { | ||
return ( | ||
<SegmentedControl> | ||
<SegmentedControl.Button leadingIcon={<LogoGithubIcon />}>Button</SegmentedControl.Button> | ||
</SegmentedControl> | ||
) | ||
} | ||
|
||
export function iconButtonWithIconElement() { | ||
return ( | ||
<SegmentedControl> | ||
<SegmentedControl.IconButton aria-label="A label" icon={<LogoGithubIcon />}> | ||
Button | ||
</SegmentedControl.IconButton> | ||
</SegmentedControl> | ||
) | ||
} |
This file contains 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 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 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,24 @@ | ||
import {LogoGithubIcon} from '@primer/octicons-react' | ||
import {Autocomplete} from '..' | ||
import React from 'react' | ||
|
||
export function itemWithIconElements() { | ||
return ( | ||
<> | ||
<label htmlFor="autocompleteId" id="autocompleteLabel"> | ||
Autocomplete field | ||
</label> | ||
<Autocomplete id="autocompleteId"> | ||
<Autocomplete.Overlay> | ||
<Autocomplete.Menu | ||
aria-labelledby="autocompleteLabel" | ||
selectedItemIds={[]} | ||
items={[ | ||
{text: 'Item1', id: 'item-1', leadingVisual: <LogoGithubIcon />, trailingVisual: <LogoGithubIcon />}, | ||
]} | ||
></Autocomplete.Menu> | ||
</Autocomplete.Overlay> | ||
</Autocomplete> | ||
</> | ||
) | ||
} |