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

Document <Spinner /> <Button /> <Icon /> #196

Merged
merged 6 commits into from
Sep 29, 2017
Merged

Conversation

ptbrowne
Copy link
Contributor

@ptbrowne ptbrowne commented Sep 27, 2017

Visible on https://ptbrowne.github.io/cozy-ui/react/

Edited: changed the url to show the result on my repo.

@ptbrowne ptbrowne force-pushed the doc-spinner-buttons-icons branch 2 times, most recently from 2734cd8 to 0243891 Compare September 27, 2017 18:15
@enguerran
Copy link
Contributor

I cannot see anything on the link you give

@enguerran
Copy link
Contributor

You create a branch on the cozy repository, is that wanted? Why not a fork?
https://github.com/cozy/cozy-ui/tree/doc-spinner-buttons-icons

Copy link
Contributor

@enguerran enguerran left a comment

Choose a reason for hiding this comment

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

Too many unexplained changes on the configuration. Need more details to be approved.

@@ -1,8 +1,11 @@
const path = require('path')

module.exports = {
components: path.resolve(__dirname, '../react/{Button,Toggle}/*.{js,jsx}'),
components: path.resolve(__dirname, '../react/{Spinner,Icon,Button,Toggle}/*.{js,jsx}'),
Copy link
Contributor

Choose a reason for hiding this comment

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

We shall not list components here, if we have 30 000 components, we could not list them anymore, could we?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Exactly what I was talking about here : #180 (review)

I am doing the change

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

@@ -33,5 +34,14 @@ module.exports = {
}
]
},
plugins: [new ExtractTextPlugin('[name].css')]
plugins: [
new webpack.LoaderOptionsPlugin({
Copy link
Contributor

Choose a reason for hiding this comment

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

What is the utility to use LoaderOptionsPlugin if we can set an option in the loader itself?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, good catch, done !

webpackConfig: require('./webpack.config.js'),
serverPort: 6161,
styleguideDir: path.resolve(__dirname, '../build/react')
styleguideDir: path.resolve(__dirname, '../build/react'),
require: [
Copy link
Contributor

Choose a reason for hiding this comment

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

Cannot fund any documentation about require in webpack.
What is used for?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@@ -1,8 +1,10 @@
import React from 'react'
import React, { PropTypes as Types } from 'react'
Copy link
Contributor

Choose a reason for hiding this comment

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

https://facebook.github.io/react/docs/typechecking-with-proptypes.html

React.PropTypes has moved into a different package since React v15.5. Please use the prop-types library instead.

Unless it's added with preact-compat. But I think to be more reliable, we should depend on the real proptypes module.

On the other hand, I cannot understand why you alias the import.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

On the other hand, I cannot understand why you alias the import.

Oh I'm sure you can :D : it is to type les characters. It is fairly common : https://github.com/search?utf8=%E2%9C%93&q=%22PropTypes+as+Types%22&type=Code

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What do you mean by to be more reliable ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

preact-compat is using the prop-types module under the hood 👌 https://github.com/developit/preact-compat/blob/master/package.json#L87

Copy link
Contributor

Choose a reason for hiding this comment

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

We are using preact but to stay more reliable on react, we also use preact-compat.
For instance preact let us declare the render function with props as parameters, react doesn't. So we usen't.

The same goes to PropTypes, since react 15.5, PropTypes has moved to a different package.

If you look at the import part of both below codesandbox, you'll understand:

On the other hand, both works with import PropTypes from "prop-types".

In any event, both used the exact same release of prop-types.

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

@ptbrowne ptbrowne force-pushed the doc-spinner-buttons-icons branch 2 times, most recently from 8673e6a to 8aaece6 Compare September 29, 2017 13:58
@ptbrowne
Copy link
Contributor Author

I cannot see anything on the link you give

True it was a bad idea to push directly on the gh-pages of the cozy/cozy-ui repository. I forked and pushed on my own branch: https://ptbrowne.github.io/cozy-ui/react/.

You create a branch on the cozy repository, is that wanted? Why not a fork?

Because it is tad more complex to manage the fork. Is it a problem if I push on cozy/cozy-ui ?

Copy link
Contributor

@enguerran enguerran left a comment

Choose a reason for hiding this comment

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

Some remarks.

<div style={{ background: '#ccc'}}>{Object.keys(icons).map(icon => <span>
{ icon } : <Icon icon={ icon } color={ colors[i++] } /><br/>
</span>) }</div>
```
Copy link
Contributor

Choose a reason for hiding this comment

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

Two problems here:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

paperplane icon missing

Bug from the icon, not from the docs

only the first 4 icons

Thanks, good catch ><

<div style={{ background: '#ccc'}}>{Object.keys(icons).map(icon => <span>
{ icon } : <Icon icon={ icon } color={ colors[i++] } /><br/>
</span>) }</div>
```
Copy link
Contributor

Choose a reason for hiding this comment

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

const icons = require('../../src/icons');
const colors = ['red', 'blue', 'yellow', 'green']
let i = 0;

<div style={{ background: '#ccc'}}>
  {Object.keys(icons).map(
    icon => (
      <span>{ icon } : <Icon icon={ icon } color={ colors[i++%colors.length] } /><br/></span>
    )
  )}
</div>

See https://codesandbox.io/s/7y0oz2m3v0

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good catch !

<div style={{ background: '#ccc'}}>{Object.keys(icons).map(icon => <span>
{ icon } : <Icon icon={ icon } color={ colors[i++] } /><br/>
</span>) }</div>
```
Copy link
Contributor

Choose a reason for hiding this comment

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

Beware of the code sample, it lacks a closing parenthesis in the map function.
And format the code as it could be more readable.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no parenthesis lacking here


import myIcon from 'my-icon.svg'

<Icon icon={ myIcon } width='2rem' height='2rem' color='purple' />
Copy link
Contributor

Choose a reason for hiding this comment

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

It ain't no purple.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

What do you mean it ain't no purple ? Are you testing with an icon with a fill property ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh, I though the icon was the ⚠️
I did not read the doc that explains we need to use svg-sprite-loader.

Icon.propTypes = {
icon: React.PropTypes.string.isRequired
icon: Types.oneOfType([Types.string, Types.object]).isRequired
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks i added the properties. I presume you use this eslint configuration in your editor ? The lint command of cozy-ui only uses standard js, maybe you can add eslint ?

white: <Spinner color='white' />
red: <Spinner color='red' />
</div>
```
Copy link
Contributor

Choose a reason for hiding this comment

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

I cannot see colored spinner, look at the screenshot below:

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 is a bug from the Spinner

Copy link
Contributor Author

Choose a reason for hiding this comment

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

<div>
<Spinner noMargin={ true }/>
</div>
```
Copy link
Contributor

Choose a reason for hiding this comment

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

I see no difference with noMargin={true}, see below:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Bug from the spinner

Copy link
Contributor Author

Choose a reason for hiding this comment

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

xlarge: <Spinner size='xlarge' /><br/>
xxlarge: <Spinner size='xxlarge' />
</div>
```
Copy link
Contributor

Choose a reason for hiding this comment

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

tiny, small and medium are the exact same size, see:

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Bug from the spinner

Copy link
Contributor Author

Choose a reason for hiding this comment

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


```jsx static
<Spinner loadingType='salut' />
```
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't want cozy-ui to be dependent on <I18n />.
But maybe, I am alone on this idea.

So please, consider this comment as a non blocking one, we should update later.

By the way, could you find a way to perform a running demo, maybe you can pass through a props like t={word => word}.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

IMHO, this is not a problem of the docs.

Copy link
Contributor

Choose a reason for hiding this comment

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

It allows to display a running demo.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You cannot pass a t like that since it is wrapped into translate. translate overwrites the t property with the t attribute from the context.

image

image

@ptbrowne ptbrowne mentioned this pull request Sep 29, 2017
3 tasks
Copy link
Contributor

@enguerran enguerran left a comment

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 fix <Spinner /> within the same Pull Request. I don't know.

Ok, for the other changes.

@enguerran
Copy link
Contributor

Even if we can improve the demo by fixing <Spinner /> and by adding more running demos, I see no other blocking things for this Pull-Request.

@ptbrowne ptbrowne merged commit 962318e into master Sep 29, 2017
@ptbrowne
Copy link
Contributor Author

Thanks for the thorough review !

@kosssi kosssi deleted the doc-spinner-buttons-icons branch September 29, 2017 16:06
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.

None yet

2 participants