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

Refactor addon-action to use glamorous #2275

Merged
merged 12 commits into from
Feb 20, 2018
Merged

Refactor addon-action to use glamorous #2275

merged 12 commits into from
Feb 20, 2018

Conversation

armandabric
Copy link
Contributor

@armandabric armandabric commented Nov 9, 2017

Hey storybookers,

This PR is related to #2263

This commit convert the Action addon to glamourous and extract the button as a shared component.

I don't known how you want to process:

  • Convert one addons at the time to glamourous and after extract what should be shared
  • Convert one addons at the time to glamourous and extract what should be shared at the same time
  • Convert all addons in the same move and extract what should be shared at the same time

This is my first PR in storybook so I'm probably forgetting somethings ;)

@armandabric armandabric changed the title Create a collection of reusable base element [WIP] Create a collection of reusable base element Nov 9, 2017
@Hypnosphi
Copy link
Member

Hypnosphi commented Nov 9, 2017

I'd prefer this:
Extract one or two components at the time, move them to lib/components and convert to glamourous. Then use elsewhere (in separate PRs maybe)

@@ -0,0 +1,10 @@
import glamorous from 'glamorous';

export default glamorous.button({
Copy link
Member

Choose a reason for hiding this comment

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

Let's set type="button" here. By default buttons are type="submit", but it's never what we actually want.

With glamorous, you can do it like that:

glamorous.button({
  <styles>
}).withProps({ type: 'button' })

@Hypnosphi
Copy link
Member

Please run yarn jest -u to update test snapshot

@armandabric
Copy link
Contributor Author

armandabric commented Nov 9, 2017

I have update the snapshot, but I do not know my classnames hashes have not the same that the one generated on the CI 😕

@Hypnosphi
Copy link
Member

That's a bit weird. Please try to run yarn bootstrap --reset --core (this will remove all the gitignored directories like node_modules and reinstall everything from scratch), and update snapshots again

@armandabric
Copy link
Contributor Author

armandabric commented Nov 9, 2017

I've run:

$ yarn bootstrap --reset --core
$ yarn jest -u

My snapshots are still the same 😕

@Hypnosphi
Copy link
Member

What does git status output for you?

@armandabric
Copy link
Contributor Author

That all my change have been commited:

$ git status
On branch qa/extract-guidelines
nothing to commit, working tree clean

I'm on slack if you want to give me a hand directly ✋

padding: '5px 10px',
borderRadius: '4px',
color: 'rgba(0, 0, 0, 0.5)',
outline: 'none',
Copy link
Member

@Hypnosphi Hypnosphi Nov 9, 2017

Choose a reason for hiding this comment

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

Let's either not remove it in a generic button, or provide something instead, using ':focus': {...styles}

Copy link
Member

Choose a reason for hiding this comment

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

We could add some :hover and :active states as well

@Hypnosphi Hypnosphi changed the base branch from master to release/3.3 November 9, 2017 21:38
@Hypnosphi
Copy link
Member

@ndelangen are you familiar with how glamor classNames are generated? Why can it be, for example, css-1fqbdip for me and CI, and css-glamorous-article for @Spy-Seth ?

@ndelangen
Copy link
Member

I've never experienced this.. Maybe NODE_ENV? Maybe we can ask @kentcdodds

Looks like one of the 2 is optimized and the other isn't.
I can't find any documentation on this on https://glamorous.rocks/advanced#optimizing-bundle-size

This is what I found:
https://github.com/threepointone/glamor#speedy-mode

@kentcdodds
Copy link
Contributor

Yes, glamor will apply the label (which is the displayName of the component) if NODE_ENV !== 'production' so that's possibly the problem.

@codecov
Copy link

codecov bot commented Nov 11, 2017

Codecov Report

Merging #2275 into master will increase coverage by 0.06%.
The diff coverage is 94.11%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2275      +/-   ##
==========================================
+ Coverage   37.48%   37.54%   +0.06%     
==========================================
  Files         434      428       -6     
  Lines        9389     9176     -213     
  Branches      908      890      -18     
==========================================
- Hits         3519     3445      -74     
+ Misses       5301     5192     -109     
+ Partials      569      539      -30
Impacted Files Coverage Δ
.../ui/src/modules/ui/components/addon_panel/style.js 0% <ø> (ø) ⬆️
lib/components/src/index.js 0% <0%> (ø) ⬆️
lib/components/src/form/button.stories.js 100% <100%> (ø)
lib/components/src/navigation/menu_link.stories.js 100% <100%> (ø) ⬆️
...b/components/src/navigation/routed_link.stories.js 100% <100%> (ø) ⬆️
...ddons/actions/src/components/ActionLogger/style.js 100% <100%> (ø) ⬆️
lib/components/src/form/button.js 100% <100%> (ø)
...ddons/actions/src/components/ActionLogger/index.js 73.68% <80%> (-0.68%) ⬇️
app/react/src/server/utils.js 0% <0%> (-100%) ⬇️
addons/notes/src/index.js 0% <0%> (-61.54%) ⬇️
... and 101 more

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 0a0fc1b...f87336c. Read the comment docs.

# Conflicts:
#	addons/actions/package.json
#	examples/cra-kitchen-sink/src/stories/__snapshots__/addon-info.stories.storyshot
#	lib/components/src/index.js
background: 'rgba(255, 255, 255, 0.5)',
padding: '5px 10px',
borderRadius: '4px',
color: 'rgba(0, 0, 0, 0.5)',
Copy link
Member

Choose a reason for hiding this comment

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

It looks disabled to me as it is now:
screen shot 2017-11-11 at 03 54 08

.button({
border: 'solid 1px rgba(0, 0, 0, 0.2)',
background: 'rgba(255, 255, 255, 0.5)',
padding: '5px 10px',
Copy link
Member

Choose a reason for hiding this comment

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

Let's add some more padding at the bottom, so that the text is vertically centered by lowercase letters. 4px 10px 7px seems to be enough:
screen shot 2017-11-11 at 03 59 28

@ndelangen
Copy link
Member

Thanks for the assistance @kentcdodds! 👏

@Spy-Seth can you try finding out why it would appear your node is in production mode when running tests?

@armandabric
Copy link
Contributor Author

armandabric commented Nov 13, 2017

It seems that @kentcdodds have made the good guess 👍

$ printenv NODE_ENV
development

If I set it to testing the generated hashes are optimized again 🎉 I will upgrade the PR with the good one. (EDIT: it seems that @Hypnosphi already did it!)

@ndelangen: Now I'm able to take some times in the next days to apply the @Hypnosphi comments.

Thanks everyone for you're help 👍

@Hypnosphi
Copy link
Member

If I set it to testing

Actually, it should rather be test (this is what jest sets by default when there's no such variable)

@ndelangen ndelangen changed the base branch from release/3.3 to master December 23, 2017 22:57
@ndelangen
Copy link
Member

@Spy-Seth anything you need to continue?

@armandabric
Copy link
Contributor Author

Yeah: times 😅 Like all of us

I was stuck on a live reload issue with the monorepo. I could not exactly remember the details sorry. I will have some time in the beginning of 2018. I will try to get back on it but I could not guaranty it. If someone want to take it and finish the move it's fine for me 👍

@Hypnosphi
Copy link
Member

OK I think I'll pick it

@Hypnosphi Hypnosphi added the maintenance User-facing maintenance tasks label Feb 17, 2018
# Conflicts:
#	addons/actions/package.json
#	examples/cra-kitchen-sink/src/stories/__snapshots__/storybook-components.stories.storyshot
#	examples/cra-kitchen-sink/src/stories/storybook-components.stories.js
@Hypnosphi Hypnosphi added cleanup Minor cleanup style change that won't show up in release changelog and removed in progress labels Feb 17, 2018
@Hypnosphi Hypnosphi changed the title [WIP] Create a collection of reusable base element Refactor addon-action to use glamorous Feb 17, 2018
@Hypnosphi Hypnosphi requested a review from a team February 17, 2018 15:36
@Hypnosphi
Copy link
Member

Ready for review

Hypnosphi
Hypnosphi previously approved these changes Feb 17, 2018
@Hypnosphi Hypnosphi requested a review from a team February 17, 2018 15:37
@Hypnosphi Hypnosphi merged commit 3edc7d1 into storybookjs:master Feb 20, 2018
@armandabric armandabric deleted the qa/extract-guidelines branch February 23, 2018 11:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
addon: actions cleanup Minor cleanup style change that won't show up in release changelog components feature request maintenance User-facing maintenance tasks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants