Skip to content
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

feat(Drawer): new component #1306

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open

feat(Drawer): new component #1306

wants to merge 17 commits into from

Conversation

pladaria
Copy link
Member

@pladaria pladaria commented Dec 16, 2024

@pladaria pladaria changed the title deat(Drawer): new component feat(Drawer): new component Dec 16, 2024
Copy link

github-actions bot commented Dec 16, 2024

Size stats

master this branch diff
Total JS 12.3 MB 12.3 MB +11.6 kB
JS without icons 2.04 MB 2.05 MB +11.6 kB
Lib overhead 72.8 kB 72.8 kB 0 B
Lib overhead (gzip) 17.1 kB 17.1 kB 0 B

Copy link

github-actions bot commented Dec 16, 2024

Accessibility report
✔️ No issues found

ℹ️ You can run this locally by executing yarn audit-accessibility.

Copy link

github-actions bot commented Dec 16, 2024

Deploy preview for mistica-web ready!

✅ Preview
https://mistica-1ubmwvf3c-flows-projects-65bb050e.vercel.app

Built with commit 07dafe9.
This pull request is being automatically deployed with vercel-action

@@ -20,29 +20,22 @@ export const Portal = ({children, className}: Props): JSX.Element | null => {
const [container, setContainer] = React.useState<HTMLDivElement | null>(null);
Copy link
Member Author

@pladaria pladaria Dec 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previous implementation was adding two nodes (because of strict mode in dev) and removing one, leaving leftovers in the dom.

export const container = style({
position: 'fixed',
display: 'flex',
paddingBottom: 'env(safe-area-inset-bottom)',
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pending to verify inside an iphone

@pladaria pladaria marked this pull request as ready for review December 20, 2024 11:41
checkTestIds(<Drawer title="Title" subtitle="Subtitle" description="Description" onClose={() => {}} />, [
{
componentName: 'Drawer',
internalTestIds: ['title', 'subtitle', 'description'],
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are these defined in the spec?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not in spec, but I was assuming the same testids for these elements that we were using in cards, etc

src/drawer.css.ts Outdated Show resolved Hide resolved
}, [onClose]);

const dismiss = React.useCallback(() => {
return close().then(() => onDismiss?.());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the difference between onDismiss and onClose? I initially thought that onDismiss was called immediately and onClose when the animation ends, but it seems both are called when the animation ends :/

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, I see the difference. onDismiss is only called when the drawer is closed by a dismiss action (esc key /close button, click outside). But can't we call onDismiss immediately without waiting for animation?

Copy link
Member Author

@pladaria pladaria Dec 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, we could call it immediately but I decided to not emit the close/dismiss event while the drawer is visible.

If you want to make some action on dismiss/close/action, you could be visually missing that change if it happens behind the drawer

)}
/>
<div
data-testid="drawerLayout"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this testid needed?

Copy link
Member Author

@pladaria pladaria Dec 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not really. I've added it to differentiate the boundaries of the different parts of the Drawer composite. The DrawerLayout is a separate component as Drawer.

Can be removed if you want to.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Opening the width prop we are opening also problems like.. what happened if the setup width is more than the device viewport? Is it possible to avoid this problem?

Example

The width should never exceed the viewport's width. If the width is greater than the viewport, the drawer should occupy 100% - 40px (to ensure the overlay is displayed).

maybe something like
max-width: calc(100vw - 40px);

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done. We could also add a min-width.

Please update specs with this information

src/drawer.css.ts Outdated Show resolved Hide resolved
src/drawer.css.ts Outdated Show resolved Hide resolved
src/drawer.css.ts Outdated Show resolved Hide resolved
},
});

export const overlay = style([
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aweell I think the overlay transition is not needed in mobile. What do you think?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like it. And If the drawer is white over a white background, it adds contrast.

@pladaria pladaria requested a review from yceballost December 20, 2024 17:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants