A WordPress starter project by emagine.
- Create a new repository here, https://github.com/organizations/emagineusa/repositories/new
- Clone the repository to your local machine.
- Download this repository and extract its contents into your local repository.
- Open the
package.jsonfile and update the "name" value to whatever you want for your new project. Replace all instances ofhttps://github.com/emagineusa/embarkwith the url to your repo. - Open
gulpfile.jsand changeconst host = "embark.local";to whatever your localhost will be for this project. Feel free to changeconst protocol = 'http';tohttpsif your project requires it. - Open your command line application and
cdto your repository's directory. - Run
npm install. - Run
gulp.
NOTE: The following method only works if your local server setup allows for symbolic links. If you use MAMP, this method is perfect for you. If you are using Vagrant or Docker based setups, then this method will not work, as they do not support symlinks. If you use "Local by Flywheel", you can install this addon, https://github.com/getflywheel/local-addon-volumes, which will let you "mount additional directories for your sites".
- Install WordPress in the root of your repo's directory. The
.gitignoreis set to ignore everything in the repository, except for what it cares about. So, don't worry about WordPress files being committed to your repo. - Next you need to make a symbolic link, or symlink, of your project's
buildfolder. If you're on a Mac, you can install this service to make things a little easier, https://www.macupdate.com/app/mac/10433/symboliclinker. After it's installed, you can simply right-click on the item you want to make a symlink of, and go to "Services > Make Symbolic Link" and your done. You can make symlinks via the command line as well, if you're into that, http://osxdaily.com/2015/08/06/make-symbolic-links-command-line-mac-os-x/. - Rename your symlink to match the value of
namein yourpackage.json. - Move your symlink to
/wp-content/themes/. - Log into your site's admin and activate your theme.
Now, as you update your files in the src directory, gulp will process them and update the build directory. Since our active theme is a symlink of the build directory, any changes will be mirrored automatically.
The Patternlab portion of this repository is entirely optional, and up to the developers to maintain.
This tool can be leveraged to help project teams in several different ways:
- Designers and developers can have a complete inventory of all the components and design patterns that exist in the design ecosystem.
- Project teams are encouraged to reuse existing patterns, rather than reinventing the wheel.
- A living styleguide helps teams communicate project jargon and terminology.
- Clients can view completed pages with real content.
- Project teams can view completed templates with dummy content.
This project uses the gulp wrapper around patternlab-node core https://github.com/pattern-lab/edition-node-gulp.
Inside the root, there is an additional directory named /patternlab/.
Inside that folder is the default Patternlab Node - Gulp Edition package.json, and a slightly customized configuration file that uses the assets created from our /src/ and /build/ directories for the WordPress theme.
To get started with Patternlab, follow these instructions:
- Open your command line application and
cdto your repository's/patternlab/directory. - Run
npm install. - Run
gulp patternlab:buildto build the patternlab. - Run
gulp patternlab:serveto serve up a browsersync local server to view the patternlab and watch for changes.
The /patternlab/ folder in the root has a slightly customized configuration file, /patternlab/patternlab-config.json to integrate the theme's css, fonts, images, and javascript without needing to copy anything to Patternlab. This configuration file has been modified slightly to integrate into our theme build process.
- Patterns are created inside
/src/_patternlab/. This is where the patternlab source files are managed for/_annotations/,/_data/,/_meta/, and/_patterns/. - The configuration file is using the theme's
/build/directory to copy over the/css/,/fonts/,/images/, and/javascript/directories into/patternlab/public/.
In summary, all the work that is done in patternlab is done inside the /src/_patternlab/ directory.
The root /patternlab/ directory is where the tool is installed to compile files and create the pattern library inside /patternlab/public/, which can be copied onto a staging server.
All the patterns and data that will need to be modified is in /src/_patternlab/.
The colors map is created by modifying the following files:
/src/_patternlab/_data/data.json: Controls the organization of the swatches/src/_patternlab/_patterns/00-atoms/00-global/00-colors.mustache: Controls the display and iteration of color data that was entered in the above file./src/sass/config/variables/__colors.scss: Defines the project colors in the$theme-colorssass map, as well as other color variables. Also defines the$swatchessass map used for labelling each swatch and its associated background/text colors.
To get started follow these instructions:
- Open the sass color variables file,
/src/sass/config/variables/__colors.scss. - Configure the
$theme-colorssass map according to the project's stylesheet. - At the bottom of that file, edit the
$swatchessass map that uses these theme colors and defines the background/text-colors. - When finished, edit
/_patternlab/data/data.jsonto define the organization of project's color scheme. Out-of-the-box, the data is structure intobrandColorsandneutralColors, but this can be changed or modified to include a different pattern. - After the data is updated, make sure it matches up with the mustache file that displays the swatches in
/src/_patternlab/_patterns/00-atoms/00-global/00-colors.mustache.
A helpful tool for downloading Google Fonts locally and creating the stylesheets is https://google-webfonts-helper.herokuapp.com/fonts.
The fonts can be configured by modifying the following files:
/src/fonts/*: Contains all locally hosted font files. This project uses Roboto font files out-of-the-box, generated from the above link./src/sass/fonts/*: Where @font-face stylesheets and rules are defined. This project uses a roboto stylesheet out-of-the-box, generated from the above link./src/sass/config/variables/__typography.scss: Where the font-stacks used for the project are defined. Defines the$primary-fontand$secondary-font, as well as typography sass maps for paragraphs and headings./src/sass/patternlab-custom.scss: Defines the helper classes.font-primary, and.font-secondaryclasses used to apply to elements to demonstrate fonts in-use./src/_patternlab/_patterns/00-atoms/00-global/01-fonts.mustache: Controls the HTML display of each font family, using the classes defined from/src/sass/patternlab-custom.scss.
To get started follow these instructions:
- Add any locally hosted fonts into the project's fonts directory
/src/fonts/. Only.woffand.woff2are needed to support IE11+. You may use a tool like https://google-webfonts-helper.herokuapp.com/fonts to host the Google Fonts locally. - Update the @font-face rules defined in
/src/sass/fonts/*for each family to reflect your project's typography. Only.woffand.woff2are needed to support IE11+. It is recommended to separate each font-family into their own sass partial for better organization (example:_roboto.scss,_oswald.scss, etc). - Update
/src/sass/config/variables/__typography.scssto modify the$primary-font,$secondary-fontand their fallbacks when fonts aren't loaded yet. - Update
/src/sass/patternlab-custom.scsswhere the.font-primary, and.font-secondaryclasses are defined. - Modify
/src/_patternlab/_patterns/00-atoms/00-global/01-fonts.mustacheto reflect all your.font-primaryand.font-secondaryclasses and their variations for each font weight/style.
Now typography rules for headings and paragraphs can be modified inside their sass maps inside /src/sass/config/variables/__typography.scss.
The button system is built using a series of variables, mixins, and placeholder classes to keep things DRY and configurable.
/src/config/variables/components/_buttons.scss: This is where all button variables and sass maps are defined for the base button class and its variants for solids and outlines.- The
%btn-textplaceholder class contains the typography styles of buttons. The.btn-textclass extends this placeholder class, for situations where you want to add Read More links. - The
.btnclass is used to apply a neutral button without any theme branding colors. This base class contains the default padding, border styles, and other common properties that can be extended with modifier classes for each variation. It also extends the%btn-textplaceholder class to inherit the typography settings. - There are two sass maps for creating the color variations:
$btn-solid-variantsand$btn-outline-variants. This solid variants sass map contains the colors for the base.btnclass that is neutral, along with any additional variants like primary and secondary. - Outline variants can be applied by simply adding
-oto any button variant. For example,.btn.btn--primarywould be solid, whereas.btn.btn--primary-owould be the outline version.
- The
/src/config/extends/_buttons.scss: Defines the placeholder classes that can be used to make any element have a specific button style./src/components/_buttons.scss: Defines the actual classes by extending the placeholder classes. There shouldn't be much going on in this partial aside from extending the placeholders defined in the extends file.