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

CSS Structure #32

Closed
mxstbr opened this issue Dec 22, 2015 · 15 comments
Closed

CSS Structure #32

mxstbr opened this issue Dec 22, 2015 · 15 comments
Assignees
Milestone

Comments

@mxstbr
Copy link
Member

mxstbr commented Dec 22, 2015

Thinking of giving the CSS folder structure a slight tweak in v3.0 too. layout and components folder are too similar - when does something become a layout? How big does it have to be?

Maybe take some inspo from http://sassdirector.com/examples/index.html

@mxstbr mxstbr added this to the v3.0 milestone Dec 24, 2015
mxstbr added a commit that referenced this issue Dec 25, 2015
I renamed layout to pages, which is more coherent with the current JS folder structure and won't be ambiguous.

Closes #32
@mxstbr mxstbr self-assigned this Dec 25, 2015
@hampusohlsson
Copy link

Have you considered switching to css modules? With that you can also remove the css folder completely and keep the css and component js in the same directory, which makes a lot of sense.

@mxstbr
Copy link
Member Author

mxstbr commented Dec 27, 2015

@hampusohlsson I have, and while I felt it didn't make sense to include them with the original application structure, if we decide to adopt the ducks approach that's definitely something I'm going to reconsider! (see #27)

@hampusohlsson
Copy link

There are a number of approaches, but in general it feels like having local css on a component level is getting more and more traction and support in the community (either by css modules or js styles using something like Radium). It makes maintainability a lot easier in large apps, as it removes the need to remember difficult naming conventions and rule pollution of the global css scope.

@MoOx
Copy link
Contributor

MoOx commented Dec 29, 2015

css modules (and generally styles near the appropriate js code) make total sense.
css folders are dead :)

@mxstbr
Copy link
Member Author

mxstbr commented Dec 29, 2015

@hampusohlsson @MoOx agreed, read the latest in #27 and check out the v3.0.0 branch, it has a new structure with CSS modules! 👍

@mxstbr
Copy link
Member Author

mxstbr commented Dec 29, 2015

I'm still unsure where to put global CSS rules though, how do you handle that?

@MoOx
Copy link
Contributor

MoOx commented Dec 29, 2015

I avoid global css at all cost. That said, there is still some (even just the css-layout default https://github.com/facebook/css-layout#default-values) that I generally put in the "App" component (the top level component).

@mxstbr
Copy link
Member Author

mxstbr commented Dec 29, 2015

How do you handle variables, hacks (e.g. clearfix),...?

On the v3.0.0 branch I currently have a folder called global that holds those files, but I'm not happy with that solution.

@MoOx
Copy link
Contributor

MoOx commented Dec 29, 2015

I have very few variables that I send directly using https://github.com/postcss/postcss-custom-properties#variables.
I avoid hacks as class and prefer to use them locally (these days we can use flexbox ;))
You should also check out css modules compose feature (I don't use it, but you might find it helpful).

@MoOx
Copy link
Contributor

MoOx commented Dec 29, 2015

For stuff like visually-hidden, maybe you should make a component ;)

@mxstbr
Copy link
Member Author

mxstbr commented Dec 29, 2015

@MoOx ah the component idea actually isn't bad, I like it. Will think about a nice, beginner friendly implementation!

@jessedobbelaere
Copy link

Yeah, global styles is one thing that kept me from using css modules because I thought it wasn't really possible. I'd like to use the same button styles, form input field styling, etc throughout the application. But the compose functionality seems really interesting! See also http://glenmaddern.com/articles/css-modules

@MoOx
Copy link
Contributor

MoOx commented Dec 29, 2015

@jessedobbelaere the a react app, you should just create some Button & Input components ;)

@mxstbr mxstbr changed the title CSS Folder Structure CSS Structure Dec 30, 2015
@mxstbr
Copy link
Member Author

mxstbr commented Dec 31, 2015

Pretty big fan of CSS modules now and have more or less decided to use it.
I'm closing this issue, but if you have anything else to say or you think there might be a better way of doing things don't hesitate to comment!

Thanks @MoOx @jessedobbelaere @hampusohlsson for the input, much appreciated!

@lock
Copy link

lock bot commented May 30, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators May 30, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants