Skip to content

Auto-inject import sass variables #352

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 1 addition & 7 deletions apps/pl/scss/_scss2json.scss
Original file line number Diff line number Diff line change
@@ -1,10 +1,4 @@
/* Sass Variables to Map to JSON */

// Import Everything from Base.
// This includes Bootstrap
@import '../../../source/_patterns/00-protons/variables';
// Import the map of available custom svg icons.
@import '../../../source/_patterns/01-atoms/svgicon/scss/_icons-generated';
// Sass Variables to Map to JSON

// Customized Sass Mapping
// Pulled from Bootstrap's _variables.scss
Expand Down
4 changes: 3 additions & 1 deletion source/_patterns/00-protons/_base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
/// This guarantees both de-duplication and existence of required, generated CSS.
///

@import 'variables';
// The non-printing variables, functions, and mixins of 00-protons/variables
// are provided to this file via:
// webpack.particle.dev.js: sass-loader.data|includePaths

// Bootstrap CSS-generating output
@import '~bootstrap/scss/root';
Expand Down
36 changes: 18 additions & 18 deletions source/_patterns/00-protons/_variables.scss
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
///
/// Global VARIABLES and HELPERS
///
/// Place global config here like Bootstrap's _variables.scss.
/// This kind of config is often required prior to importing any libraries (ie Bootstrap Sass), and
/// does not produce any CSS, just variables and maps.
///
/// All .scss files NEED TO INCLUDE this file as the top import to ensure consistent settings.
/// Particle does not glob Sass! Because there is no printing CSS output in this file, webpack will
/// safely squash any duplication.
///
/// @example
/// ```scss
/// @import '../../00-protons/variables';
/// ```
/// This guarantees every component is styled with the same presets.
///
//
// Global VARIABLES and HELPERS
//
// Place global config here like Bootstrap's _variables.scss.
// This kind of config is often required prior to importing any libraries
// (ie Bootstrap Sass), and does not produce any CSS, just variables and maps.
//
// This file is provided AUTOMATICALLY to every .scss file on the dependency
// chain via the configuration of the sass-loader within webpack.particle.dev.js.
// In other words, every .scss within Particle has `@import 00-protons/variables`
// silently injected into the first line.
//
// As long as everything within this files DOES NOT PRINT CSS, there will be
// no duplicated output. Again, for the people in the back:
//
// THIS FILE CONTAINS ONLY NON-PRINTING SASS, LIKE VARIABLES, MIXINS, & FUNCTIONS
//

