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

🚀 refactor(drawer): adjust drawer styles and structure #647

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

Conversation

matheushdsbr
Copy link
Collaborator

@matheushdsbr matheushdsbr commented Apr 6, 2023

JIRA Issue

Description 📄

In this PR I'm refactoring the drawer and adding some new props.

I realized that the Drawer receives the body of the Dialog as a base, but I needed to add some props to the <Drawer.Header>, so I thought about refactoring the <Dialog.Header> by changing a little how it works. This change also affected the <BottomSheet.Header>.

The <Drawer.Header> now has the option to onClose, backHandler and title.

onClose and backHandler are very similar, they receive a function, but each with its own icon:

onClose -> Close icon,
backHandler -> ArrowLeft icon,
title -> string

To use <Drawer.Header> just use its props.

This PR will trigger a breaking change <---
Need to adjust components that are using <Dialog.Header> and <BottomSheet.Header>

Obs:

Added @testing-library/user-event and @testing-library/dom package to perform click actions on tests with userEvent as recommended by testing library doc

Platforms 📲

  • Web
  • Mobile

Type of change 🔍

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested? 🧪

[Enter the tips to test this PR]

  • Unit Test
  • Snapshot Test

Checklist: 🔍

  • My code follows the contribution guide of this project Contributing Guide
  • Layout matches design prototype: FIGMA
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules
  • I have checked my code and corrected any misspellings

Screenshots 📸

Before After
Screenshot 2023-04-06 at 15 53 52 Screenshot 2023-04-06 at 15 54 10

With back button

Screenshot 2023-04-06 at 15 55 43

With divider on header

Screenshot 2023-04-06 at 15 57 25

With no close button

Screenshot 2023-04-06 at 15 57 56

With no header

Screenshot 2023-04-06 at 16 00 09

@matheushdsbr matheushdsbr self-assigned this Apr 6, 2023
@matheushdsbr matheushdsbr marked this pull request as ready for review April 11, 2023 13:53
@matheushdsbr matheushdsbr marked this pull request as draft April 11, 2023 18:42
@matheushdsbr matheushdsbr marked this pull request as ready for review April 11, 2023 19:15
@caiotracera
Copy link
Contributor

Hey, @matheushdsbr!
Congrats for the initiative! I am wondering if this PR fixes #632 🤔

@matheushdsbr
Copy link
Collaborator Author

Hey, @matheushdsbr! Congrats for the initiative! I am wondering if this PR fixes #632 🤔

Thanks! Not yet, but thanks for mentioning it. I will analyze the situation

@matheushdsbr
Copy link
Collaborator Author

Hey @caiotracera, I believe that to solve this bug it would be better to open another PR, the purpose of this one at first is to adjust the structure of the drawer. What do you think?

Comment on lines +8 to +64
function showCloseButton() {
if (onClose && !hideCloseButton) {
return (
<Heading.RightButton
aria-label="close-button-drawer"
onClick={onClose}
icon={Close}
large
/>
);
}

return null;
}

function showTitle() {
if (title) {
return (
<Heading.Title
style={{
letterSpacing: '1px',
textTransform: 'uppercase',
fontSize: '12px',
}}
>
{title}
</Heading.Title>
);
}

return null;
}

function showBackButton() {
if (backHandler) {
return (
<Heading.BackButton
aria-label="back-button-drawer"
onClick={backHandler}
/>
);
}

return null;
}

function showDivider() {
if (divider) {
return (
<Box marginTop="small">
<Divider aria-label="divider-drawer" />
</Box>
);
}

return null;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Defining components within components is a bad practise.

Explanation why:
https://youtu.be/QuLfCUh-iwI?t=532

return (
<Box width="100%">
<Box paddingTop="small" paddingRight="small" paddingLeft="xxlarge">
<Heading noPadding role="heading" aria-label="header-drawer">
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't define a fixed aria-label. You defining a "meaning" that not explain the usage of the "Heading". If really needed (which i don't think it ) it should be costumizable.

Comment on lines +14 to +15
padding: ${theme.spacing.zero} !important;
border-radius: ${theme.borders.zero} !important;
Copy link
Contributor

Choose a reason for hiding this comment

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

If you are using !important here probably something is not right with the css structure.
Can you check?

Comment on lines -121 to -122
/** Hide the close button when onClose prop is defined. */
hideCloseButton: bool,
Copy link
Contributor

@MicaelRodrigues MicaelRodrigues May 2, 2023

Choose a reason for hiding this comment

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

Why did you remove hideCloseButton prop? It will break some implementations that are using it.
Example, in partners portal:

https://github.com/gympass/partners-reports-mfe/blob/master/src/components/templates/DrawerPage/DrawerPage.tsx

/** Function to close the dialog. */
onClose: func,
backHandler: func,
Copy link
Contributor

Choose a reason for hiding this comment

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

Following the name convention of "onClose", WDYT of onBack here?


const BoxContent = styled(Box)`
height: 100%;
max-width: 340px;
Copy link
Contributor

Choose a reason for hiding this comment

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

We should not assume these sizes. The box should be always 100% of Drawer.Content. and Drawer.Content should be the one setting the spacing

@psidneis psidneis requested review from ericcleao and tcK1 May 8, 2023 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants