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

files knob #2860

Merged
merged 10 commits into from
Mar 27, 2018
Merged

files knob #2860

merged 10 commits into from
Mar 27, 2018

Conversation

kn0ll
Copy link
Contributor

@kn0ll kn0ll commented Jan 28, 2018

Issue: my component can accept file input but i can't create a knob for it.

What I did

created a knob for file input.

How to test

i added the knob to the all knobs story. let me know if this is insufficient.


notes: some of these changes break from the pattern of other knobs... with reason...

  1. i added browser: true to .eslintrc.js. this is so it lints FileReader, a global object of window. not trying to impose anything here though. if you'd prefer i lint this another way, like disable linting for those lines, i can do that...

  2. files are passed as Data URLs. i ran into security and serialization issues passing input files between iframes and the only in-scope solution i could come up with... was only parsing files as Data URLs. if the component requires other types, it would have to manage that itself (which kind of sucks-- but at least keeps the knob robust). here is an example wrapper component that could manage this type of deserialization

  3. i set serialize and deserialize to undefined. this is because:
    A. certain files, when serialized to the URL, break on reload (404 or something).
    B. you cannot actually set the value of input type file, and so it serves no purpose anyway.

  4. i was unable to pass tests locally because of master tests not passing #2859... and i am unsure how to clean up the failing checks for this PR... sorry...

thank you all...

@codecov
Copy link

codecov bot commented Jan 28, 2018

Codecov Report

Merging #2860 into master will decrease coverage by 0.09%.
The diff coverage is 18.51%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master    #2860     +/-   ##
=========================================
- Coverage   36.21%   36.12%   -0.1%     
=========================================
  Files         444      445      +1     
  Lines        9736     9775     +39     
  Branches      893      909     +16     
=========================================
+ Hits         3526     3531      +5     
- Misses       5670     5672      +2     
- Partials      540      572     +32
Impacted Files Coverage Δ
addons/knobs/src/angular/index.js 0% <ø> (ø) ⬆️
addons/knobs/src/vue/index.js 24.13% <ø> (ø) ⬆️
addons/knobs/src/index.js 0% <ø> (ø) ⬆️
addons/knobs/src/polymer/index.js 0% <ø> (ø) ⬆️
addons/knobs/src/react/index.js 40% <ø> (ø) ⬆️
addons/knobs/src/components/types/index.js 0% <ø> (ø) ⬆️
addons/knobs/example/stories/index.js 0% <0%> (ø) ⬆️
addons/knobs/src/base.js 11.11% <0%> (-0.66%) ⬇️
addons/knobs/src/components/types/Files.js 14.28% <20.83%> (ø)
app/polymer/src/server/utils.js 0% <0%> (-100%) ⬇️
... and 62 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 4f5d7f9...b57e8e7. Read the comment docs.

@Hypnosphi
Copy link
Member

i added browser: true to .eslintrc.js. this is so it lints FileReader, a global object of window

Please use import {FileReader} from 'global' instead

@@ -20,6 +20,8 @@ stories.add('with all knobs', () => {

const passions = array('Passions', ['Fishing', 'Skiing']);

const images = files('Happy Picture', ['data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAQAAAC1+jfqAAAABGdBTUEAALGPC/xhBQAAACBjSFJNAAB6JgAAgIQAAPoAAACA6AAAdTAAAOpgAAA6mAAAF3CculE8AAAAAmJLR0QA/4ePzL8AAAAHdElNRQfiARwMCyEWcOFPAAAAP0lEQVQoz8WQMQoAIAwDL/7/z3GwghSp4KDZyiUpBMCYUgd8rehtH16/l3XewgU2KAzapjXBbNFaPS6lDMlKB6OiDv3iAH1OAAAAJXRFWHRkYXRlOmNyZWF0ZQAyMDE4LTAxLTI4VDEyOjExOjMzLTA3OjAwlAHQBgAAACV0RVh0ZGF0ZTptb2RpZnkAMjAxOC0wMS0yOFQxMjoxMTozMy0wNzowMOVcaLoAAAAASUVORK5CYII=']);
Copy link
Member

Choose a reason for hiding this comment

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

Please add this example to examples/offisial-storybook instead. addons/*/examples are outdated and probably will be removed. Sorry for the confusion

const FilesType = ({ knob, onChange }) => (
<input
id={knob.name}
type="file"
Copy link
Member

Choose a reason for hiding this comment

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

manager,
} from '../base';

export { knob, text, boolean, number, color, object, array, date, select, button };
export { knob, text, boolean, number, color, object, array, date, select, button, files };
Copy link
Member

Choose a reason for hiding this comment

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

Can it be supported in angular and polymer as well?

@Hypnosphi
Copy link
Member

@kn0ll are you still interested in finishing that? It's OK if you aren't, I'll just pick it up then

@ndelangen
Copy link
Member

@kn0ll This is really useful, let's get this finished and merged!

@Hypnosphi Hypnosphi self-assigned this Feb 23, 2018
@kn0ll
Copy link
Contributor Author

kn0ll commented Feb 26, 2018

sorry i fell out of the loop all. other priorities came up... @Hypnosphi if you've not started i will take it over the finish line today.

@Hypnosphi
Copy link
Member

No I haven't

@Hypnosphi
Copy link
Member

Please resolve conflicts

@Hypnosphi Hypnosphi added this to the v4.0.0 milestone Mar 8, 2018
@Hypnosphi Hypnosphi merged commit 2994fc1 into storybookjs:master Mar 27, 2018
@Hypnosphi
Copy link
Member

Released as 4.0.0-alpha.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants