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

Allow transparency in color knob #2624

Merged
merged 5 commits into from
Jan 3, 2018
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion addons/knobs/src/components/types/Color.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,19 @@ class ColorType extends React.Component {
this.popover = e;
}}
>
<SketchPicker color={knob.value} onChange={color => onChange(color.hex)} />
<SketchPicker
color={knob.value}
onChange={color =>
onChange(`
Copy link
Member

Choose a reason for hiding this comment

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

This code looks nice, but it generates a huge section of noise in the url:

Copy link
Member

Choose a reason for hiding this comment

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

Can you solve this somehow?

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 think this is a formatting issue, since I used a template string and applied prettier to make sure it doesn't exceed the line length (which added newlines). What would you recommend in order to stay within storybook's style guide?

Copy link
Member

Choose a reason for hiding this comment

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

You can ignore the problematic eslint rule for this line.

Copy link
Member

Choose a reason for hiding this comment

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

@Primigenus that's weird, prettier shouldn't insert newlines into text, only into interpolations. And you actually don't have to run it by hand, it runs automatically as precommit hook

rgba(
${color.rgb.r},
${color.rgb.g},
${color.rgb.b},
${color.rgb.a}
)
`)
}
/>
</div>
),
() => null
Expand Down