-
Notifications
You must be signed in to change notification settings - Fork 0
feat(ECX-579): add Drawer component and wide Constrain variant #7220
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
4 commits
Select commit
Hold shift + click to select a range
029e2db
feat(ECX-579): add Drawer component
hevele-moda c640a50
feat(ECX-579): add wide size variant to Constrain
hevele-moda 925b1a5
fix(storybook): replace unmaintained ignore-not-found-export-webpack-…
hevele-moda 89aa809
fix(ECX-579): address Drawer review feedback
hevele-moda 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
Some comments aren't visible on the classic Files Changed page.
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,16 @@ | ||
| // Replaces the unmaintained `ignore-not-found-export-webpack-plugin`, whose only functionality | ||
| // is filtering out "export was not found" warnings — its `require('webpack/lib/ModuleDependencyWarning')` | ||
| // deep-import breaks on newer webpack 5 versions, where that module moved under `lib/errors/`. | ||
| // Matching on `constructor.name` avoids importing the class at all. | ||
| const EXPORT_NOT_FOUND = /export.*was not found in/; | ||
|
|
||
| module.exports = class IgnoreNotFoundExportWarningsPlugin { | ||
| apply(compiler) { | ||
| compiler.hooks.done.tap('IgnoreNotFoundExportWarningsPlugin', stats => { | ||
| stats.compilation.warnings = stats.compilation.warnings.filter( | ||
| warning => | ||
| !(warning.constructor.name === 'ModuleDependencyWarning' && EXPORT_NOT_FOUND.test(warning.message)) | ||
| ); | ||
| }); | ||
| } | ||
| }; |
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| @use '~@moda/om'; | ||
|
|
||
| .Drawer { | ||
| --drawer-width: 15rem; | ||
|
|
||
| flex: 0 0 auto; | ||
| width: 0; | ||
| overflow: hidden; | ||
| visibility: hidden; | ||
| transition: width 250ms ease, visibility 0s 250ms; | ||
|
|
||
| &--open { | ||
| width: var(--drawer-width); | ||
| visibility: visible; | ||
| transition: width 250ms ease, visibility 0s; | ||
| } | ||
|
|
||
| &__content { | ||
| width: var(--drawer-width); | ||
| height: 100%; | ||
| } | ||
| } |
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,26 @@ | ||
| import React, { useState } from 'react'; | ||
| import { Button } from '../Button'; | ||
| import { Text } from '../Text'; | ||
| import { Drawer } from './Drawer'; | ||
|
|
||
| export default { title: 'Components/Drawer' }; | ||
|
|
||
| export const Default = () => { | ||
| const [open, setOpen] = useState(false); | ||
|
|
||
| return ( | ||
| <div style={{ display: 'flex' }}> | ||
| <Drawer open={open} style={{ backgroundColor: 'lightgray' }}> | ||
| <Text>Drawer content</Text> | ||
| </Drawer> | ||
|
|
||
| <div style={{ flex: 1, padding: '1rem' }}> | ||
| <Button onClick={() => setOpen(open => !open)}>{open ? 'Close' : 'Open'} drawer</Button> | ||
| <Text> | ||
| The drawer pushes this content over when open, rather than overlaying it — no backdrop, no | ||
| focus trap. | ||
| </Text> | ||
| </div> | ||
| </div> | ||
| ); | ||
| }; |
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,27 @@ | ||
| import React from 'react'; | ||
| import { render, screen } from '@testing-library/react'; | ||
|
|
||
| import { Drawer } from './Drawer'; | ||
|
|
||
| describe('Drawer', () => { | ||
| it('renders its children', () => { | ||
| render(<Drawer open>Hello</Drawer>); | ||
| expect(screen.getByText('Hello')).toBeVisible(); | ||
| }); | ||
|
|
||
| it('toggles the open class based on the open prop', () => { | ||
| const { rerender } = render( | ||
| <Drawer open={false} data-testid='drawer'> | ||
| Hello | ||
| </Drawer> | ||
| ); | ||
| expect(screen.getByTestId('drawer')).not.toHaveClass('Drawer--open'); | ||
|
|
||
| rerender( | ||
| <Drawer open data-testid='drawer'> | ||
| Hello | ||
| </Drawer> | ||
| ); | ||
| expect(screen.getByTestId('drawer')).toHaveClass('Drawer--open'); | ||
| }); | ||
| }); | ||
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,13 @@ | ||
| import React from 'react'; | ||
| import classNames from 'classnames'; | ||
| import './Drawer.scss'; | ||
|
|
||
| export type DrawerProps = React.HTMLAttributes<HTMLDivElement> & { | ||
| open: boolean; | ||
| }; | ||
|
|
||
| export const Drawer: React.FC<DrawerProps> = ({ className, open, children, ...rest }) => ( | ||
| <div className={classNames('Drawer', { 'Drawer--open': open }, className)} {...rest}> | ||
| <div className='Drawer__content'>{children}</div> | ||
| </div> | ||
| ); |
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 @@ | ||
| export * from './Drawer'; |
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
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.