Skip to content

Styleguide: General

Brian Talbot edited this page Feb 17, 2015 · 18 revisions

General

Welcome to the edX General Front End Styleguide. This document is meant to be referenced alongside the following more detailed styleguides:


In general, edX styling should adhere to:

  • four (4) spaces indents, no tabs;
  • files should be named in all lowercase with - separating legible words (e.g. footer-global.html)
  • prefix any partial or included file (a file that should not render on its own) with an underscore (e.g. _system-alerts.scss).

File Organization

Per application, we adhere to the following Front-End directory structure, with the assumption that we are working in a Django environment with Django templates and with Sass):

Note: Certain directories not pertaining to the scope of this Front End Development guide have been omitted for legibility.

[application-name]
...
├── static
|   └── vendor                       // vendor packages
|   └── vendor-extensions            // customizations to vendor packages
|   └── css
|   |   └── main.css                 // compiled css
|   ...
|   └── images
|   |   └── *.*                      // rendered in DOM/content images
|   |   └── bg-*.*                   // style-based background images
|   |   └── logo-*.*                 // logos/branding/official images
|   |   └── ico-*.*                  // style-based icon-based images
|   ...
|   └── js
|   ...
|   └── sass
|   |   └── base                     // set up, variables, and reset
|   |   └── components               // atomic, elemental, and molecular-level UI
|   |   └── layouts                  // grid, canned layouts, layout-based rules
|   |   └── shame                    // browser/UI hacks, and poorly-scoped overrides
|   |   └── utilities                // utilities
|   |   └── views                    // page/view specifics
|   |   └── main.scss                // main application compile
└── templates
|   └── ...                          // individual theme
└── themes
|   └── [theme-name]                 // individual theme
|   |   └── static
|   |   └── templates
|   |    ...

File Naming

We adhere to the following conventions when naming:

  • files should be named in all lowercase with - separating legible words (e.g. main-rtl.scss or _header-primary.html);
  • all theme-based assets are contained within a [theme-name] directory who's static and template structure mirrors the major directories within the application;
  • images that are not used directly in the content should be prefixed with their appropriate purpose (bg = background, ico = icon/symbol, logo = brand/logo)

Vendor Files

When possible, we do not:

  • edit a vendor file directly or change a vendor's source code
  • change a vendor file's name
  • split specific vendor files that are bundled together (this means customizing folder paths when referencing vendor files)
Known/Chosen Vendor Files
  • Bourbon (docs) - A set of utilities for writing SCSS
  • Neat (docs) - A responsive-friendly grid framework based upon Bourbon.
  • normalize - A common and basic CSS reset that makes cross-browser/agent rendering more consistent.
  • JQuery - Basic utility for DOM manipulation and UI behavior
  • Font Awesome - Vector-based icon font library

Git Etiquette

Never check production-ready files into a codebase's repository including:

  • Sass sourcemaps
  • compiled CSS files
  • compressed assets (CSS and JavaScript files)
  • local editor/project management files
  • local cache-based files

All of these files should be added to either your local global .gitignore file or better yet the edX project's .gitignore file.

Clone this wiki locally