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

[Accordion] Update Accordion.Container-based Styling #371

Merged
merged 19 commits into from
Sep 18, 2020

Conversation

michaeljaltamirano
Copy link
Contributor

@michaeljaltamirano michaeljaltamirano commented Sep 15, 2020

This PR sets out to make the following changes to the Accordion component:

  1. Update the box-shadow property.
  2. Add a default 4px border-radius.
  3. Add the following border-radius behavior: only the top-most and bottom-most accordion elements should be rounded.

The first two updates are relatively trivial. The third update required expanding the styling functionality of Accordion.Container, which has additional CSS selectors that handle the border-radius & focus outline requirements.
border-radius is set via long-hand properties border-top-left-radius, border-top-right-radius, border-bottom-left-radius, and border-bottom-right-radius.

This PR also updates all documentation instances of <Accordion> to be wrapped with <Accordion.Container>.

You can play with the Review App here: https://curology-radiance-pr-371.herokuapp.com/

Before:

before

After:

after

@snags88 snags88 temporarily deployed to curology-radiance-pr-371 September 15, 2020 22:12 Inactive
@snags88 snags88 temporarily deployed to curology-radiance-pr-371 September 15, 2020 22:25 Inactive
@snags88 snags88 temporarily deployed to curology-radiance-pr-371 September 15, 2020 22:29 Inactive
@snags88 snags88 temporarily deployed to curology-radiance-pr-371 September 15, 2020 22:30 Inactive
@snags88 snags88 temporarily deployed to curology-radiance-pr-371 September 15, 2020 22:34 Inactive
@snags88 snags88 temporarily deployed to curology-radiance-pr-371 September 16, 2020 19:33 Inactive
@@ -42,6 +52,8 @@ export const AccordionBox = styled.div<{
}>`
${({ noBorder, isOpen }) => (!noBorder ? getBorderStyle(isOpen) : '')};

position: relative;
Copy link
Contributor Author

@michaeljaltamirano michaeljaltamirano Sep 16, 2020

Choose a reason for hiding this comment

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

You can play with this in the dev tools but without it the box-shadow in the focus state is clipped by the border. It's not a total improvement but it's a small thing before I get to the accessibility updates this cycle, which is changing our focus state anyway.

@snags88 snags88 temporarily deployed to curology-radiance-pr-371 September 16, 2020 19:42 Inactive
@snags88 snags88 temporarily deployed to curology-radiance-pr-371 September 16, 2020 19:48 Inactive
Copy link
Contributor

@ZeMunchkin ZeMunchkin left a comment

Choose a reason for hiding this comment

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

Had a couple questions I left comments on. One might simplify the issue of enforcing the use of Grouping in the codebase, depending on how it shakes out.

Comment on lines 137 to 148
<Accordion.Grouping>
<Accordion.Container>
<Accordion title={<Accordion.Content>First Title</Accordion.Content>}>
<Accordion.Content>First Expansion</Accordion.Content>
</Accordion>
</Accordion.Container>
<Accordion.Container>
<Accordion title={<Accordion.Content>Second Title</Accordion.Content>}>
<Accordion.Content>Second Expansion</Accordion.Content>
</Accordion>
</Accordion.Container>
</Accordion.Grouping>;
Copy link
Contributor

Choose a reason for hiding this comment

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

This component structure confuses me a little bit. My understanding of Container was that it was an outer wrapper to hold several instances of Accordion. Here's an example from PocketDerm that supports that: https://github.com/curology/PocketDerm/blob/6216330178f842b1a886a23baf0b6a654aeb98f1/resources/assets/jsx/components/photoUploadAccordion/index.js#L160

With that in mind, I'm curious if it's feasible to extend the styles on Container with the Grouping styles and not have to use two outer wrappers for Accordion?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh interesting. Since there were some usages of <Accordion> without the container I had assumed that it just wraps a single <Accordion>. I should have considered more strongly that the docs read Container to hold instances of <Accordion> even though all the code examples only had one <Accordion> present. Let me refactor.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ZeMunchkin Thank you again for catching this. Updated in 03af86c (and story markup formatting fixed in 7d95b2b). I've also updated the PR description.

Comment on lines 13 to 21
const getTopBorderRadius = (borderRadius: string) => ({
borderTopLeftRadius: borderRadius,
borderTopRightRadius: borderRadius,
});

const getBottomBorderRadius = (borderRadius: string) => ({
borderBottomLeftRadius: borderRadius,
borderBottomRightRadius: borderRadius,
});
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm on the fence about these functions, since they seem to only give borderRadius two additional names without any modifications. It seems like it might be adding some unnecessary complexity, since borderRadius could be used in place of these to the same effect.

Copy link
Contributor Author

@michaeljaltamirano michaeljaltamirano Sep 17, 2020

Choose a reason for hiding this comment

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

Edit: misread this message the first time around. See follow-up, anyhow.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ZeMunchkin Opted to just remove the helpers entirely in ac26593 🙂

@snags88 snags88 temporarily deployed to curology-radiance-pr-371 September 17, 2020 17:35 Inactive
@snags88 snags88 temporarily deployed to curology-radiance-pr-371 September 17, 2020 17:38 Inactive
@snags88 snags88 temporarily deployed to curology-radiance-pr-371 September 17, 2020 17:40 Inactive
@snags88 snags88 temporarily deployed to curology-radiance-pr-371 September 17, 2020 17:42 Inactive
@michaeljaltamirano michaeljaltamirano changed the title [Accordion] Add Grouping Static Component + Update Styling [Accordion] Update Accordion.Container-based Styling Sep 17, 2020
@michaeljaltamirano
Copy link
Contributor Author

Need to refactor the styling since the box-shadows are not applying accurately anymore in TitleWrapper.

@snags88 snags88 temporarily deployed to curology-radiance-pr-371 September 17, 2020 18:58 Inactive
Copy link
Contributor

@ZeMunchkin ZeMunchkin left a comment

Choose a reason for hiding this comment

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

LGTM! 🎊

@michaeljaltamirano michaeljaltamirano merged commit 6ccce19 into master Sep 18, 2020
@michaeljaltamirano michaeljaltamirano deleted the accordion/styling branch September 18, 2020 15:43
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.

5 participants