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

Styling ModeButton title when component is selected #92

Merged

Conversation

binh-dam-ibigroup
Copy link
Collaborator

@binh-dam-ibigroup binh-dam-ibigroup commented Mar 20, 2020

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.

image

@@ -50,6 +50,10 @@ const TriMetStyled = styled.div`
padding: 4px 0px 0px;
font-size: 10px;
line-height: 12px;

&.active {
Copy link
Contributor

@evansiroky evansiroky Mar 20, 2020

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'}

Copy link
Collaborator Author

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}`}
Copy link
Contributor

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}
>

Copy link
Contributor

@evansiroky evansiroky left a 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.

Copy link
Contributor

@evansiroky evansiroky left a 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.

Copy link
Member

@fpurcell fpurcell left a 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.

@fpurcell fpurcell self-requested a review March 23, 2020 18:38
Copy link
Member

@fpurcell fpurcell left a 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).

@fpurcell fpurcell merged commit e2c7321 into opentripplanner:master Mar 23, 2020
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

Successfully merging this pull request may close these issues.

3 participants