// Custom non-printing tools
@import 'non-printing/functions';
Expand All @@ -40,7 +40,7 @@ $spacing: (
// @import 'non-printing/project-specific-mixins'

// Generated SVG icons and sprite mixins
@import '../01-atoms/svgicon/scss/_icons-generated.scss';
@import '01-atoms/svgicon/scss/_icons-generated';

// Font Awesome tools
@import '~font-awesome/scss/variables';
Expand Down
4 changes: 3 additions & 1 deletion source/_patterns/00-protons/printing/_forms.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
@import '../variables';
// The non-printing variables, functions, and mixins of 00-protons/variables
// are provided to this file via:
// webpack.particle.dev.js: sass-loader.data|includePaths

// Bootstrap override variables go here.
// See available vars in ~bootstrap/scss/_variables.scss, i.e.
Expand Down
4 changes: 3 additions & 1 deletion source/_patterns/00-protons/printing/_html-elements.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
@import '../variables';
// The non-printing variables, functions, and mixins of 00-protons/variables
// are provided to this file via:
// webpack.particle.dev.js: sass-loader.data|includePaths

// Use this file for any global layout rules you want applied after
// Bootstrap's Reboot does it's thing, but don't necessarily fit into
Expand Down
4 changes: 3 additions & 1 deletion source/_patterns/00-protons/printing/_tables.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
@import '../variables';
// The non-printing variables, functions, and mixins of 00-protons/variables
// are provided to this file via:
// webpack.particle.dev.js: sass-loader.data|includePaths

// Bootstrap override variables go here.
// See available vars in ~bootstrap/scss/_variables.scss, i.e.
Expand Down
4 changes: 3 additions & 1 deletion source/_patterns/00-protons/printing/_transitions.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
@import '../variables';
// The non-printing variables, functions, and mixins of 00-protons/variables
// are provided to this file via:
// webpack.particle.dev.js: sass-loader.data|includePaths

// Bootstrap override variables go here.
// See available vars in ~bootstrap/scss/_variables.scss, i.e.
Expand Down
4 changes: 3 additions & 1 deletion source/_patterns/00-protons/printing/_type.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
@import '../variables';
// The non-printing variables, functions, and mixins of 00-protons/variables
// are provided to this file via:
// webpack.particle.dev.js: sass-loader.data|includePaths

// Bootstrap override variables go here.
// See available vars in ~bootstrap/scss/_variables.scss, i.e.
Expand Down
5 changes: 3 additions & 2 deletions source/_patterns/01-atoms/alert/_alert.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// All component Sass needs non-printing base config
@import '../../00-protons/variables';
// The non-printing variables, functions, and mixins of 00-protons/variables
// are provided to this file via:
// webpack.particle.dev.js: sass-loader.data|includePaths

// To change default bootstrap alert variables, SEE ~bootstrap/scss/variables
// Add bootstrap variables here
Expand Down
4 changes: 3 additions & 1 deletion source/_patterns/01-atoms/badge/_badge.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
@import '../../00-protons/variables';
// The non-printing variables, functions, and mixins of 00-protons/variables
// are provided to this file via:
// webpack.particle.dev.js: sass-loader.data|includePaths

// To change default bootstrap list-item variables,
// copy from ~bootstrap/scss/variables to here
Expand Down
5 changes: 3 additions & 2 deletions source/_patterns/01-atoms/branding/_branding.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// All component Sass needs non-printing base config
@import '../../00-protons/variables';
// The non-printing variables, functions, and mixins of 00-protons/variables
// are provided to this file via:
// webpack.particle.dev.js: sass-loader.data|includePaths

// To change default bootstrap card variables, SEE ~bootstrap/scss/variables
// Add bootstrap variables here
Expand Down
5 changes: 3 additions & 2 deletions source/_patterns/01-atoms/breadcrumb/_breadcrumb.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// All component Sass needs non-printing base config
@import '../../00-protons/variables';
// The non-printing variables, functions, and mixins of 00-protons/variables
// are provided to this file via:
// webpack.particle.dev.js: sass-loader.data|includePaths

// To change default bootstrap breadcrumb variables, SEE ~bootstrap/scss/variables
// Add bootstrap variables here
Expand Down
4 changes: 3 additions & 1 deletion source/_patterns/01-atoms/button/_button.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
@import '../../00-protons/variables';
// The non-printing variables, functions, and mixins of 00-protons/variables
// are provided to this file via:
// webpack.particle.dev.js: sass-loader.data|includePaths

// To change default bootstrap card variables,
// copy from ~bootstrap/scss/variables to here
Expand Down
4 changes: 3 additions & 1 deletion source/_patterns/01-atoms/dropdown/_dropdown.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
@import '../../00-protons/variables';
// The non-printing variables, functions, and mixins of 00-protons/variables
// are provided to this file via:
// webpack.particle.dev.js: sass-loader.data|includePaths

// To change default bootstrap nav variables,
// copy from ~bootstrap/scss/variables to here
Expand Down
8 changes: 7 additions & 1 deletion source/_patterns/01-atoms/grid/_grid.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
@import '../../00-protons/variables';
// The non-printing variables, functions, and mixins of 00-protons/variables
// are provided to this file via:
// webpack.particle.dev.js: sass-loader.data|includePaths

// The non-printing variables, functions, and mixins of 00-protons/variables
// are provided to this file via:
// webpack.particle.dev.js: sass-loader.data|includePaths

// Bootstrap override variables go here.
// See available vars in ~bootstrap/scss/_variables.scss
Expand Down
4 changes: 3 additions & 1 deletion source/_patterns/01-atoms/image/_image.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
@import '../../00-protons/variables';
// The non-printing variables, functions, and mixins of 00-protons/variables
// are provided to this file via:
// webpack.particle.dev.js: sass-loader.data|includePaths

// Override any Bootstrap image vars here
@import '~bootstrap/scss/images';
Expand Down
4 changes: 3 additions & 1 deletion source/_patterns/01-atoms/list-group/_list-group.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
@import '../../00-protons/variables';
// The non-printing variables, functions, and mixins of 00-protons/variables
// are provided to this file via:
// webpack.particle.dev.js: sass-loader.data|includePaths

// To change default bootstrap list-item variables,
// copy from ~bootstrap/scss/variables to here
Expand Down
11 changes: 8 additions & 3 deletions source/_patterns/01-atoms/svgicon/_svgicon.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
// All component Sass needs non-printing base config
@import '../../00-protons/variables';
@import './scss/_icons-generated';
// The non-printing variables, functions, and mixins of 00-protons/variables
// are provided to this file via:
// webpack.particle.dev.js: sass-loader.data|includePaths

// Note!
// ./scss/_icons-generated is automatically made available because
// 00-protons/variables is provided to every scss file and _icons-generated
// is @import'd within 00-protons/variables

// Default styles to maintain inline-block functionality
// since the SVG is wrapped in a div
Expand Down
5 changes: 3 additions & 2 deletions source/_patterns/01-atoms/svgicon/demo/_svgicon-demo.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// All component Sass needs non-printing base config
@import '../../../00-protons/variables';
// The non-printing variables, functions, and mixins of 00-protons/variables
// are provided to this file via:
// webpack.particle.dev.js: sass-loader.data|includePaths

.svgicon-demo--particle-mixin {
@include sprite('person');
Expand Down
10 changes: 6 additions & 4 deletions source/_patterns/02-molecules/card/_card.scss
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
// All component Sass needs non-printing base config
@import '../../00-protons/variables';
// The non-printing variables, functions, and mixins of 00-protons/variables
// are provided to this file via:
// webpack.particle.dev.js: sass-loader.data|includePaths

// To change default bootstrap card variables, SEE ~bootstrap/scss/variables
// Add bootstrap variables here
// To change default Bootstrap card variables, see ~bootstrap/scss/variables
// and then add Bootstrap variables here
$card-border-width: 1px;

// Then import the Bootstrap component styles
@import '~bootstrap/scss/card';

// Add custom code here
Expand Down
5 changes: 3 additions & 2 deletions source/_patterns/02-molecules/carousel/_carousel.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// All component Sass needs non-printing base config
@import '../../00-protons/variables';
// The non-printing variables, functions, and mixins of 00-protons/variables
// are provided to this file via:
// webpack.particle.dev.js: sass-loader.data|includePaths

// To change default bootstrap carousel variables, SEE ~bootstrap/scss/variables
// Add bootstrap variables here
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// All component Sass needs non-printing base config
@import '../../00-protons/variables';
// The non-printing variables, functions, and mixins of 00-protons/variables
// are provided to this file via:
// webpack.particle.dev.js: sass-loader.data|includePaths

.example-widget {
}
5 changes: 3 additions & 2 deletions source/_patterns/02-molecules/jumbotron/_jumbotron.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// All component Sass needs non-printing base config
@import '../../00-protons/variables';
// The non-printing variables, functions, and mixins of 00-protons/variables
// are provided to this file via:
// webpack.particle.dev.js: sass-loader.data|includePaths

// To change default bootstrap jumbotron variables, SEE ~bootstrap/scss/variables
// Add bootstrap variables here
Expand Down
4 changes: 3 additions & 1 deletion source/_patterns/02-molecules/nav/_nav.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
@import '../../00-protons/variables';
// The non-printing variables, functions, and mixins of 00-protons/variables
// are provided to this file via:
// webpack.particle.dev.js: sass-loader.data|includePaths

// To change default bootstrap nav variables,
// copy from ~bootstrap/scss/variables to here
Expand Down
5 changes: 3 additions & 2 deletions source/_patterns/02-molecules/pagination/_pagination.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// All component Sass needs non-printing base config
@import '../../00-protons/variables';
// The non-printing variables, functions, and mixins of 00-protons/variables
// are provided to this file via:
// webpack.particle.dev.js: sass-loader.data|includePaths

// To change default bootstrap variables, SEE ~bootstrap/scss/variables
// Add bootstrap variables here
Expand Down
5 changes: 3 additions & 2 deletions source/_patterns/03-organisms/accordion/_accordion.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// All component Sass needs non-printing base config
@import '../../00-protons/variables';
// The non-printing variables, functions, and mixins of 00-protons/variables
// are provided to this file via:
// webpack.particle.dev.js: sass-loader.data|includePaths

// Accordion contains both Bootstrap Card and Collapse.
// To change default bootstrap variables, SEE ~bootstrap/scss/variables
Expand Down
5 changes: 3 additions & 2 deletions source/_patterns/03-organisms/article/_article.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// All component Sass needs non-printing base config
@import '../../00-protons/variables';
// The non-printing variables, functions, and mixins of 00-protons/variables
// are provided to this file via:
// webpack.particle.dev.js: sass-loader.data|includePaths

// Add custom code here
5 changes: 3 additions & 2 deletions source/_patterns/03-organisms/footer/_footer.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// All component Sass needs non-printing base config
@import '../../00-protons/variables';
// The non-printing variables, functions, and mixins of 00-protons/variables
// are provided to this file via:
// webpack.particle.dev.js: sass-loader.data|includePaths

.footer {
}
4 changes: 3 additions & 1 deletion source/_patterns/03-organisms/navbar/_navbar.scss
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
@import '../../00-protons/variables';
// The non-printing variables, functions, and mixins of 00-protons/variables
// are provided to this file via:
// webpack.particle.dev.js: sass-loader.data|includePaths

// To change default bootstrap navbar variables,
// copy from ~bootstrap/scss/variables to here
Expand Down
5 changes: 3 additions & 2 deletions source/_patterns/04-templates/basic-page/_basic-page.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// All component Sass needs non-printing base config
@import '../../00-protons/variables';
// The non-printing variables, functions, and mixins of 00-protons/variables
// are provided to this file via:
// webpack.particle.dev.js: sass-loader.data|includePaths

.basic-page {
@include full-width();
Expand Down
5 changes: 3 additions & 2 deletions tools/new-component/templates/_pattern.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// All component Sass needs non-printing base config
@import '../../00-protons/variables';
// The non-printing variables, functions, and mixins of 00-protons/variables
// are provided to this file via:
// webpack.particle.dev.js: sass-loader.data|includePaths

.<%= name %> {
}
12 changes: 11 additions & 1 deletion webpack.particle.dev.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,17 @@ module.exports = {
{ loader: 'resolve-url-loader' },
{
loader: 'sass-loader',
options: { sourceMap: true, functions: sassExportData },
options: {
// ALL Sass partials should be provided with non-printing
// variables, mixins, and functions
data: '@import "00-protons/variables";',
// Enable Sass to import other components via, eg:
// `@import 01-atoms/thing/thing`
includePaths: [path.resolve(__dirname, './source/_patterns')],
// Used to generate JSON about variables like colors, fonts
functions: sassExportData,
sourceMap: true,
},
},
],
},
Expand Down
12 changes: 11 additions & 1 deletion webpack.particle.prod.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,17 @@ const prod = {
{ loader: 'resolve-url-loader' },
{
loader: 'sass-loader',
options: { sourceMap: true, functions: sassExportData },
options: {
// ALL Sass partials should be provided with non-printing
// variables, mixins, and functions
data: '@import "00-protons/variables";',
// Enable Sass to import other components via, eg:
// `@import 01-atoms/thing/thing`
includePaths: [path.resolve(__dirname, './source/_patterns')],
// Used to generate JSON about variables like colors, fonts
functions: sassExportData,
sourceMap: true,
},
},
],
}),
Expand Down