Repository: 10up/theme-scaffold
Branch: master
Commit: e68ccaa0b963
Files: 72
Total size: 67.5 KB
Directory structure:
gitextract_0yipqz8n/
├── .browserslistrc
├── .editorconfig
├── .eslintignore
├── .eslintrc.json
├── .gitignore
├── .npmrc
├── .nvmrc
├── .stylelintrc
├── LICENSE.md
├── README.md
├── assets/
│ ├── css/
│ │ ├── admin/
│ │ │ ├── admin-style.css
│ │ │ └── example-block-1.css
│ │ ├── blocks/
│ │ │ ├── example-block-1.css
│ │ │ └── index.css
│ │ ├── frontend/
│ │ │ ├── base/
│ │ │ │ ├── index.css
│ │ │ │ ├── prefers-reduced-motion.css
│ │ │ │ └── wordpress.css
│ │ │ ├── components/
│ │ │ │ └── index.css
│ │ │ ├── editor-style.css
│ │ │ ├── global/
│ │ │ │ ├── colors.css
│ │ │ │ ├── index.css
│ │ │ │ └── media-queries.css
│ │ │ ├── layout/
│ │ │ │ └── index.css
│ │ │ ├── style.css
│ │ │ └── templates/
│ │ │ └── index.css
│ │ ├── shared/
│ │ │ └── shared-style.css
│ │ └── styleguide/
│ │ └── styleguide.css
│ ├── fonts/
│ │ └── font-name/
│ │ └── .gitkeep
│ ├── images/
│ │ └── .gitkeep
│ ├── js/
│ │ ├── admin/
│ │ │ └── admin.js
│ │ ├── blocks/
│ │ │ ├── blocks.js
│ │ │ └── example-block-1.js
│ │ ├── frontend/
│ │ │ ├── components/
│ │ │ │ └── .gitkeep
│ │ │ └── frontend.js
│ │ ├── shared/
│ │ │ └── shared.js
│ │ └── styleguide/
│ │ ├── styleguide.js
│ │ └── uikitsection.js
│ └── svg/
│ └── .gitkeep
├── babel.config.js
├── composer.json
├── config/
│ ├── webpack.config.common.js
│ ├── webpack.config.dev.js
│ ├── webpack.config.prod.js
│ └── webpack.settings.js
├── footer.php
├── functions.php
├── header.php
├── includes/
│ ├── blocks/
│ │ ├── blocks-editor.js
│ │ └── example-block-1/
│ │ └── index.js
│ ├── blocks.php
│ ├── classes/
│ │ └── .gitkeep
│ ├── core.php
│ ├── overrides.php
│ ├── template-tags.php
│ └── utility.php
├── index.php
├── languages/
│ └── TenUpScaffold.pot
├── manifest.json
├── package.json
├── partials/
│ └── .gitkeep
├── phpcs.xml
├── postcss.config.js
├── search.php
├── searchform.php
├── style.css
├── templates/
│ └── page-styleguide.php
├── tests/
│ ├── accessibility/
│ │ └── compliance/
│ │ └── pa11y.js
│ ├── js/
│ │ └── .gitkeep
│ ├── php/
│ │ └── .gitkeep
│ └── wpa/
│ ├── FrontendTest.php
│ └── StandardTest.php
└── wpacceptance.json
================================================
FILE CONTENTS
================================================
================================================
FILE: .browserslistrc
================================================
# Browsers that we support
> 1%
last 2 versions
Firefox ESR
IE 11
================================================
FILE: .editorconfig
================================================
root = true
[*]
charset = utf-8
end_of_line = lf
insert_final_newline = true
trim_trailing_whitespace = true
indent_style = tab
[{*.json,*.yml,.babelrc,.bowerrc,.browserslistrc,.postcssrc}]
indent_style = space
indent_size = 2
[*.txt,wp-config-sample.php]
end_of_line = crlf
================================================
FILE: .eslintignore
================================================
assets/js/vendor
assets/js/admin/vendor
assets/js/frontend/vendor
assets/js/shared/vendor
webpack.config.babel.js
tests
================================================
FILE: .eslintrc.json
================================================
{
"extends": "@10up/eslint-config/wordpress",
"rules": {},
"globals": {
"module": true,
"process": true
}
}
================================================
FILE: .gitignore
================================================
node_modules
bower_components
release
vendor
phpunit.xml
.idea
# Project Files
dist
backstop_data
# Editors
*.esproj
*.tmproj
*.tmproject
tmtags
.*.sw[a-z]
*.un~
Session.vim
*.swp
# Mac OSX
.DS_Store
._*
.Spotlight-V100
.Trashes
# Windows
Thumbs.db
Desktop.ini
================================================
FILE: .npmrc
================================================
engine-strict=true
================================================
FILE: .nvmrc
================================================
12
================================================
FILE: .stylelintrc
================================================
{
"extends": "@10up/stylelint-config"
}
================================================
FILE: LICENSE.md
================================================
MIT License
Copyright (c) 2019 10up Inc. (https://10up.com)
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.
================================================
FILE: README.md
================================================
# 10up Scaffold
**DEPRECATED.** Use https://github.com/10up/wp-scaffold
> At 10up, we strive to provide digital products that yield a top-notch user experience. In order to improve both our efficiency and consistency, we need to standardize what we use and how we use it. This theme scaffold allows us to share initial set up procedures to make sure all projects can get up and running as quickly as possible while closely adhering to 10up's high quality standards.
[](#support-level) [](https://github.com/10up/theme-scaffold/blob/master/LICENSE.md)
## Dependencies
1. [Node@^8.11.0 & NPM](https://www.npmjs.com/get-npm) - Build packages and 3rd party dependencies are managed through NPM, so you will need that installed globally.
2. [Webpack](https://webpack.js.org/) - Webpack is used to process the JavaScript, CSS, and other assets.
3. [Composer](https://getcomposer.org/) - Composer is used to manage PHP.
## Getting Started
### Quick Start
Install 10up's command line tool for scaffolding new projects. You can download it from the [Project Scaffold repository](https://github.com/10up/project-scaffold). Setting up a new theme is as easy as running `create-10up theme theme-name-here` in the terminal!
Browsersync requires a local development URL. This is currently set in the `config/webpack.settings.js`, as `BrowserSyncConfig.proxy`.
### Direct Install
- Clone the repository
- Rename folder theme-scaffold -> your project's name
- If copying files manually to an existing theme directory instead of cloning directly from the repository, make sure to include the following files which may be hidden:
```
.babelrc
.browserslistrc
.editorconfig
.eslintignore
.eslintrc
.gitignore
```
The NPM commands will fail without these files present.
- Do case-sensitive search/replace for the following:
- TenUpScaffold
- TENUP_SCAFFOLD
- tenup-scaffold
- tenup_scaffold
- 10up Scaffold
- `cd` into the theme folder
- run `npm run start`
## Webpack config
Webpack config files can be found in `config` folder:
- `webpack.config.dev.js`
- `webpack.config.common.js`
- `webpack.config.prod.js`
- `webpack.settings.js`
In most cases `webpack.settings.js` is the main file which would change from project to project. For example adding or removing entry points for JS and CSS.
## NPM Commands
- `npm run start` (install dependencies)
- `npm run watch` (watch)
- `npm run build` (build all files)
- `npm run build-release` (build all files for release)
- `npm run dev` (build all files for development)
- `npm run lint-release` (install dependencies and run linting)
- `npm run lint-css` (lint CSS)
- `npm run lint-js` (lint JS)
- `npm run lint-php` (lint PHP)
- `npm run lint` (run all lints)
- `npm run format-js` (format JS using eslint)
- `npm run format` (alias for `npm run format-js`)
- `npm run test:a11y` (run accessibility tests)
## Composer Commands
- `composer install`* (install packages)
- `composer update`* (update packages)
- `composer lint` (lint PHP files)
- `composer lint-fix` (lint PHP files and automatically correct coding standard violations)
_* If your host machine's local version of PHP is <7.2, composer may produce the following, or similar, error message:_
```
Problem 1
- Installation request for 10up/wpacceptance dev-master -> satisfiable by 10up/wpacceptance[dev-master].
- 10up/wpacceptance dev-master requires php >=7.2 -> your PHP version (7.1.23) does not satisfy that requirement
```
_To suppress this error, add the flag `--ignore-platform-reqs` (ie. `composer install --ignore-platform-reqs`)._
## Automated Style Guide
The Theme Scaffolding ships with a default style guide you can find in `/templates/page-styleguide.php`. This file contains all the basic HTML elements you would find at the very top of the cascade (headings, typography, tables, forms, etc.) These base elements will be styled and displayed as you naturally build out your CSS. The style guide also automatically pulls in the color variables used in the project. Any hex codes added into `/assets/css/frontend/global/variables.css` will be automatically displayed in the style guide. To set up your style guide, you just need to create a new page in WordPress and assign it the "Style Guide" template.
If you need to update the core styles that power the style guide they are located in `/assets/css/styleguide` and will naturally process with the rest of the CSS.
As your site grows you can add components to the style guide by updating `/templates/page-styleguide.php` as you see fit. All the JS and CSS for the site will already be included in the template, so everything should just work.
## Automated Accessibility Testing
Automated accessibility testing in the Theme Scaffolding is done with [Pa11y](https://www.npmjs.com/package/pa11y) and is executed with the command `npm run test-a11y`. You can find any configuration options inside your `package.json` file inside the `testing` object. You will see default URL options (homepage, article, search-results), but you can add as many as you'd like. The default script runs over the `local` URL and any others will run with an argument like `npm run test-a11y production`, over a production URL. You can also add more template URLs for testing like `npm run a11y-test article-template`. Be sure to check with your systems person on a project to make sure accessibility tests are also hooked up through the deploy process.
Compliance levels can also be updated through the `testing.accessibility.compliance` object in the `package.json` file. The default is WCAG Level A, but it can be updated to anything listed in the [pa11y documentation](https://github.com/pa11y/pa11y).
The test file lives in `/tests/accessibility/compliance/pa11y.js` if any edits are needed (such as staging credentials, if you're running tests in an environment that requires authentication).
## Visual Regression Testing
We use [BackstopJS](https://github.com/garris/BackstopJS) to run our visual regression tests. BackstopJS requires just a few settings to work: a `scenarios` array that tells it which URL's to screenshot, a `viewports` array that tells it what breakpoints to use, and a `config` object for global settings.
Begin by setting which URL's you'd like to test in the `testing.urls` object in `package.json`. You will see some default URL's (homepage, article, search-results), but you can add as many as you'd like. These URL's are read by `tests/visual/scenarios.js` to automatically produce the `scenarios` array that BackstopJS will use to take screenshots.
You can also create custom scenarios in `tests/visual/custom-scenarios.js`. Custom scenarios allow us to add specific options for specific URL's, for situations like hovering over an element to screenshot its hover state, or clicking a modal button and waiting for the modal to become visible.
To create a custom scenario, simply set the `urlName` property to match the property name in the `testing.urls` object, and then create an `options` object with your desired settings. A couple examples are provided in `tests/visual/custom-scenarios.js` and you can see a list of all available options in the [advanced scenarios](https://github.com/garris/BackstopJS#advanced-scenarios) section on GitHub.
BackstopJS can take screenshots at various screen widths, so make sure to match the breakpoints in `tests/visual/viewports.js` with those in your theme.
Though generally not necessary, you can customize the BackstopJS configuration by changing the settings in `tests/visual/config.js`.
To begin running BackstopJS visual regression tests, initialize its required files. This only needs to be done once on your local machine:
`npm run test:visual-init`
Then create a set of screenshots that will become the base reference images to run future tests against:
`npm run test:visual-reference`
After you've made changes and want to test for visual regressions:
`npm run test:visual`
Finally, if the new screenshots fail but contain desired changes, approve them for use as the new base reference images:
`npm run test:visual-approve`
## Automated Acceptance Testing
Automated acceptance testing in the Theme Scaffolding leverages [WP Acceptance](https://github.com/10up/wpacceptance) and is included in the project via Composer as a dev required package. Run the command `composer update` (see [Composer Commands](https://github.com/10up/theme-scaffold/tree/feature/docs-composer#composer-commands) above) to install the required packages. Refer to the [documentation](https://wpacceptance.readthedocs.io/en/latest/#wp-acceptance) to ensure your host machine has the necessary [requirements](https://wpacceptance.readthedocs.io/en/latest/#requirements). The Theme Scaffolding is already setup to work with WP Acceptance and a few example tests have been created to serve as examples.
To run the test suite, from the root of the repository, run `./vendor/bin/wpacceptance run`. WP Acceptance will automatically run the test suite in isolated docker containers. To write your own acceptance tests, refer to the [documentation](https://wpacceptance.readthedocs.io/en/latest/#writing-tests) and [cookbook](https://wpacceptance.readthedocs.io/en/latest/cookbook/).
## Contributing
We don't know everything! We welcome pull requests and spirited, but respectful, debates. Please contribute via [pull requests on GitHub](https://github.com/10up/theme-scaffold/compare).
1. Fork it!
2. Create your feature branch: `git checkout -b feature/my-new-feature`
3. Commit your changes: `git commit -am 'Added some great feature!'`
4. Push to the branch: `git push origin feature/my-new-feature`
5. Submit a pull request
## Learn more about the default packages used with this project
- [10up Eslint config](https://www.npmjs.com/package/@10up/eslint-config)
- [10up Stylelint config](https://www.npmjs.com/package/@10up/stylelint-config)
- [Babel core](https://www.npmjs.com/package/@babel/core)
- [Babel Eslint](https://www.npmjs.com/package/babel-eslint)
- [Babel loader](https://www.npmjs.com/package/babel-loader)
- [Babel preset env](https://www.npmjs.com/package/@babel/preset-env)
- [Babel register](https://www.npmjs.com/package/@babel/register)
- [Browsersync](https://browsersync.io/)
- [BackstopJS](https://github.com/garris/BackstopJS)
- [Can I Use DB](https://www.npmjs.com/package/caniuse-db)
- [Clean Webpack plugin](https://www.npmjs.com/package/clean-webpack-plugin)
- [Copy Webpack plugin](https://www.npmjs.com/package/copy-webpack-plugin)
- [CSS loader](https://www.npmjs.com/package/css-loader)
- [CSS nano](https://www.npmjs.com/package/cssnano)
- [Eslint](https://www.npmjs.com/package/eslint)
- [Eslint loader](https://www.npmjs.com/package/eslint-loader)
- [Husky@next](https://www.npmjs.com/package/husky)
- [Imagemin plugin for Webpack](https://github.com/Klathmon/imagemin-webpack-plugin)
- [Lint Staged](https://www.npmjs.com/package/lint-staged)
- [Mini CSS extract plugin](https://www.npmjs.com/package/mini-css-extract-plugin)
- [Pa11y](https://www.npmjs.com/package/pa11y)
- [PostCSS Import](https://www.npmjs.com/package/postcss-import)
- [PostCSS loader](https://www.npmjs.com/package/postcss-loader)
- [PostCSS preset-env](https://www.npmjs.com/package/postcss-preset-env)
- [Stylelint](https://www.npmjs.com/package/stylelint)
- [Stylelint config WordPress](https://www.npmjs.com/package/stylelint-config-wordpress)
- [Stylelint declaration use variable](https://www.npmjs.com/package/stylelint-declaration-use-variable)
- [Stylelint order](https://www.npmjs.com/package/stylelint-order)
- [Stylelint Webpack plugin](https://www.npmjs.com/package/stylelint-webpack-plugin)
- [Terser](https://www.npmjs.com/package/terser)
- [Webpack](https://www.npmjs.com/package/webpack)
- [Webpack CLI](https://www.npmjs.com/package/webpack-cli)
- [Webpack fix style only entries](https://www.npmjs.com/package/webpack-fix-style-only-entries)
- [Webpack merge](https://www.npmjs.com/package/webpack-merge)
- [Webpackbar](https://www.npmjs.com/package/webpackbar)
- [PHPCS](https://github.com/squizlabs/PHP_CodeSniffer)
## Support Level
**Active:** 10up is actively working on this, and we expect to continue work for the foreseeable future including keeping tested up to the most recent version of WordPress. Bug reports, feature requests, questions, and pull requests are welcome.
## Like what you see?
================================================
FILE: assets/css/admin/admin-style.css
================================================
/**
* TenUpScaffold - Admin Styles
* https://project-website.tld
*
*/
/**
* Gutenberg blocks admin styles:
* if block editor styles differ from front-end block styles,
* create new partials here as needed
*/
@import url("example-block-1.css");
/* @import url("example-block-2.css"); */
/* @import url("example-block-3.css"); */
================================================
FILE: assets/css/admin/example-block-1.css
================================================
/* empty file */
================================================
FILE: assets/css/blocks/example-block-1.css
================================================
/**
* TenUpScaffold: Gutenberg Blocks Styles
* https://project-website.tld
*
*/
/**
* Example block 1 front end styles
*/
================================================
FILE: assets/css/blocks/index.css
================================================
/**
* TenUpScaffold: Gutenberg Blocks Styles
* https://project-website.tld
*
*/
/**
* Gutenberg blocks front-end styles:
* create new partials here as needed
*/
/* @import url("example-block-1.css"); */
/* @import url("example-block-2.css"); */
/* @import url("example-block-3.css"); */
================================================
FILE: assets/css/frontend/base/index.css
================================================
@import url("prefers-reduced-motion.css");
@import url("wordpress.css");
================================================
FILE: assets/css/frontend/base/prefers-reduced-motion.css
================================================
/*
* Resources on prefers-reduced-motion:
* https://webkit.org/blog-files/prefers-reduced-motion/prm.htm
* https://developer.mozilla.org/en-US/docs/Web/CSS/@media/prefers-reduced-motion
*/
@media (prefers-reduced-motion: reduce) {
*,
*::before,
*::after {
animation-duration: 0.001s !important;
transition-duration: 0.001s !important;
}
}
================================================
FILE: assets/css/frontend/base/wordpress.css
================================================
/* WordPress generated classes */
.alignleft {
float: left;
margin-right: 1rem;
text-align: left;
}
.alignright {
float: right;
margin-left: 1rem;
text-align: right;
}
.aligncenter {
clear: both;
display: block;
margin-left: auto;
margin-right: auto;
text-align: center;
}
.wp-caption {
max-width: 100%;
&.aligncenter {
text-align: center;
}
&.alignright {
text-align: right;
}
}
.wp-caption-text {
margin: 0;
}
================================================
FILE: assets/css/frontend/components/index.css
================================================
/* Components */
================================================
FILE: assets/css/frontend/editor-style.css
================================================
/**
* TenUpScaffold - Editor Styles
* https://project-website.tld
*
* Copyright (c) 2017 10up
* Licensed under the MIT license.
*/
/* Gutenberg blocks */
/* @import url("../blocks/index.css"); */
================================================
FILE: assets/css/frontend/global/colors.css
================================================
/*
* Colors
*/
:root {
--c-black: #000;
--c-white: #fff;
}
================================================
FILE: assets/css/frontend/global/index.css
================================================
@import url("colors.css");
@import url("media-queries.css");
================================================
FILE: assets/css/frontend/global/media-queries.css
================================================
/*
* Media Queries
*/
@custom-media --bp-tiny ( min-width: 25em ); /* 400px */
@custom-media --bp-small ( min-width: 30em ); /* 480px */
@custom-media --bp-medium ( min-width: 48em ); /* 768px */
@custom-media --bp-large ( min-width: 64em ); /* 1024px */
@custom-media --bp-xlarge ( min-width: 80em ); /* 1280px */
@custom-media --bp-xxlarge ( min-width: 90em ); /* 1440px */
/* WP Core Breakpoints (used for the admin bar for example) */
@custom-media --wp-small ( min-width: 600px );
@custom-media --wp-medium-max (max-width: 782px);
================================================
FILE: assets/css/frontend/layout/index.css
================================================
/* Layout */
================================================
FILE: assets/css/frontend/style.css
================================================
/**
* TenUpScaffold
* https://project-website.tld
*
*/
/* Resets - installed via NPM */
@import url("normalize.css");
/* Global - global pieces like media queries, mixins and placholders */
@import url("global/index.css");
/* Base - base styles such as fonts, typography, and wordpress overrides */
@import url("base/index.css");
/* Layout - styles specific to layout */
/* @import url("layout/index.css"); */
/* Templates */
/* @import url("templates/index.css"); */
/* Components */
/* @import url("components/index.css"); */
/* Gutenberg blocks */
/* @import url("../blocks/index.css"); */
================================================
FILE: assets/css/frontend/templates/index.css
================================================
/* Templates */
================================================
FILE: assets/css/shared/shared-style.css
================================================
/**
* TenUpScaffold: Shared Styles
* https://project-website.tld
*
*/
================================================
FILE: assets/css/styleguide/styleguide.css
================================================
:root {
--c-uikit-base: #fff;
--c-uikit-accent: #767676;
--c-uikit-hightlight: #f6f6f6;
--c-uikit-border: #ccc;
--c-uikit-primary: #000;
@custom-media --bp-uikit-small (min-width: 40.625em);
}
.uikit__container {
padding-left: 20px;
padding-right: 20px;
}
.uikit__heading {
border-bottom: 1px solid var(--c-uikit-border);
font-size: 56px;
font-weight: 400;
letter-spacing: 0.055em;
margin: 100px auto 130px;
max-width: 720px;
padding: 0;
text-align: center;
text-transform: uppercase;
}
.uikit__heading span {
background: var(--c-uikit-base);
display: inline-block;
padding: 0 40px;
}
.uikit__content {
margin: auto;
max-width: 960px;
}
.uikit__block {
margin-bottom: -33px;
}
.uikit__colors {
font-family: "Courier New", monospace;
list-style: none;
margin: 0;
overflow: hidden;
padding: 0;
text-align: center;
}
.uikit__color {
align-items: center;
border: 1px solid var(--c-uikit-border);
display: flex;
float: left;
font-size: 0.85em;
height: 90px;
justify-content: center;
margin-bottom: 32px;
margin-right: 32px;
width: 90px;
}
.uikit__color--label {
color: var(--c-primary);
left: -999em;
margin: 0;
padding: 0;
position: absolute;
}
.uikit__color--label.light {
color: var(--c-uikit-base);
}
.uikit__icons {
text-align: center;
}
.uikit__icon {
align-items: center;
background: var(--c-uikit-hightlight);
display: flex;
float: left;
height: 62px;
justify-content: center;
margin-bottom: 32px;
margin-right: 32px;
width: 62px;
}
.uikit__icon--label {
left: -999em;
position: absolute;
}
.uikit__section > .heading {
box-sizing: border-box;
color: var(--c-uikit-accent);
display: inline-block;
font-size: 14px;
font-weight: 400;
margin: 0;
padding: 0 40px 20px 0;
vertical-align: top;
width: 100%;
}
.uikit__section > .heading > .toggle {
background-color: transparent;
border: 0;
color: inherit;
cursor: pointer;
font-size: inherit;
font-weight: inherit;
overflow: hidden;
padding: 0 18px 0 0;
position: relative;
}
.uikit__chevron-up,
.uikit__chevron-down {
fill: currentColor;
position: absolute;
right: 0;
top: 50%;
transform: translate(0, -50%);
}
.uikit__chevron-up {
display: none;
}
.uikit__section > .heading > .toggle[aria-expanded="true"] .uikit__chevron-up,
.uikit__chevron-down {
display: block;
}
.uikit__section > .heading > .toggle[aria-expanded="true"] .uikit__chevron-down {
display: none;
}
.uikit__section > .content {
box-sizing: border-box;
display: inline-block;
margin-bottom: 100px;
vertical-align: top;
width: 100%;
}
.uikit__section > .content[hidden] {
display: none;
}
.uikit-mb-1 {
margin-bottom: 1em;
}
@media (--bp-uikit-small) {
.uikit__section > .heading {
width: 145px;
}
.uikit__section.-secondary > .heading {
width: 100%;
}
.uikit__section > .content {
width: calc(100% - 150px);
}
.uikit__section.-secondary > .content {
width: 100%;
}
}
================================================
FILE: assets/fonts/font-name/.gitkeep
================================================
# Basically just want to ignore the directory contents
================================================
FILE: assets/images/.gitkeep
================================================
# Basically just want to ignore the directory contents
================================================
FILE: assets/js/admin/admin.js
================================================
// import foo from './bar'
================================================
FILE: assets/js/blocks/blocks.js
================================================
/**
* Gutenberg block-specific JavaScript:
* used on front-end and/or in editor
*/
// import example-block-1 from './example-block-1';
================================================
FILE: assets/js/blocks/example-block-1.js
================================================
/**
* Gutenberg block-specific JavaScript:
* used on front-end and/or in editor
*/
/**
* Block 1 JavaScript
*/
================================================
FILE: assets/js/frontend/components/.gitkeep
================================================
# Basically just want to ignore the directory contents
================================================
FILE: assets/js/frontend/frontend.js
================================================
// import foo from './components/bar';
================================================
FILE: assets/js/shared/shared.js
================================================
// import foo from './bar'
================================================
FILE: assets/js/styleguide/styleguide.js
================================================
import UIKitSection from './uikitsection';
const uiKitSection = new UIKitSection(document.querySelectorAll('.uikit__section h2.heading'));
uiKitSection.init();
================================================
FILE: assets/js/styleguide/uikitsection.js
================================================
/**
* @module UIKitSection
*
* @description
*
* Collapsible UI kit sections
*
*/
export default class UIKitSection {
/**
* Initialize everything
*
* @param {Element[]} elements Section Heading elements.
*/
constructor(elements) {
// Grab all the UI kit section headings
this.sectionHeadings = elements;
}
/**
* Inits UI Kit Section
*/
init() {
// Stop if there's no section heading
if (!this.sectionHeadings) {
console.error( 'Styleguide: No sections detected.' ); // eslint-disable-line
return;
}
this.sectionHeadings.forEach((sectionHeading) => {
this.setupCollapsible(sectionHeading);
});
}
/**
* Create a button, add chevron SVG and inject in heading
* Hide section content, set ARIA attributes
*
* @param {Element} sectionHeading The UI Kit section heading
*
*/
setupCollapsible(sectionHeading) {
// Get section ID
const sectionID = sectionHeading.parentNode.id;
// Default state
let expanded = true;
// Check localStorage to see if we want to expand some sections by default
if (localStorage) {
// Override expanded state
expanded = localStorage.getItem(`section-${sectionID}`) !== 'true' || false;
}
// Build the button, add the SVG chevron icons
// eslint-disable-next-line no-param-reassign
sectionHeading.innerHTML = `
`;
// Get the section content and hide it
const wrapper = sectionHeading.parentNode.querySelector('.content');
wrapper.hidden = expanded;
wrapper.setAttribute('aria-hidden', expanded);
wrapper.setAttribute('aria-labelledby', `toggle-${sectionID}`);
// Assign click event to the button
const button = sectionHeading.querySelector('button');
button.onclick = (e) => this.toggleCollapsible(e, wrapper, button);
}
/**
* Toggles a section
*
* @param {Object} e The click event
* @param {Element} wrapper The UI Kit section content
* @param {Element} button The UI Kit section toggle button
*
*/
toggleCollapsible(e, wrapper, button) {
// Expanded state as bool
const expanded = button.getAttribute('aria-expanded') === 'true' || false;
// Toggle expanded state and visibility
button.setAttribute('aria-expanded', !expanded);
// eslint-disable-next-line no-param-reassign
wrapper.hidden = expanded;
wrapper.setAttribute('aria-hidden', expanded);
// Store expanded state in localStorage
const sectionID = wrapper.parentNode.id;
if (localStorage) {
localStorage.setItem(`section-${sectionID}`, !expanded);
}
}
}
================================================
FILE: assets/svg/.gitkeep
================================================
# Basically just want to ignore the directory contents
================================================
FILE: babel.config.js
================================================
/**
* Babel Config, .babelrc equivalent.
*
* @package
* @type {{presets: [[]|string|Object]}}
*/
module.exports = {
presets: [
[
'@10up/babel-preset-default',
{
wordpress: true,
},
],
],
};
================================================
FILE: composer.json
================================================
{
"name": "10up/tenup-scaffold",
"type": "wordpress-theme",
"authors": [
{
"name": "10up",
"email": "info@10up.com"
}
],
"require": {
"php": ">=7.0"
},
"autoload": {
"psr-4": {
"TenUpScaffold\\": "includes/classes/"
}
},
"minimum-stability": "dev",
"prefer-stable": true,
"require-dev": {
"10up/wpacceptance": "dev-master",
"10up/phpcs-composer": "dev-master"
},
"scripts": {
"lint": "phpcs .",
"lint-fix": "phpcbf ."
}
}
================================================
FILE: config/webpack.config.common.js
================================================
const path = require('path');
const { CleanWebpackPlugin } = require('clean-webpack-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const FixStyleOnlyEntriesPlugin = require('webpack-fix-style-only-entries');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const StyleLintPlugin = require('stylelint-webpack-plugin');
const WebpackBar = require('webpackbar');
const ImageminPlugin = require('imagemin-webpack-plugin').default;
const isProduction = process.env.NODE_ENV === 'production';
// Config files.
const settings = require('./webpack.settings.js');
/**
* Configure entries.
*
* @return {Object[]} Array of webpack settings.
*/
const configureEntries = () => {
const entries = {};
for (const [key, value] of Object.entries(settings.entries)) {
entries[key] = path.resolve(process.cwd(), value);
}
return entries;
};
module.exports = {
entry: configureEntries(),
output: {
path: path.resolve(process.cwd(), settings.paths.dist.base),
filename: settings.filename.js,
/**
* If multiple webpack runtimes (from different compilations) are used on the same webpage,
* there is a risk of conflicts of on-demand chunks in the global namespace.
*
* @see (@link https://webpack.js.org/configuration/output/#outputjsonpfunction)
*/
jsonpFunction: '__TenUpScaffold_webpackJsonp',
},
// Console stats output.
// @link https://webpack.js.org/configuration/stats/#stats
stats: settings.stats,
// External objects.
externals: {
jquery: 'jQuery',
lodash: 'lodash',
},
// Performance settings.
performance: {
maxAssetSize: settings.performance.maxAssetSize,
},
// Build rules to handle asset files.
module: {
rules: [
// Lint JS.
{
test: /\.js$/,
enforce: 'pre',
loader: 'eslint-loader',
options: {
fix: true,
},
},
// Scripts.
{
test: /\.js$/,
exclude: /node_modules(?!\/@10up)/,
use: [
{
loader: 'babel-loader',
options: {
cacheDirectory: true,
sourceMap: !isProduction,
},
},
],
},
// Styles.
{
test: /\.css$/,
include: path.resolve(process.cwd(), settings.paths.src.css),
use: [
{
loader: MiniCssExtractPlugin.loader,
},
{
loader: 'css-loader',
options: {
sourceMap: !isProduction,
// We copy fonts etc. using CopyWebpackPlugin.
url: false,
},
},
{
loader: 'postcss-loader',
options: {
sourceMap: !isProduction,
},
},
],
},
],
},
plugins: [
// Remove the extra JS files Webpack creates for CSS entries.
// This should be fixed in Webpack 5.
new FixStyleOnlyEntriesPlugin({
silent: true,
}),
// Clean the `dist` folder on build.
new CleanWebpackPlugin({
cleanStaleWebpackAssets: false,
}),
// Extract CSS into individual files.
new MiniCssExtractPlugin({
filename: settings.filename.css,
chunkFilename: '[id].css',
}),
// Copy static assets to the `dist` folder.
new CopyWebpackPlugin([
{
from: settings.copyWebpackConfig.from,
to: settings.copyWebpackConfig.to,
context: path.resolve(process.cwd(), settings.paths.src.base),
},
]),
// Compress images
// Must happen after CopyWebpackPlugin
new ImageminPlugin({
disable: !isProduction,
test: settings.ImageminPlugin.test,
}),
// Lint CSS.
new StyleLintPlugin({
context: path.resolve(process.cwd(), settings.paths.src.css),
files: '**/*.css',
}),
// Fancy WebpackBar.
new WebpackBar(),
],
};
================================================
FILE: config/webpack.config.dev.js
================================================
const merge = require('webpack-merge');
const BrowserSyncPlugin = require('browser-sync-webpack-plugin');
const common = require('./webpack.config.common.js');
// Config files.
const settings = require('./webpack.settings.js');
module.exports = merge(common, {
mode: 'development',
devtool: 'inline-cheap-module-source-map',
plugins: [
// Run BrowserSync.
new BrowserSyncPlugin(
{
host: settings.BrowserSyncConfig.host,
port: settings.BrowserSyncConfig.port,
proxy: settings.BrowserSyncConfig.proxy,
open: settings.BrowserSyncConfig.open,
files: settings.BrowserSyncConfig.files,
},
{
injectCss: true,
reload: false,
},
),
],
});
================================================
FILE: config/webpack.config.prod.js
================================================
const merge = require('webpack-merge');
const TerserPlugin = require('terser-webpack-plugin'); // eslint-disable-line import/no-extraneous-dependencies
const common = require('./webpack.config.common.js');
module.exports = merge(common, {
mode: 'production',
optimization: {
minimizer: [
new TerserPlugin({
cache: true,
parallel: true,
sourceMap: false,
terserOptions: {
parse: {
// We want terser to parse ecma 8 code. However, we don't want it
// to apply any minfication steps that turns valid ecma 5 code
// into invalid ecma 5 code. This is why the 'compress' and 'output'
// sections only apply transformations that are ecma 5 safe
// https://github.com/facebook/create-react-app/pull/4234
ecma: 8,
},
compress: {
ecma: 5,
warnings: false,
// Disabled because of an issue with Uglify breaking seemingly valid code:
// https://github.com/facebook/create-react-app/issues/2376
// Pending further investigation:
// https://github.com/mishoo/UglifyJS2/issues/2011
comparisons: false,
// Disabled because of an issue with Terser breaking valid code:
// https://github.com/facebook/create-react-app/issues/5250
// Pending futher investigation:
// https://github.com/terser-js/terser/issues/120
inline: 2,
},
output: {
ecma: 5,
comments: false,
},
ie8: false,
},
}),
],
},
});
================================================
FILE: config/webpack.settings.js
================================================
// Webpack settings exports.
module.exports = {
entries: {
// JS files.
admin: './assets/js/admin/admin.js',
blocks: './assets/js/blocks/blocks.js',
frontend: './assets/js/frontend/frontend.js',
shared: './assets/js/shared/shared.js',
styleguide: './assets/js/styleguide/styleguide.js',
'blocks-editor': './includes/blocks/blocks-editor.js',
// CSS files.
'admin-style': './assets/css/admin/admin-style.css',
'editor-style': './assets/css/frontend/editor-style.css',
'shared-style': './assets/css/shared/shared-style.css',
style: './assets/css/frontend/style.css',
'styleguide-style': './assets/css/styleguide/styleguide.css',
},
filename: {
js: 'js/[name].js',
css: 'css/[name].css',
},
paths: {
src: {
base: './assets/',
css: './assets/css/',
js: './assets/js/',
},
dist: {
base: './dist/',
clean: ['./images', './css', './js'],
},
},
stats: {
// Copied from `'minimal'`.
all: false,
errors: true,
maxModules: 0,
modules: true,
warnings: true,
// Our additional options.
assets: true,
errorDetails: true,
excludeAssets: /\.(jpe?g|png|gif|svg|woff|woff2)$/i,
moduleTrace: true,
performance: true,
},
copyWebpackConfig: {
from: '**/*.{jpg,jpeg,png,gif,svg,eot,ttf,woff,woff2}',
to: '[path][name].[ext]',
},
ImageminPlugin: {
test: /\.(jpe?g|png|gif|svg)$/i,
},
BrowserSyncConfig: {
host: 'localhost',
port: 3000,
proxy: 'http://tenup-scaffold.test',
open: false,
files: [
'**/*.php',
'dist/js/**/*.js',
'dist/css/**/*.css',
'dist/svg/**/*.svg',
'dist/images/**/*.{jpg,jpeg,png,gif}',
'dist/fonts/**/*.{eot,ttf,woff,woff2,svg}',
],
},
performance: {
maxAssetSize: 100000,
},
manifestConfig: {
basePath: '',
},
};
================================================
FILE: footer.php
================================================