Skip to content

Commit

Permalink
Build process with Laravel Mix. Switches the dev CSS to use SCSS. Org…
Browse files Browse the repository at this point in the history
…anizes the dev JS and SCSS files.
  • Loading branch information
justintadlock committed Jun 25, 2019
1 parent ac6c259 commit b9945de
Show file tree
Hide file tree
Showing 12 changed files with 9,713 additions and 54 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
composer.lock
/node_modules
/vendor
/composer.lock
*.map
9,540 changes: 9,540 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

28 changes: 28 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "customize-section-button",
"version": "1.0.0",
"author": "WPTRT",
"license": "GPL-2.0+",
"homepage": "https://github.com/WPTRT/customize-section-button",
"main": "",
"scripts": {
"dev": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"watch": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"prod": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/WPTRT/customize-section-button.git"
},
"bugs": {
"url": "https://github.com/WPTRT/customize-section-button/issues"
},
"devDependencies": {
"cross-env": "^5.2.0",
"laravel-mix": "^4.0.16",
"postcss-preset-env": "^6.6.0",
"sass": "^1.22.0",
"sass-loader": "^7.1.0",
"vue-template-compiler": "^2.6.10"
}
}
17 changes: 1 addition & 16 deletions public/css/customize-controls.css

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 1 addition & 11 deletions public/js/customize-controls.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions public/mix-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"/js/customize-controls.js": "/js/customize-controls.js?id=89773d0dfda85acd340f",
"/css/customize-controls.css": "/css/customize-controls.css?id=06bbe20903aac0ce7de7"
}
16 changes: 0 additions & 16 deletions resources/css/customize-controls.css

This file was deleted.

23 changes: 13 additions & 10 deletions resources/js/customize-controls.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
/**
* Customize Controls.
*
* This is the primary script for the customize controls panel. Use this file
* importing scripts for custom panels, sections, and controls.
*
* @package CustomizeSectionButton
* @author WPTRT <themes@wordpress.org>
* @copyright 2019 WPTRT
* @license https://www.gnu.org/licenses/gpl-2.0.html GPL-2.0-or-later
* @link https://github.com/WPTRT/customize-section-button
*/

wp.customize.sectionConstructor['wptrt-button'] = wp.customize.Section.extend( {

// No events for this type of section.
attachEvents: function () {},

// Always make the section active.
isContextuallyActive: function () {
return true;
}
} );
import sectionButton from './customize-controls/section-button';
20 changes: 20 additions & 0 deletions resources/js/customize-controls/section-button.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
/**
* Button Customize Section.
*
* @package CustomizeSectionButton
* @author WPTRT <themes@wordpress.org>
* @copyright 2019 WPTRT
* @license https://www.gnu.org/licenses/gpl-2.0.html GPL-2.0-or-later
* @link https://github.com/WPTRT/customize-section-button
*/

wp.customize.sectionConstructor['wptrt-button'] = wp.customize.Section.extend( {

// No events for this type of section.
attachEvents: () => {},

// Always make the section active.
isContextuallyActive: () => {
return true;
}
} );
14 changes: 14 additions & 0 deletions resources/scss/customize-controls.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
////
/// Customize controls stylesheet.
///
/// This is the primary stylesheet for the customize controls panel. Use this
/// for importing styles for custom panels, sections, and controls.
///
/// @group Styles
/// @author WPTRT <themes@wordpress.org>
/// @link https://github.com/WPTRT/customize-section-button
////

// Import components.

@import 'customize-controls/section-button';
35 changes: 35 additions & 0 deletions resources/scss/customize-controls/_section-button.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
////
/// Button section.
///
/// @group Components
/// @author WPTRT <themes@wordpress.org>
/// @link https://github.com/WPTRT/customize-section-button
////

.control-section-wptrt-button {

.accordion-section-title {

// Make sure that the background color doesn't change if the
// section title is hovered or focused because this is an
// non-expandable section.
&:hover,
&:focus {
background-color: #fff;
}

// Adjusts the button to make sure it's vertically aligned in
// the section title and provide some margin horizontally to
// keep text from butting against it.
.button {
margin-top: -4px;
margin-left: 8px;
font-weight: 400;

.rtl & {
margin-left: 0;
margin-right: 8px;
}
}
}
}
54 changes: 54 additions & 0 deletions webpack.mix.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/**
* Lavarel Mix Config.
*
* Laravel Mix is a simplified wrapper for Webpack. Use this file to add CSS/JS
* files to compile.
*
* @package CustomizeSectionButton
* @author WPTRT <themes@wordpress.org>
* @copyright 2019 WPTRT
* @license https://www.gnu.org/licenses/gpl-2.0.html GPL-2.0-or-later
* @link https://github.com/WPTRT/customize-section-button
*/

// Import required packages.
const mix = require( 'laravel-mix' );

// Set dev path.
const devPath = 'resources';

// Set public path.
mix.setPublicPath( 'public' );

// Set options.
mix.options( {
postCss : [ require( 'postcss-preset-env' )() ],
processCssUrls : false
} );

// Source maps.
mix.sourceMaps();

// Versioning and cache-busting with `mix-manifest.json`.
mix.version();

// Compile JS.
mix.js( `${devPath}/js/customize-controls.js`, 'js' );

// Sass configuration.
var sassConfig = {
outputStyle : 'expanded',
indentType : 'tab',
indentWidth : 1
};

// Compile SASS/CSS.
mix.sass( `${devPath}/scss/customize-controls.scss`, 'css', sassConfig );

// Extra Webpack config.
mix.webpackConfig( {
stats : 'minimal',
devtool : mix.inProduction() ? false : 'source-map',
performance : { hints : false },
externals : { jquery : 'jQuery' },
} );

0 comments on commit b9945de

Please sign in to comment.