Skip to content
This repository has been archived by the owner on Oct 6, 2020. It is now read-only.

feat(Text): New Text component; upgrade to styled-system@v5 #79

Merged
merged 8 commits into from
Sep 16, 2019

Conversation

kylealwyn
Copy link
Contributor

@kylealwyn kylealwyn commented Sep 15, 2019

Summary

New <Text /> component

  • <Text as="h1" fontSize={100} color="primaryLight" />
  • Should allow us to remove many of our one-off styled components, which are typically used only to style some text

Upgrade styled-system

  • Better performance for foundational components like Box and Flex with compose
  • Better support for responsive styles, e.g. <Box m={{ _: 0, sm: 12 }} />, which says for all screens, apply 0 margin, and for small screens and up, apply a 12px margin

Clean up theme.js

  • Better organization
  • Remove grid nesting
  • Add 24px to space scale
  • Allow breakpoints to be overridden

Clean up <Column />

  • Remove order style so styled-system can apply order responsively, e.g. <Column order={{ _: -1, sm: 1 }} />
  • Prettier wasn't liking some of the implicit ternary returns

Fix Dropdown stories

  • Storybook was not liking hooks in the base story
  • Modal was using old Dropdown syntax

@codecov
Copy link

codecov bot commented Sep 15, 2019

Codecov Report

Merging #79 into v5 will increase coverage by 0.22%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##               v5      #79      +/-   ##
==========================================
+ Coverage   66.15%   66.37%   +0.22%     
==========================================
  Files          20       21       +1     
  Lines         458      461       +3     
  Branches       92       93       +1     
==========================================
+ Hits          303      306       +3     
  Misses        124      124              
  Partials       31       31
Impacted Files Coverage Δ
src/Box/Box.js 100% <ø> (ø) ⬆️
src/Text/Text.js 100% <100%> (ø)
src/theme.js 100% <100%> (ø) ⬆️
src/Badge/Badge.js 100% <100%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 96bebb9...becbbc7. Read the comment docs.

Copy link
Contributor

@mathewmorris mathewmorris left a comment

Choose a reason for hiding this comment

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

This looks really clean. Huge fan of this update.

Copy link
Contributor

@cehsu cehsu left a comment

Choose a reason for hiding this comment

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

LGTM, once the simple merge conflict is resolved.

@@ -41,12 +42,12 @@
"react-popper": "^1.3.3",
"react-portal": "^4.2.0",
"react-transition-group": "^2.5.3",
"styled-system": "^3.2.1"
"styled-components": "^4.0.0",
Copy link
Contributor

Choose a reason for hiding this comment

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

Why did we downgrade styled-components?

@@ -15,11 +16,18 @@ export default {
format: 'es',
},
],
external: [...Object.keys(pkg.dependencies || {}), ...Object.keys(pkg.peerDependencies || {})],
external: [
...Object.keys(pkg.dependencies || {}).filter(dep => dep !== 'styled-components'),
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be worthwhile to add a comment about why we're doing this?

@@ -29,10 +30,11 @@ const StyledAlert = createComponent({
});

/** Alerts are typically used to display meaningful copy to users - typically notifying the user of an important message. */
const Alert = props => <StyledAlert {...props} />;
const Alert = React.forwardRef((props, ref) => <StyledAlert {...props} ref={ref} />);
Copy link
Contributor

Choose a reason for hiding this comment

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

🙏

@@ -22,11 +23,12 @@ const StyledBadge = createComponent({
},
});

const Badge = props => <StyledBadge {...props} />;
const Badge = React.forwardRef((props, ref) => <StyledBadge {...props} ref={ref} />);
Copy link
Contributor

Choose a reason for hiding this comment

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

🙏


Alert.propTypes = {
variant: PropTypes.string,
...propTypes.space,
Copy link
Contributor

Choose a reason for hiding this comment

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

😎

space,
color,
typography
),
Copy link
Contributor

Choose a reason for hiding this comment

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

So slick 😎


test('"color" prop', () => {
const { asFragment } = renderWithTheme(<Text color="red">Hey!</Text>);
expect(asFragment()).toMatchSnapshot();
Copy link
Contributor

Choose a reason for hiding this comment

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

While we're at it, should we add a space prop test as well?

<>
<Text>The basic text component renders as a {'<span />'}</Text>
<Text as="h1">It can render as other tags, like this {'<H1/>'}</Text>
<Text color="red">It can use colors from the theme</Text>
Copy link
Contributor

Choose a reason for hiding this comment

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

Similar to above, should we add a spacing prop case while we're going to the trouble to illustrate these props, or is it similar enough to the existing spacing props on other components, that there's no need for the additional explanation?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The latter

@@ -27,16 +27,10 @@ export default class ModalDropdownDemo extends React.Component {
return (
<div>
<Dropdown placement="top" width={250} trigger={<Button variant="success">Open Dropdown</Button>}>
<Dropdown.Header title="Dropdown" />
Copy link
Contributor

Choose a reason for hiding this comment

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

No more need for the multi section dropdown? Do we want to use the divider here? I think we had added the dropdown to facilitate keyboard accessibility testing.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

wut

${getColumnWidth(props[breakpoint], theme.gridColumns)};
${props[`${breakpoint}Offset`] !== undefined && getOffset(props[`${breakpoint}Offset`], theme.gridColumns)};
}
`;
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we use breakpoint aliases to generate these media queries?

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'd rather not touch the implementation in this PR

@kylealwyn kylealwyn merged commit 82c8b32 into v5 Sep 16, 2019
@kylealwyn kylealwyn deleted the text-component branch September 16, 2019 19:06
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants