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

Discovery: Button variants and styled-system PoC #8304

Closed
rcantin-w opened this issue Aug 18, 2022 · 1 comment
Closed

Discovery: Button variants and styled-system PoC #8304

rcantin-w opened this issue Aug 18, 2022 · 1 comment
Assignees

Comments

@rcantin-w
Copy link
Contributor

Because of all the refactoring of the button component going on and new designs (Exhibition Guides, Concepts) suggesting different versions of new buttons, I want to explore how complex/beneficial it would be to start using styled-system on top of styled-components. It allows for variants, which is a simpler way of declaring components in specific styles, hopefully keeping them aligned throughout the platforms instead of allowing for too much flexibility.

I'm exploring this one as I've used it before and it seems to match what are needs are in this moment. As they say:

[...] style functions can be written on a one-off basis, but Styled System is meant to help reduce boilerplate, ensure a consistent styling API, and speed the development of component-based design systems.

This discovery will also ensure it still allows some flexibility when there are edge cases.

@rcantin-w rcantin-w self-assigned this Aug 18, 2022
@rcantin-w
Copy link
Contributor Author

rcantin-w commented Aug 23, 2022

Proof of concept started in the poc-styled-system branch. I just worked with the variant tool styled-system offers, and only did the work on buttons. There, different scales represent main button styles (outline/solid), colour schemes (e.g. white/dark/green) and sizes (small/medium/large). See here for where they are declared in the Button components. And here is where the scales are declared in config.js.

It seems it would be easily changeable to using this library if it is of interest, but for now I want to wait and see where things are headed with the new palette, which will certainly dictate what our new "atom" components will look like and if it's worth switching over.

I personally find it a very readable way of declaring components, whilst insuring their styles are aligned. It is still possible to declare your own styles if you decide you need something other than the available variants, just by using styled-components and declaring custom styles.

In this example, code changed in this way:

Before:

import { themeValues } from [...]

<ButtonSolid
   text="Button copy"
   colors={themeValues.colors.greenTransparentGreen}
   hoverUnderline={true}
   size="small"
/>   

After:

<ButtonSolid
   text="Button copy"
   variant="outline"
   variantColor="green"
   size="small"
/>   

or even, as I made "solid" and "green" defaults (and "medium" for the size) :

<ButtonSolid text="Button copy" variant="outline" size="small" />   

(in this case, hoverUnderline was made true when variant was "outline")

These of course are all suggestions, the way we go ahead with the different scales would depend on our needs.

All in all, It was a promising first array into looking into styled-system, and it would be an interesting avenue to go down when we have a more solid understanding of our new styles.

@rcantin-w rcantin-w moved this from In Progress to Done in Digital platform Aug 23, 2022
@pollecuttn pollecuttn moved this from Done to Archive in Digital platform Sep 2, 2022
Repository owner moved this from Archive to Done in Digital platform Sep 6, 2022
@pollecuttn pollecuttn moved this from Done to Archive in Digital platform Sep 14, 2022
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

No branches or pull requests

2 participants