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

feat(text): Add styled system { layout } style to Text #96

Merged

Conversation

ChefHutch
Copy link
Contributor

@ChefHutch ChefHutch commented May 7, 2021

Recently, I have needed to restyle the <Text> component to have the display property: inline, for example when piecing together a single piece of text with different styles:

Screenshot 2021-05-07 at 15 21 23

Or, a <Balance> component, preceded by a ~
Screenshot 2021-05-07 at 15 21 39

Both of these examples require a styled component to be initialised, with the required display style.

As per CR feedback - I am passing the styled system { layout } styles to our Text component, allowing us to pass this display style as a prop, rather than needing to declare a styled component.

Breaking changes

  • As size is a reserved styled-system layout prop, I've renamed this for headings to 'scale' - this matches the sizing props pattern used throughout the codebase (Button, Checkbox, Input, Toggle, Progress, Radio, Tag, Toggle)
  • If we are happy with this change, I'll prepare FE & Exchange PRs changing this prop value throughout the codebase.

@RabbitDoge
Copy link
Contributor

I'm not sure it's worth to add a prop for this. And if we really want, use this https://styled-system.com/api#layout

@ChefHutch ChefHutch changed the title feat(text): Add display: inline to Text comp, controlled by prop feat(text): Add styled system { layout } props to Text May 10, 2021
@ChefHutch ChefHutch changed the title feat(text): Add styled system { layout } props to Text feat(text): Add styled system { layout } style to Text May 10, 2021
@@ -1,33 +1,33 @@
import styled from "styled-components";
import Text from "../Text/Text";
import { tags, sizes, HeadingProps } from "./types";
import { tags, scales, HeadingProps } from "./types";
Copy link
Contributor Author

Choose a reason for hiding this comment

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

  • As size is a reserved styled-system layout prop, I've renamed this prop in <Heading> to 'scale' - this matches the sizing props pattern used throughout the codebase (Button, Checkbox, Input, Toggle, Progress, Radio, Tag, Toggle)
  • If we are happy with this change, I'll prepare FE & Exchange PRs changing this prop value throughout the codebase.

@ChefHutch
Copy link
Contributor Author

Yea good point @RabbitDoge. I still think having access to the display style via props will be massively useful, so I've implemented the layout styles. The size short hand introduces a bug with Heading (which I've fixed here, and I think is a slight improvement anyway, but will also need FE/Exchange changes when the uikit version is bumped).

Can I get a re-up on the review?

Copy link
Contributor

@Chef-Cheems Chef-Cheems left a comment

Choose a reason for hiding this comment

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

Seems nice, actually need this functionality too, thanks! 👍

@hachiojidev hachiojidev merged commit 2b619a1 into pancakeswap:master May 11, 2021
@ChefHutch ChefHutch deleted the feature/text-inline-display-prop branch May 11, 2021 12:00
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