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

Solidify button appearance combos, document active state #2

Merged
merged 1 commit into from
Jun 3, 2019
Merged

Solidify button appearance combos, document active state #2

merged 1 commit into from
Jun 3, 2019

Conversation

kylesuss
Copy link
Collaborator

@kylesuss kylesuss commented Jun 1, 2019

  • Solidify the button appearances -- you can no longer combine multiple string appearances.
  • Remove unnecessary css calls from within the styled blocks
  • Pull common string constants out to a variable so that they can easily be changed in the future
  • Add PropTypes for the active state. I do not really understand the point of this state though and I would like to add a comment for it for docs mode, so I would like to understand the use case
  • Add stories for active state

--

Over time, I would like to slim up the styles in this component as I think they are a bit hard to follow. It can be hard to tell where certain styles are coming from given there are some duplications in various prop checks and properties. Also, given the styles take up ~300 or so lines, I think there is room to split this out in a way that is a bit easier to track down. It feels like an unnecessary optimization now though, so I believe this would be better served for future work/once it actually becomes a problem.

@@ -1,6 +1,6 @@
{
"name": "@storybook/design-system",
"version": "0.0.10",
"version": "0.0.11",
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I would like to pull this into the learn storybook repo, so I think it needs another release

@@ -1,6 +1,6 @@
import React, { Fragment } from 'react';
import PropTypes from 'prop-types';
import styled, { css } from 'styled-components';
import styled from 'styled-components';
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

As mentioned, these css calls are not necessary in this context

@@ -441,16 +464,17 @@ Button.propTypes = {
Buttons with icons by themselves have a circular shape
*/
containsIcon: PropTypes.bool,
size: PropTypes.oneOf(['small', 'medium']), // this is enum incase we need to add more sizes
size: PropTypes.oneOf(Object.values(SIZES)),
Copy link
Collaborator Author

@kylesuss kylesuss Jun 1, 2019

Choose a reason for hiding this comment

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

Thoughts on this approach? The array of values is not immediately apparent without jumping to the variable definition, though I like that using the variable means that there is only 1 place where the string value needs to be updated. In docs mode, the array of values looks great.

Copy link
Member

Choose a reason for hiding this comment

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

👍

@@ -233,6 +251,7 @@ const ButtonWrapper = styled.button`
&:focus {
box-shadow: ${color.secondary} 0 0 0 3em inset,
${rgba(color.secondary, 0.4)} 0 1px 9px 2px;
color: ${color.lightest};
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

To prevent this in the focus state:

Screen Shot 2019-06-01 at 2 59 21 PM

Now it looks like this:
Screen Shot 2019-06-01 at 2 59 10 PM

})
expect(ExampleComponent).toBeTruthy();
});
});
Copy link
Collaborator Author

@kylesuss kylesuss Jun 1, 2019

Choose a reason for hiding this comment

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

Prettier updates...

@@ -421,6 +443,7 @@ export function Button({
}

Button.propTypes = {
active: PropTypes.bool,
Copy link
Collaborator Author

@kylesuss kylesuss Jun 1, 2019

Choose a reason for hiding this comment

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

I tend to prefer using qualifiers for booleans, like isActive or isUnclickable because I think the cognitive load is lower. It makes it obvious that the value will be true or false without having to look up the docs. That said, I am flexible and think it should be agreed upon as a standard so I didn't update anything -- just calling it out to get the conversation started. Thoughts on the approach for future work?

Copy link
Member

Choose a reason for hiding this comment

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

That approach sgtm!

@kylesuss
Copy link
Collaborator Author

kylesuss commented Jun 1, 2019

@domyen Button updates! Left you a bunch of comments here to get some conversations started. Can you help me out w/ the purpose of the active button state as well? I'd like to get some documentation for it in the PropTypes to be clear about the use case.

@domyen
Copy link
Member

domyen commented Jun 3, 2019

@kylesuss Just tried active, seems like it's no longer used and shares styles with primaryOutline. Go ahead and axe it!

containsIcon={containsIcon}
{...props}
>
<ButtonLink isLoading={isLoading} disabled={isDisabled} {...props}>
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

disabled is always a tricky one w/ regard to the is prefixing -- since the default HTML property is just disabled, I typically pass that to the actual button element so that it can do things naturally, but require the prefix on the React component that wraps it.

@domyen domyen merged commit cdb449f into storybookjs:master Jun 3, 2019
@kylesuss
Copy link
Collaborator Author

kylesuss commented Jun 3, 2019

🚀 PR was released in v0.0.13 🚀

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.

2 participants