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

Récupérer facilement les couleurs #188

Closed
kosssi opened this issue Sep 20, 2017 · 9 comments
Closed

Récupérer facilement les couleurs #188

kosssi opened this issue Sep 20, 2017 · 9 comments
Assignees

Comments

@kosssi
Copy link
Contributor

kosssi commented Sep 20, 2017

Actuellement on ajoute dans chaque projet ses propres variables JS pour les couleurs alors que l'on a un référentiel dans palette.styl.

Nous devrions pouvoir récupérer facilement une variable :

import palette from 'cozy-ui/palette.json'
import { Icon } from 'cozy-ui/react'
<Icon icon='album-add' color={palette['cool-grey']} />

Proposition:

  1. Continuer comme on fait
  2. Créer rapidement des variables dans un fichier JS (du coup duplication des variables js/stylus)
  3. Créer un palette.json avec les variables puis les importer dans stylus et dans un fichier JS
@ptbrowne
Copy link
Contributor

Related : webpack-contrib/stylus-loader#163 (comment)

" Like the old quoted comment, I think its best to use stylus's json function to import variables from a json file that can easily be shared with js and other systems."

palette.styl could use the json function from stylus

http://stylus-lang.com/docs/bifs.html#jsonpath-options

@ptbrowne ptbrowne self-assigned this Sep 20, 2017
@kosssi
Copy link
Contributor Author

kosssi commented Sep 20, 2017

Je vote pour le 3

@gregorylegarec
Copy link
Contributor

Au sein de <Icon />, comment est ensuite gérée cette couleur ?

@ptbrowne
Copy link
Contributor

import palette from 'cozy-ui/palette.json'

<Icon color={ palette['dodger-blue']} />

@y-lohse
Copy link
Contributor

y-lohse commented Sep 20, 2017

De notre côté, on n'utilise pas les couleurs sous forme de variable js à ma connaissance. Ceci dit la solution 3 semble effectivement la plus pertinente.

@GoOz
Copy link
Contributor

GoOz commented Sep 20, 2017

Ah putain, je savais même pas que Stylus traitait du json comme ça. Bref du coup, la 3 me convient très bien.

@CPatchane
Copy link
Contributor

Would it be possible to also expose all palette colors as css variable? It will avoid to do this kind of trick when we don't want to use stylus : https://github.com/cozy/cozy-store/blob/master/src/styles/palette.styl

@kosssi
Copy link
Contributor Author

kosssi commented Sep 20, 2017

@ptbrowne
Copy link
Contributor

@CPatchane : please open another issue for this :) I will do the JSON trick and have a PR soon :)

@goldoraf goldoraf mentioned this issue Sep 27, 2017
ptbrowne added a commit that referenced this issue Nov 29, 2017
✨ feat: have the palette in json so that JS files can load it. fix #188
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants