-
Notifications
You must be signed in to change notification settings - Fork 34
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
Styling ModeButton title when component is selected #92
Styling ModeButton title when component is selected #92
Conversation
@@ -50,6 +50,10 @@ const TriMetStyled = styled.div` | |||
padding: 4px 0px 0px; | |||
font-size: 10px; | |||
line-height: 12px; | |||
|
|||
&.active { |
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.
We should not use classes like this with styled-components. Instead, the styled component should provide dynamic values based on the props that are sent. So this should be rewritten as:
text-decoration: ${props => props.selected && 'underline'}
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.
Fair point. Except that props refers to the top-level styled component, in which case is SettingsSelectorPanel, and props contains the props of that component only.
@@ -36,7 +36,10 @@ const ModeButton = props => { | |||
</Styled.ModeButton.Button> | |||
|
|||
{title && showTitle && ( | |||
<Styled.ModeButton.Title className={disabledClassName} title={title}> | |||
<Styled.ModeButton.Title | |||
className={`${activeClassName} ${disabledClassName}`} |
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.
We should not use classes like this with styled-components. Instead, the styled component should provide dynamic values based on the props that are sent. So this should be rewritten as:
<Styled.ModeButton.Title
selected={selected}
title={title}
>
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.
Please refactor to not generate classnames like this with styled-components.
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.
Nevermind. I'm approving for now. I still think this could be done a little better, but in order to get the styling to work in otp-react-redux I do think this "hack" is needed.
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.
Looks good. Ship it.
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.
Good. (npx lerna changed is giving some strange results ... it compares the #92 tree with v17, not currently released v18 ... might be me).
This is a minor PR to allow the title of ModeButton to have a different style when the button is selected, as illustrated in the screenshot below.