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

Center InternalDatePicker Clear button #3265

Merged
merged 11 commits into from
Jan 17, 2024

Conversation

leojalfred
Copy link
Contributor

Addresses #3249 by altering the InternalDatePicker Clear button to take the full width. Note that .hoverable-buttons is now conditionally rendered to prevent issues when centering the items in the button.

Screenshot 2024-01-05 at 12 07 48 PM Screenshot 2024-01-05 at 12 08 00 PM

This is my first open source contribution, please let me know if I can do anything to streamline my contribution.

Copy link

github-actions bot commented Jan 5, 2024

CLA

Hello there and welcome to our project!
By submitting your Pull Request, you acknowledge that you agree with the terms of our Contributor License Agreement.
Although we don't have a dedicated legal counsel, having this kind of agreement can protect us from potential legal issues or patent trolls.
Thank you for your understanding.

Generated by 🚫 dangerJS against 0d1a7c3


& .menu-item {
height: ${({ theme }) => theme.spacing(8)};
margin-bottom: ${({ theme }) => theme.spacing(1)};
margin-top: ${({ theme }) => theme.spacing(1)};
padding: 0 ${({ theme }) => theme.spacing(2)};
width: fit-content;

& > div {
Copy link
Member

Choose a reason for hiding this comment

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

We avoid styling children through CSS.
Instead you can transform the div itself to a Styled component

@lucasbordeau
Copy link
Contributor

Hi @leojalfred, it seems that you're both working on the same issue with @abdul-irfan-k, see other PR : #3273

Would you be ok to work together on this ?

We need this to be pixel perfect like in the figma.

@leojalfred
Copy link
Contributor Author

@lucasbordeau I'd be happy to. I can push up necessary changes tomorrow morning. Do you have a specific example in Figma that you want me to reference? I'm looking at the calendar components linked on the repo's README and I don't see a mockup for this.

@charlesBochet
Copy link
Member

@leojalfred
Copy link
Contributor Author

@charlesBochet I saw that but that doesn't really have much to do with the specifics of this ticket. Also the existing implementation doesn't match the design in Figma, particularly with respect to the padding. I can do my best when it comes to the padding, but it makes more sense to have the spacing for the Clear button line up with the rest of the spacing in existing implementation rather than the design in Figma.

@leojalfred
Copy link
Contributor Author

Also the div that you pointed out in the comment was already a styled component (StyledMenuItemLeftContent). The reason I used the div in styling is because it avoided the need for prop drilling. I think in order to not use children in the styling I'll need to pass a centering boolean down the chain to that component and use it to add justify-content: center.

I've got a question about using children in styling. It seems like children are used in styling, as in targeting .menu-item under the StyledButtonContainer styles. Should this be refactored as well? Or is there some rule that determines when it's appropriate to use children in styling and when it's not?

@leojalfred
Copy link
Contributor Author

leojalfred commented Jan 14, 2024

@charlesBochet it should be good to go. I changed the justify-content: center that was originally styled on the div to be styled via props in StyledMenuItemLeftContent. Per the other PR I changed StyledButtonContainer to extend MenuItem. Per the other PR I also changed the StyledButtonContainer spacing to be the same vertically and horizontally, but to my eye it looks worse.

Screenshot 2024-01-14 at 12 41 27 PM Screenshot 2024-01-14 at 12 41 45 PM

Copy link
Contributor

@lucasbordeau lucasbordeau left a comment

Choose a reason for hiding this comment

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

Good for the design.

Could you just create the button from scratch and not use the MenuItem component ?

Because MenuItem is used everywhere in the code and refactoring it to handle centered text is out of the scope of this issue.

We can see in storybook for MenuItem, that it doesn't play well with isCentered set to true and right icon buttons.

We'll see how to refactor this MenuItem later.

image

Copy link
Member

@charlesBochet charlesBochet left a comment

Choose a reason for hiding this comment

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

Looks great! Perfect, thank you :)

@charlesBochet charlesBochet merged commit 8864528 into twentyhq:main Jan 17, 2024
10 checks passed
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.

None yet

3 participants