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

Refactoring text component #769

Closed
wants to merge 7 commits into from
Closed

Conversation

caiokf
Copy link
Contributor

@caiokf caiokf commented Nov 14, 2019

Dependent on #743, please merge that one first.

@drydenwilliams
Copy link
Contributor

Awesome Storybook work 👍 just want to make sure there will be no breaking changes with this refactor?

Comment on lines +35 to +136
`
display: 'inline-block';
`}

${props =>
props.txtcenter &&
`
textAlign: 'center';
`}

${props =>
props.txtRight &&
`
textAlign: 'right';
`}

${props =>
props.superSmall &&
`
font-size: ${theme.fontSizes[0]};
`}

${props =>
props.small &&
`
font-size: ${theme.fontSizes[1]};
`}

${props =>
props.medium &&
`
font-size: ${theme.fontSizes[2]};
`}

${props =>
props.large &&
`
font-size: ${theme.fontSizes[3]};
`}

${props =>
props.regular &&
`
font-weight: 400;
`}

${props =>
props.bold &&
`
font-weight: 600;
`}

${props =>
props.uppercase &&
`
text-transform: uppercase;
`}

${props =>
props.capitalize &&
`
text-transform: capitalize;
`}

${props =>
props.tags &&
`
font-size: 12px;
color: ${theme.colors.blue};
`}

${props =>
props.auxiliary &&
`
font-family: "Inter", Helvetica Neue, Arial, sans-serif;
font-size: 12px;
color: #686868;
`}

${props =>
props.paragraph &&
`
font-family: "Inter", Helvetica Neue, Arial, sans-serif;
font-size: 16px;
color: ${theme.colors.grey};
`}

${props =>
props.clipped &&
`
white-space: nowrap;
text-overflow: ellipsis;
overflow: hidden;
`}

${props =>
props.preLine &&
`
white-space: pre-line;
`}
Copy link
Contributor

Choose a reason for hiding this comment

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

Yep that's more clear thanks. I was wondering though if you had an idea to reduce the number of possible props to the text component ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@BenGamma

What we have at the moment:

inline?: boolean
regular?: boolean
txtcenter?: boolean
capitalize?: boolean
bold?: boolean
txtRight?: boolean
large?: boolean
medium?: boolean
small?: boolean
superSmall?: boolean
color?: keyof typeof theme.colors
clipped?: boolean
preLine?: boolean
tags?: boolean
auxiliary?: boolean
paragraph?: boolean

What I think we can reduce it to:

color?: keyof typeof theme.colors
large?: boolean
medium?: boolean
small?: boolean
superSmall?: boolean
align?: string
bold?: boolean
uppercase?: boolean
capitalize?: boolean
clipped?: boolean

Plus, I would have the following separate components for the predefined styles:

ParagraphText
AuxiliaryText
TagsText

Those can simply be export default styled(Text)`color: blah; font-size: bleh;` exported as a different component.

Then we have left inline?: boolean which maybe every Text could be by default, and if needed to be a block element, just wrap it in a div.

What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes props make sense 👍
I like the separate component for ParaphText, AuxiliaryText, TagsText.

How I would see it is in the src/components/Text/index.ts having the Text component exported by default and then have exported const ParaphText, AuxiliaryText, TagsText.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

i will go ahead with that

@caiokf
Copy link
Contributor Author

caiokf commented Nov 17, 2019

@drydenwilliams So far this text refactoring would have no breaking change I assume, since the interface of the component (props, etc) haven't changed. Once I reply to @BenGamma about minimizing the amount of props, that might be something we need to go back and fix all uses of the component.

Awesome Storybook work 👍 just want to make sure there will be no breaking changes with this refactor?

@BenGamma
Copy link
Contributor

@drydenwilliams So far this text refactoring would have no breaking change I assume, since the interface of the component (props, etc) haven't changed. Once I reply to @BenGamma about minimizing the amount of props, that might be something we need to go back and fix all uses of the component.

Awesome Storybook work 👍 just want to make sure there will be no breaking changes with this refactor?

Yes that would require a little bit of refactoring and UI check, but should be ok 🙆‍♂

@caiokf caiokf force-pushed the refactoring-text-component branch from b11307a to 9d15560 Compare November 18, 2019 10:34
@ONEARMY ONEARMY deleted a comment from cypress bot Nov 18, 2019
@cypress
Copy link

cypress bot commented Nov 18, 2019



Test summary

30 0 10 0


Run details

Project onearmy-community-platform
Status Passed
Commit 5f51ecb
Started Nov 20, 2019 12:06 PM
Ended Nov 20, 2019 12:14 PM
Duration 08:10 💡
OS Linux Ubuntu Linux - 14.04
Browser Electron 73

View run in Cypress Dashboard ➡️


This comment has been generated by cypress-bot as a result of this project's GitHub integration settings. You can manage this integration in this project's settings in the Cypress Dashboard

@BenGamma
Copy link
Contributor

@caiokf I pushed some minor changes to be able to compile on yarn start.
Should I merge now or you'll do the changes we mentioned in comments on the same branch ?

@chrismclarke
Copy link
Member

As this is now quite old (not sure whether overlooked, in which case apologies, or there were issues) and has conflicts I'm going to close here, but feel free to re-open if still relevant and resolved

@chrismclarke chrismclarke deleted the refactoring-text-component branch January 24, 2021 21:17
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.

4 participants