jquery-archive / css-chassis

An attempt at creating an open standard for both CSS and JavaScript UI libraries.
https://css-chassis.com
Other
351 stars 67 forks source link

File structure #29

Closed MichaelArestad closed 9 years ago

MichaelArestad commented 9 years ago

I suggest an atomic structure with small self-contained modules. I prefer a version inspired by a Dale Sande article (or video).

Here's how I propose each module is structured:

// Module structure
// 1. main file with styles
// 2. functions used with main file
// 3. mixins used with main file
// 4. variables used with main file

|- typography/
|--- functions.scss  // 2
|--- mixins.scss     // 3
|--- typography.scss // 1
|--- variables.scss  // 4

And how the overall file structure might look:

// 1. _utilities contains global mixins module, normalize, etc
// 2. atoms contains modules like buttons
// 3. molecules contains  modules like nav_horizontal
// 4. organisms contains more complex modules like banner
// 5. views contains individual page/view templates like admin

|- sass/
|--- _utilities/ // 1
|--- atoms/      // 2
|--- molecules/  // 3
|--- organisms/  // 4
|--- views/      // 5
|--- style.scss

Pros

@import "atoms/colors/colors",  // Global color variables
    "_utilities/mixins/mixins", // Global mixins
    "_utilities/clearings",

    "atoms/typography/typography",
    "atoms/media",
    "atoms/animations",
    "atoms/buttons",
    "atoms/icons/genericons",

    "molecules/nav-horizontal",
    "molecules/nav-off-screen",
    "molecules/alerts",

    "organisms/contact-form",
    "organisms/calendar",

    "views/main",
    "views/settings";

Cons

sfrisk commented 9 years ago

Looks interesting. Best I can figure the difference between molecule and organism is an organism might have molecules in it? Or is it more than that?

I definitely could get behind a file organization system like this.

MichaelArestad commented 9 years ago

Best I can figure the difference between molecule and organism is an organism might have molecules in it? Or is it more than that?

That's generally the case.

cbracco commented 9 years ago

I do like this type of organization as well. The next version of Cardinal will have LESS files organized in a similar manner, like so:

|____areas
| |____boxes.less
| |____grids.less
| |____strips.less
| |____wrappers.less
|____base
| |____anchors.less
| |____base.less
| |____blockquotes.less
| |____fonts.less
| |____forms.less
| |____headings.less
| |____horizontal-rules.less
| |____reset.less
| |____selections.less
| |____shared.less
| |____syntax.less
| |____tables.less
|____cardinal.less
|____components
| |____buttons.less
| |____icons.less
| |____lists.less
|____objects
| |____media.less
|____print
| |____print.less
|____settings
| |____mixins.less
| |____variables.less
|____utilities
| |____alignment.less
| |____display.less
| |____layout.less
| |____position.less
| |____spacing.less
| |____text.less
| |____widths.less
| |____z-index.less

Base = normalize, reset, and styling for common elements (aka atoms) Areas = spaces where common elements, components, and objects can live Components = a collection of one or more common elements Objects = a collection of one or more common elements and/or components. Print = print styles Settings = variables and mixins Utilities = helper classes

Not saying we should do it exactly like this, simply sharing some additional thoughts around the subject. I like the suggestions of @MichaelArestad!

sfrisk commented 9 years ago

Also brought up in the January 6, 2015 meeting: Possibility of bundling component styles with components rather than in the sass folder. Example: https://github.com/topcoat/button-bar-template/tree/master/example

trailofdad commented 9 years ago

After much thought, I really like the structure proposed by @MichaelArestad . I do think the documentation would have to make it clear the difference between atoms, molecules and organisms. I feel like some people might be confused otherwise. I do like how in the example that @cbracco had contributed is very obvious where everything goes. I think the best way would be to make sure that everything is as modular as possible and easily readable. I'm going to do some more looking around at other file structures.

trailofdad commented 9 years ago

I've explored a lot of other file structures today and I think the atomic structure is the best option. Some file structures have upwards of 10 folders in the root. I don't know about anyone else but I like to keep my files super tidy. It would be best to have the framework be minimally abrasive and complicated to the user.

arschmitz commented 9 years ago

@sfrisk does it make since to keep this open? We already landed most of whats being covered here. The only thing not already landed is where the html files will go ( I think only because there is nothing in it yet and git wont maintain an empty folder ), but if i'm not mistaken we decided we wanted to keep those in a separate folder ( hence the scss folder name we already landed ). So it seems like this could be closed.

sfrisk commented 9 years ago

I think we're good to close this.

maikuru commented 9 years ago

@arschmitz One can just create the folder with a .gitignore file in it to at least maintain structure while in this early phase

arschmitz commented 9 years ago

@maikuru true just not sure there is a point until we do have something to put it in.

maikuru commented 9 years ago

@arschmitz to stop people from wondering where it's going to go someday ;)