Theme Assets
Each Stencil theme’s assets/ directory contains CSS, JavaScript, and image assets that help create the design of storefront pages. A minimal assets/ directory contains the files and subdirectories that you can view on the Cornerstone GitHub Repository.
In parts of your theme’s directory tree where you are free to add new subdirectories and files, be sure to:
- Set newly added directories to permission
755 (drwxr-xr-x). - Set newly added files to permission
644 (rw-r--r--). - Without these permissions, running your theme locally will fail, with multiple error messages. Bundling your theme will also fail, blocking its upload to a store.
Cornerstone assets directory
- Directory:
assets/
Citadel subdirectory
Stencil themes include an internal pattern library called Citadel, which consumes the ZURB Foundation framework. Foundation provides the basis for creating responsive themes. Citadel extends the Foundation framework’s mixins and components to provide Stencil’s own mixins, extensible components, and utilities. The designstyle language underlying these Citadel resources is the Sass/SCSS preprocessor. Citadel resources are named according to BEM and SUIT CSS conventions. Classes are named functionally, rather than based on visual presentation or content. Citadel is based specifically on Foundation 5.5.3, which installs with the Stencil framework. We do not support Foundation 6.x, due to breaking changes introduced between versions 5.x and 6.x.
Citadel design patterns reside in cornerstone/assets/scss/components/. Citadel assets bundled with Cornerstone are located in the following subdirectories:
cornerstone/assets/scss/settings/citadel/cornerstone/assets/scss/components/citadel/
The components/citadel subdirectory contains Citadel-specific resources. The resources are named according to our style guide, which follows BEM and SUIT CSS naming conventions. Class names are structured, and hyphens are meaningful (that is, hyphens are not used merely to separate words). Here are some prototypes and examples:
Components vs utilities
Our naming scheme makes an architectural distinction between components and utilities. Components are defined as custom elements that enclose specific semantics, styling, and behavior. Component names are in camel case. Our syntax for naming them is as follows:
Utility classes are defined as low-level, structural and positional traits. Utilities can be applied directly to any element. Multiple utilities can be used together, and utilities can be used alongside component classes.
To make HTML patterns as reusable as possible, we have used utility classes sparingly, reserving them for component-level styling.
Our syntax for naming utilities is camel case, prefixed with a u- namespace:
Variables and mixins
Citadel variables and mixins follow similar naming conventions.
Variables are things that can change over time. Their names are in camel case, and show context.
Stencil subdirectory
The /components/stencil/ subdirectory contains CSS files unique to Stencil themes, which are used to create specific page elements within the themes. You can view this subdirectory and all its children in the Cornerstone Theme GitHub Repository.
This subdirectory’s children contain CSS for the following page elements.
Resources
Sample apps
- Cornerstone GitHub Repository (BigCommerce GitHub)
Additional resources
- Getting Started With Foundation 5 (Zurb)
- BEM (Get BEM)
- SUIT CSS (GitHub)
- Customizing a Theme (Assets Directory) (YouTube)
- BigCommerce Sass Styling Guide (BigCommerce GitHub)