-
Notifications
You must be signed in to change notification settings - Fork 7
feat(design-system): change DsDrawer responsive strategy [AR-53856] #358
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
Closed
vpolessky-dn
wants to merge
1
commit into
drivenets:next
from
vpolessky-dn:feat/AR-53856-change-drawer-responsive
Closed
Changes from all commits
Commits
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,5 @@ | ||
| --- | ||
| '@drivenets/design-system': major | ||
| --- | ||
|
|
||
| `DsDrawer`: Replace `columns` prop with `width` |
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,5 @@ | ||
| --- | ||
| '@drivenets/design-system': minor | ||
| --- | ||
|
|
||
| Add responsive prop support at 1440px breakpoint with CSS-first styling and `useResponsiveValue` hook for JS conditional rendering |
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
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
5 changes: 4 additions & 1 deletion
5
packages/design-system/src/components/ds-button/versions/ds-button-new/index.ts
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 |
|---|---|---|
| @@ -1,2 +1,5 @@ | ||
| export { default as DsButtonNew } from './ds-button-new'; | ||
| import { withResponsiveProps } from '../../../../utils/responsive'; | ||
| import DsButtonBase from './ds-button-new'; | ||
|
|
||
| export const DsButtonNew = withResponsiveProps(DsButtonBase, ['size']); | ||
| export * from './ds-button-new.types'; |
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
100 changes: 100 additions & 0 deletions
100
packages/design-system/src/components/ds-drawer/__tests__/ds-drawer.browser.test.tsx
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,100 @@ | ||
| import { useState } from 'react'; | ||
| import { describe, expect, it, vi } from 'vitest'; | ||
| import { page } from 'vitest/browser'; | ||
| import DsDrawer from '../ds-drawer'; | ||
|
|
||
| const DrawerWrapper = ({ onOpenChange, ...props }: Partial<Parameters<typeof DsDrawer>[0]>) => { | ||
| const [open, setOpen] = useState(false); | ||
|
|
||
| const handleOpenChange = (value: boolean) => { | ||
| setOpen(value); | ||
| onOpenChange?.(value); | ||
| }; | ||
|
|
||
| return ( | ||
| <div style={{ position: 'relative', width: 800, height: 400 }}> | ||
| <button type="button" onClick={() => handleOpenChange(true)}> | ||
| Open Drawer | ||
| </button> | ||
|
|
||
| <DsDrawer {...props} open={open} onOpenChange={handleOpenChange}> | ||
| {props.children ?? ( | ||
| <> | ||
| <DsDrawer.Header> | ||
| <DsDrawer.Title>Test Drawer</DsDrawer.Title> | ||
| <DsDrawer.CloseTrigger /> | ||
| </DsDrawer.Header> | ||
| <DsDrawer.Body>Body content</DsDrawer.Body> | ||
| </> | ||
| )} | ||
| </DsDrawer> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| describe('DsDrawer', () => { | ||
| it('opens and closes via trigger', async () => { | ||
| await page.render(<DrawerWrapper />); | ||
|
|
||
| await page.getByRole('button', { name: /open drawer/i }).click(); | ||
|
|
||
| const dialog = page.getByRole('dialog'); | ||
| await expect.element(dialog).toHaveAttribute('data-state', 'open'); | ||
|
|
||
| await page.getByRole('button', { name: /close/i }).click(); | ||
| await expect.element(dialog).toHaveAttribute('data-state', 'closed'); | ||
| }); | ||
|
|
||
| it('calls onOpenChange when opened and closed', async () => { | ||
| const onOpenChange = vi.fn(); | ||
| await page.render(<DrawerWrapper onOpenChange={onOpenChange} />); | ||
|
|
||
| await page.getByRole('button', { name: /open drawer/i }).click(); | ||
| expect(onOpenChange).toHaveBeenCalledWith(true); | ||
|
|
||
| await page.getByRole('button', { name: /close/i }).click(); | ||
| expect(onOpenChange).toHaveBeenCalledWith(false); | ||
| }); | ||
|
|
||
| it('renders backdrop when backdrop prop is true', async () => { | ||
| const { baseElement } = await page.render(<DrawerWrapper backdrop />); | ||
|
|
||
| await page.getByRole('button', { name: /open drawer/i }).click(); | ||
|
|
||
| const dialog = page.getByRole('dialog'); | ||
| await expect.element(dialog).toHaveAttribute('data-state', 'open'); | ||
|
|
||
| const backdrop = baseElement.querySelector('[data-part="backdrop"]'); | ||
| expect(backdrop).toBeTruthy(); | ||
| expect(backdrop).toHaveAttribute('data-state', 'open'); | ||
| }); | ||
|
|
||
| it('has responsive width clamped between 240px and 480px', async () => { | ||
| await page.render(<DrawerWrapper />); | ||
|
|
||
| await page.getByRole('button', { name: /open drawer/i }).click(); | ||
|
|
||
| const dialog = page.getByRole('dialog'); | ||
| await expect.element(dialog).toHaveAttribute('data-state', 'open'); | ||
|
|
||
| const el = dialog.element() as HTMLElement; | ||
| const width = el.getBoundingClientRect().width; | ||
| expect(width).toBeGreaterThanOrEqual(240); | ||
| expect(width).toBeLessThanOrEqual(480); | ||
| }); | ||
|
|
||
| it('fills remaining height', async () => { | ||
| await page.render(<DrawerWrapper />); | ||
|
|
||
| await page.getByRole('button', { name: /open drawer/i }).click(); | ||
|
|
||
| const dialog = page.getByRole('dialog'); | ||
| await expect.element(dialog).toHaveAttribute('data-state', 'open'); | ||
|
|
||
| const el = dialog.element() as HTMLElement; | ||
| const container = el.closest('[data-scope="dialog"]')?.parentElement; | ||
| const containerHeight = container?.getBoundingClientRect().height ?? 0; | ||
| const drawerHeight = el.getBoundingClientRect().height; | ||
| expect(drawerHeight).toBe(containerHeight); | ||
| }); | ||
| }); |
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 |
|---|---|---|
| @@ -1,5 +1,3 @@ | ||
| @use '../../styles/grid-variables' as grid-vars; | ||
|
|
||
| .backdrop { | ||
| position: absolute; | ||
| inset: 0; | ||
|
|
@@ -47,14 +45,13 @@ | |
| display: block; | ||
| top: 0; | ||
| bottom: 0; | ||
| width: clamp(240px, 20vw, 480px); | ||
| background: var(--color-background); | ||
| box-shadow: 0 2px 6px 0 rgba(0, 0, 0, 0.22); | ||
| z-index: 1200; | ||
| pointer-events: auto; | ||
| overflow: hidden; | ||
| transition: | ||
| transform 0.2s ease, | ||
| width 0.2s ease; | ||
| transition: transform 0.2s ease; | ||
|
|
||
| &.position-end { | ||
| right: 0; | ||
|
|
@@ -83,12 +80,6 @@ | |
| animation: 0.25s slide-out-drawer-start both; | ||
| } | ||
| } | ||
|
|
||
| @for $i from 1 through grid-vars.$columns { | ||
| &.cols-#{$i} { | ||
| width: var(--col-span-#{$i}); | ||
| } | ||
| } | ||
| } | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why are you removing this? It should be the same as per what I'm seeing in Figma Am I missing something? |
||
|
|
||
| @keyframes slide-in-drawer-end { | ||
|
|
||
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what are these changesets names? it should be auto-generated by
pnpm run changelog, not written manually