The BigCommerce Cornerstone theme
mattolson Merge pull request #1380 from bookernath/STRF-4612
STRF-4612 - Remove unnecessary API call to get cookie notification st…
Latest commit e2cbbe4 Nov 8, 2018
Permalink
Failed to load latest commit information.
.github Add issue template Mar 28, 2017
assets STRF-4612 - Remove unnecessary API call to get cookie notification st… Nov 9, 2018
grunt fix(content): STRF-4948 fix missing svg icons on AMP add-to-cart page… Jun 13, 2018
lang default instrument for add/edit form Nov 1, 2018
meta MERC-817: new thumbnail images for the theme Jun 13, 2016
templates PROJECT-2272: Add support for declarative data tag analytics Nov 2, 2018
.eslintignore webpack 2 Apr 25, 2017
.eslintrc STRF-4220 - Fix image-overlap on Orders page Jan 3, 2018
.gitignore MERC-4196: Fixes issue with Slick slider for mobile safari Oct 15, 2018
.scss-lint.yml BIG-21458: Revert default SelectorDepth and NestingDepth levels Oct 28, 2015
.travis.yml STRF-4603: Webpack 4 + Javascript optimizations May 17, 2018
CHANGELOG.md STRF-4612 - Remove unnecessary API call to get cookie notification st… Nov 9, 2018
CONTRIBUTING.md Update license year and contributing link. Mar 16, 2017
Gemfile BIG-21458: Add dev-related grunt tasks and hooks Sep 2, 2015
Gemfile.lock BIG-21458: Add dev-related grunt tasks and hooks Sep 2, 2015
Gruntfile.js MERC-409: Enable theme specific builds Apr 6, 2016
LICENSE.md Update license year and contributing link. Mar 16, 2017
README.md credit card listing without actions(add, edit, delete) Nov 1, 2018
config.json Releasing 2.6.0 Nov 5, 2018
karma.conf.js STRF-4603: Webpack 4 + Javascript optimizations May 17, 2018
package.json STRF-4612 - Remove unnecessary API call to get cookie notification st… Nov 9, 2018
schema.json Add option to disable arrows on the homepage carousel Oct 8, 2018
stencil.conf.js Require Webpack and its config only when used Aug 22, 2018
webpack.common.js Fix minor ESLint errors in webpack.common.js Jun 28, 2018
webpack.dev.js Fix Webpack 4 DefinePlugin config Jun 28, 2018
webpack.prod.js Fix Webpack 4 DefinePlugin config Jun 28, 2018

README.md

Cornerstone

Build Status

Stencil's Cornerstone theme is the building block for BigCommerce theme developers to get started quickly developing premium quality themes on the BigCommerce platform.

Stencil Utils

Stencil-utils is our supporting library for our events and remote interactions.

JS API

When writing theme JavaScript (JS) there is an API in place for running JS on a per page basis. To properly write JS for your theme, the following page types are available to you:

  • "pages/account/addresses"
  • "pages/account/add-address"
  • "pages/account/add-return"
  • "pages/account/add-wishlist"
  • "pages/account/recent-items"
  • "pages/account/download-item"
  • "pages/account/edit"
  • "pages/account/return-saved"
  • "pages/account/returns"
  • "pages/account/payment-methods"
  • "pages/auth/login"
  • "pages/auth/account-created"
  • "pages/auth/create-account"
  • "pages/auth/new-password"
  • "pages/blog"
  • "pages/blog-post"
  • "pages/brand"
  • "pages/brands"
  • "pages/cart"
  • "pages/category"
  • "pages/compare"
  • "pages/errors"
  • "pages/gift-certificate/purchase"
  • "pages/gift-certificate/balance"
  • "pages/gift-certificate/redeem"
  • "global"
  • "pages/home"
  • "pages/order-complete"
  • "pages/page"
  • "pages/product"
  • "pages/search"
  • "pages/sitemap"
  • "pages/subscribed"
  • "page/account/wishlist-details"
  • "pages/account/wishlists"

These page types will correspond to the pages within your theme. Each one of these page types map to an ES6 module that extends the base PageManager abstract class.

    export default class Auth extends PageManager {
        constructor() {
            // Set up code goes here; attach to internals and use internals as you would 'this'
        }
    }

Within PageManager you will see methods that are available from all classes, but there are three really important methods. The following methods have the signature func (callback) and the callback takes callback(err) if there is an error.

before(callback)

When this method is implemented in your class, the code contained therein will be executed after the constructor but before the loaded() method. This provides a shim for your code before your main implementation logic runs.

    export default class Auth extends PageManager {
        constructor() {
            // Set up code goes here
        }
        before(callback) {
            // Code that should be run before any other code in this class

            // Callback must be called to move on to the next method
            callback();
        }
    }

loaded(callback)

This method will be called when the constructor has run and before() has been executed. Main implementation code should live in the loaded method.

    export default class Auth extends PageManager {
        constructor() {
            // Set up code goes here
        }
        loaded(callback) {
            // Main implementation logic here

            // Callback must be called to move on to the next method
            callback();
        }
    }

after(callback)

This method is for any cleanup that may need to happen and it will be executed after before() and loaded().

    export default class Auth extends PageManager {
        constructor() {
            // Set up code goes here
        }
        after(callback) {
            // Main implementation logic here

            // Callback must be called to move on to the next method
            callback();
        }
    }

JS Template Context Injection

Occasionally you may need to use dynamic data from the template context within your client-side theme application code.

Two helpers are provided to help achieve this.

The inject helper allows you to compose a JSON object with a subset of the template context to be sent to the browser.

{{inject "stringBasedKey" contextValue}}

To retrieve the parsable JSON object, just call {{jsContext}} after all of the {{@inject}} calls.

For example, to setup the product name in your client-side app, you can do the following if you're in the context of a product:

{{inject "myProductName" product.title}}

<script>
// Note the lack of quotes around the jsContext handlebars helper, it becomes a string automatically.
var jsContext = JSON.parse({{jsContext}}); // jsContext would output "{\"myProductName\": \"Sample Product\"}" which can feed directly into your JavaScript

console.log(jsContext.myProductName); // Will output: Sample Product
</script>

You can compose your JSON object across multiple pages to create a different set of client-side data depending on the currently loaded template context.

The stencil theme makes the jsContext available on both the active page scoped and global PageManager objects as this.context.

Static assets

Some static assets in the Stencil theme are handled with Grunt if required. This means you have some dependencies on grunt and npm. To get started:

First make sure you have Grunt installed globally on your machine:

npm install -g grunt-cli

and run:

npm install

Icons

Icons are delivered via a single SVG sprite, which is embedded on the page in templates/layout/base.html. It is generated via a grunt task grunt svgstore.

The task takes individual SVG files for each icon in assets/icons and bundles them together, to be inlined on the top of the theme, via an ajax call managed by svg-injector. Each icon can then be called in a similar way to an inline image via:

<svg><use xlink:href="#icon-svgFileName" /></svg>

The ID of the SVG icon you are calling is based on the filename of the icon you want, with icon- prepended. e.g. xlink:href="#icon-facebook".

Simply add your new icon SVG file to the icons folder, and run grunt svgstore, or just grunt.

License

(The MIT License) Copyright (C) 2015-present BigCommerce Inc. All rights reserved.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense,and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.