Skip to content
This repository has been archived by the owner on Nov 10, 2017. It is now read-only.

Added a datetime knob #26

Merged
merged 13 commits into from
Sep 19, 2016
Merged

Added a datetime knob #26

merged 13 commits into from
Sep 19, 2016

Conversation

madushan1000
Copy link
Contributor

@madushan1000 madushan1000 commented Sep 15, 2016

Datetime knob to test react components taking Date objects or timestamps as props.
To use, import date from storybook-addon-knobs and use as date('<name>', <default value>)

@arunoda
Copy link
Contributor

arunoda commented Sep 15, 2016

Do npm test and fix common issues.

};

DateType.deserialize = function (value) {
return value;
Copy link
Contributor

Choose a reason for hiding this comment

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

Don't we need to parseFloat here.

@@ -27,6 +27,11 @@ export function select(name, options, value) {
return manager.knob(name, { type: 'select', options, value });
}

export function date(name, value) {
const r = manager.knob(name, { type: "date", value: value.toISOString() });
Copy link
Contributor

Choose a reason for hiding this comment

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

I like to use a timestamp here. It's more generic in JS and smaller.
I think you need to change several places.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@@ -11,6 +11,8 @@ require('babel-polyfill');
var jsdom = require('jsdom').jsdom;

var exposedProperties = ['window', 'navigator', 'document'];
var fileExts = ['jpg', 'png', 'gif', 'eot', 'svg', 'ttf', 'woff', 'woff2'];
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this is because we included css.
So, just add a single entry for just handling .css

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Contributor

Choose a reason for hiding this comment

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

Great. Thanks.

@madushan1000 madushan1000 changed the title Added a date knob Added a datetime knob Sep 15, 2016
Copy link
Contributor

@arunoda arunoda left a comment

Choose a reason for hiding this comment

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

Add some comments regarding the CSS loading system.
Try to apply these requests.

@@ -0,0 +1,217 @@
.rdt {
Copy link
Contributor

@arunoda arunoda Sep 19, 2016

Choose a reason for hiding this comment

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

It's pretty hard to load CSS specific to our manager's code at Storybook.
So, we need to think something else.

Here's something we can do.
See this library: https://github.com/substack/insert-css

We need to write this file as a .js file which returns a big string of CSS.
Then we can simply use above library to apply CSS.

@@ -30,4 +30,8 @@ process.on('unhandledRejection', function (error) {
console.error(error && error.stack || error);
});

require.extensions[`.css`] = function () {
Copy link
Contributor

Choose a reason for hiding this comment

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

Once we added new CSS loading system. We don't need this.

@@ -53,6 +53,8 @@
"dependencies": {
"babel-runtime": "^6.5.0",
"deep-equal": "^1.0.1",
"moment": "^2.15.0",
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be a devDependancy as we only use this on the example.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

moment is a peer dependency of the react component I'm using. How should I handle that?

Copy link
Contributor

Choose a reason for hiding this comment

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

Okay. If so, this is good.

@@ -0,0 +1,32 @@
import React from 'react';
import Datetime from 'react-datetime';
import './Date.css';
Copy link
Contributor

@arunoda arunoda Sep 19, 2016

Choose a reason for hiding this comment

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

Import the JS string of CSS here and use insert-css NPM module to load CSS.
If I doesn't work, try to do that in DOMContentLoaded event.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's working properly now

@arunoda arunoda merged commit 35fec84 into master Sep 19, 2016
@arunoda arunoda deleted the date-knob branch September 19, 2016 08:53
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants