-
Notifications
You must be signed in to change notification settings - Fork 155
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
React #1888
React #1888
Conversation
…t-button-foundation
with the latest commit e27d41d
*This hook can be reused for components that just needs to bind current theme to more complicated styling configuration. One can write out all possible styling into global css space, but i think encapsulate the logic within the component makes things more maintainable. While css space should use sparingly with base colours and/or default values. |
I feel like you're overcomplicating things a bit when it comes to colouring which ends up giving the button too much responsibility. The button shouldn't be aware of what theme it's being displayed in. That responsibility should be on the colour variables we set at the root. I also feel like your approach to changing colours isn't particularly clean either. I'd suggest you try to use classes for alternative colours like you're doing with other things already. |
Thank you honestly, I definitely overcomplicated it 😅 😅 . Without going too far why, I basically made some mistake and misunderstood something with postcss that left me producing some unsatisfactory code which went against DRY principles. So, I went for an alternative to encapsulate the logic in the component which felt reasonable coming from someone whom used a lot of css-in-js. But anyways, upon backtracking of my stumbles, I did solved my misunderstanding - and I've converted most of the JS code to module.css |
src/components/Button/index.tsx
Outdated
export enum HoverBehaviour { | ||
LIGHTEN = 'bg-lighten', | ||
DARKEN = 'bg-darken', | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't doubt that we actually have both these behaviors throughout the site, but I wonder if we should unify on one or the other for consistency? 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for taking the time to review. Yep, we can continue to tailor them down.
I design them with the intention to bring more headroom for some ordered customizability. The idea was to always use default/fallback values as means to maintain consistency i.e. omitted hoverBehaviour prop will default to 'bg-darken'. Like any optional props here, they are customizable that should be used situationally when needed .
😅 tho I agree nonetheless, I think more nuance customization do come with more understanding and responsibility to use appropriately. hover-behaviour may just be too much, so yes, unify on one. I'll declutter it, and keep our core options, i.e. size/color/padding/etc. Better to expand accordingly as opposed to over-preparing .
color: var(--LIGHT, var(--darken-100)) var(--DARK, var(--lighten-100)) | ||
var(--OLED, var(--lighten-100)); | ||
background-color: var(--LIGHT, var(--translucent-5)) var(--DARK, var(--translucent-5)) | ||
var(--OLED, var(--translucent-25)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there some way we can eliminate this conditional logic from the button stylesheet? Ideally components should not have to think about themes, they should just reference logical variables (not color variables) from the theme stylesheet, to keep the theming all in one place
If you remove the bg-darken
and bg-lighten
that might make it easier 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, removing bg-darken/lighten property will make it easier to rid of those conditional logic, tho they can be moved to global stylesheet as well. But i will follow thru with the first review, remove them.
--safe-purple: #8548a8; | ||
--safe-grey: #727272; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is meant by "safe" in this context?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the "safe" keyword are colours I checked were safe to use against white/dark backgrounds, since I was reusing the colour palette already defined. I didn't want to alter those colours nor add new ones in case they were important. Thus I added two new colours, both deviated slightly for better readability.
currently they should be the same value across all three themes, and it works well. but if needed extra contrast - one can always alter to liking. the original palette for the two specific colours just didn't do it for buttons. especially for something like borderless/outline variants.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That makes a lot of sense. I have been noticing a lot of cracks in the current color palette approach and thinking of maybe copying what github does and having a set of numbered shades (1-7) for each color. For now this safe thing works and we can clean it up when we figure out a better palette system 😅
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry for the delay, I had a bunch of stuff come up at my day job. Couple points I'd like to address before we merge still, but this is legitimately one of the best PRs I've ever seen 😍
--lighten-100: var(--button-lighten-safe-grey-100); | ||
--lighten-200: var(--button-lighten-safe-grey-200); | ||
--darken-100: var(--button-darken-safe-grey-100); | ||
--darken-200: var(--button-darken-safe-grey-200); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think my biggest remaining question is if -100
and -200
are the best naming scheme, since they don't really say what the colors are for. In fact, I don't fully grasp what they're for. Looks like active and hover states? Would -hover
and -active
work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mhm, yeah good suggestion. i've changed the variable names to -hover and -active, for a better association and clarity. I forgotten, but now I also removed the 'darken' variables, since the last request for better uniformity.
…mments for clarity
Small contribution to button component for better UI/UX and development [#1879].
Goals:
Changes proposed in this pull request:
File notes
/cc @NuckChorris @Reinachan