-
Notifications
You must be signed in to change notification settings - Fork 550
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ActionList.Heading): Convert to CSS Modules (#5367)
* heading * lint * Create new-pans-shout.md * use size prop * test(vrt): update snapshots * Update e2e/components/ActionList.test.ts * test(vrt): update snapshots * Update packages/react/src/ActionList/Heading.test.tsx --------- Co-authored-by: langermank <[email protected]> Co-authored-by: Jon Rohan <[email protected]> Co-authored-by: jonrohan <[email protected]>
- Loading branch information
1 parent
3e0fc7c
commit 844e41f
Showing
17 changed files
with
196 additions
and
58 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 | ||
--- | ||
|
||
Convert ActionList.Heading to CSS Modules |
Binary file added
BIN
+12.8 KB
...s/ActionList.test.ts-snapshots/Heading-with-Classname-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
+12.7 KB
...nents/ActionList.test.ts-snapshots/Heading-with-Classname-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
+12.7 KB
...ctionList.test.ts-snapshots/Heading-with-Classname-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
+12.8 KB
...s/components/ActionList.test.ts-snapshots/Heading-with-Classname-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
+12.8 KB
...s/ActionList.test.ts-snapshots/Heading-with-Classname-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
+12.6 KB
.../ActionList.test.ts-snapshots/Heading-with-Classname-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
+12.5 KB
...tionList.test.ts-snapshots/Heading-with-Classname-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
+12.6 KB
.../components/ActionList.test.ts-snapshots/Heading-with-Classname-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 added
BIN
+12.6 KB
.../ActionList.test.ts-snapshots/Heading-with-Classname-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.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
.ActionListHeader { | ||
margin-block-end: var(--base-size-8); | ||
|
||
&:where([data-list-variant='full']) { | ||
margin-inline-start: var(--base-size-8); | ||
} | ||
|
||
&:where([data-list-variant='inset']) { | ||
/* stylelint-disable-next-line primer/spacing */ | ||
margin-inline-start: calc(var(--control-medium-paddingInline-condensed) + var(--base-size-8)); | ||
} | ||
} |
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,83 @@ | ||
import {render as HTMLRender} from '@testing-library/react' | ||
import React from 'react' | ||
import theme from '../theme' | ||
import {ActionList} from '.' | ||
import {BaseStyles, ThemeProvider, ActionMenu} from '..' | ||
import {FeatureFlags} from '../FeatureFlags' | ||
|
||
describe('ActionList.Heading', () => { | ||
it('should render the ActionList.Heading component as a heading with the given heading level', async () => { | ||
const container = HTMLRender( | ||
<ActionList> | ||
<ActionList.Heading as="h1">Heading</ActionList.Heading> | ||
</ActionList>, | ||
) | ||
const heading = container.getByRole('heading', {level: 1}) | ||
expect(heading).toBeInTheDocument() | ||
expect(heading).toHaveTextContent('Heading') | ||
}) | ||
|
||
it('should label the action list with the heading id', async () => { | ||
const {container, getByRole} = HTMLRender( | ||
<ActionList> | ||
<ActionList.Heading as="h1">Heading</ActionList.Heading> | ||
<ActionList.Item>Item</ActionList.Item> | ||
</ActionList>, | ||
) | ||
const list = container.querySelector('ul') | ||
const heading = getByRole('heading', {level: 1}) | ||
expect(list).toHaveAttribute('aria-labelledby', heading.id) | ||
}) | ||
|
||
it('should throw an error when ActionList.Heading is used within ActionMenu context', async () => { | ||
const spy = jest.spyOn(console, 'error').mockImplementation(() => jest.fn()) | ||
expect(() => | ||
HTMLRender( | ||
<ThemeProvider theme={theme}> | ||
<BaseStyles> | ||
<ActionMenu open={true}> | ||
<ActionMenu.Button>Trigger</ActionMenu.Button> | ||
<ActionMenu.Overlay> | ||
<ActionList> | ||
<ActionList.Heading as="h1">Heading</ActionList.Heading> | ||
<ActionList.Item>Item</ActionList.Item> | ||
</ActionList> | ||
</ActionMenu.Overlay> | ||
</ActionMenu> | ||
</BaseStyles> | ||
</ThemeProvider>, | ||
), | ||
).toThrow( | ||
"ActionList.Heading shouldn't be used within an ActionMenu container. Menus are labelled by the menu button's name.", | ||
) | ||
expect(spy).toHaveBeenCalled() | ||
spy.mockRestore() | ||
}) | ||
|
||
it('should support a custom `className` on the outermost element', () => { | ||
const Element = () => { | ||
return ( | ||
<ActionList> | ||
<ActionList.Heading as="h2" className="test-class-name"> | ||
Filter by | ||
</ActionList.Heading> | ||
</ActionList> | ||
) | ||
} | ||
const FeatureFlagElement = () => { | ||
return ( | ||
<FeatureFlags | ||
flags={{ | ||
primer_react_css_modules_team: true, | ||
primer_react_css_modules_staff: true, | ||
primer_react_css_modules_ga: true, | ||
}} | ||
> | ||
<Element /> | ||
</FeatureFlags> | ||
) | ||
} | ||
expect(HTMLRender(<FeatureFlagElement />).container.querySelector('h2')).toHaveClass('test-class-name') | ||
expect(HTMLRender(<Element />).container.querySelector('h2')).toHaveClass('test-class-name') | ||
}) | ||
}) |
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