Skip to content

chore: CSS build improvements (closes #2917) #3055

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 11 commits into from
Apr 9, 2019
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
14 changes: 11 additions & 3 deletions docs/markdown/intro/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import 'bootstrap/dist/css/bootstrap.css'
import 'bootstrap-vue/dist/bootstrap-vue.css'
```

Or import Bootstrap and BootstrapVue `scss` files via a custom SCSS file:
Or import Bootstrap and BootstrapVue `scss` files via a single custom SCSS file:

```scss
// custom.scss
Expand All @@ -50,12 +50,20 @@ Or import Bootstrap and BootstrapVue `scss` files via a custom SCSS file:
import 'custom.scss'
```

Be sure to include your custom variables before `bootstrap.scss` and include BootstrapVue SCSS
_after_ Bootstrap SCSS to ensure variables are set up correctly.
Be sure to `@import` or define your custom variable values _before_ including Bootstrap SCSS
(`bootstrap.scss`), and include BootstrapVue SCSS (`bootstrap-vue.scss`) _after that_ to ensure
variables are set up correctly.

Make sure you place all the SCSS `@import`s into a single SCSS file, and import that single file
into your project. Importing individual SCSS files into your project will **not** share variable
values and functions between files by default.

**Note**: _Requires webpack configuration to load CSS/SCSS files
([official guide](https://webpack.js.org/guides/asset-management/#loading-css))_.

For information on theming Bootstrap, check out the [Theming](/docs/reference/theming) reference
section.

## Nuxt.js Module

[Nuxt.js](https://nuxtjs.org) version {{ nuxtVersion }} (or greater) is recommended.
Expand Down
2 changes: 1 addition & 1 deletion docs/nuxt.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ module.exports = {
'highlightjs/styles/atom-one-light.css',
'codemirror/lib/codemirror.css',
'bootstrap/dist/css/bootstrap.css',
'../src/index.scss', // BootstrapVue SCSS
'../scripts/build.scss', // BootstrapVue SCSS
'@assets/css/docs.min.css',
'@assets/scss/styles.scss'
]
Expand Down
11 changes: 11 additions & 0 deletions scripts/build.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*!
* BootstrapVue Custom CSS (https://bootstrap-vue.js.org)
*/

// Include Bootstrap functions, variables, and mixins
@import "node_modules/bootstrap/scss/functions";
@import "node_modules/bootstrap/scss/variables";
@import "node_modules/bootstrap/scss/mixins";

// Import BootstrapVue custom SCSS
@import "../src/index.scss";
2 changes: 1 addition & 1 deletion scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ node-sass --output-style expanded \
--source-map true \
--source-map-contents true \
--precision 6 \
src/index.scss \
scripts/build.scss \
dist/bootstrap-vue.css
postcss --config scripts/postcss.config.js \
--replace dist/bootstrap-vue.css
Expand Down
6 changes: 3 additions & 3 deletions src/_utilities.scss
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// Bootstrap Vue Utility classes
// --- BootstrapVue Utility Classes ---

$bv-utility-classes-defined: false !default;

// Make sure to include these style definitions only once
@if $bv-utility-classes-defined == false {
// This test will only include these style definitions once
$bv-utility-classes-defined: true;

// Create .bv-d-<bp>-down-none helper classes
// Create `.bv-d-<bp>-down-none` helper classes
@each $breakpoint in map-keys($grid-breakpoints) {
@include media-breakpoint-down($breakpoint) {
.bv-d-#{$breakpoint}-down-none {
Expand Down
6 changes: 2 additions & 4 deletions src/_variables.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
// Alerts

// --- Alerts ---
$bv-alert-transition: $transition-fade !default;

// Tables

// --- Tables ---
$b-table-busy-opacity: 0.55 !default;
2 changes: 1 addition & 1 deletion src/components/button/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "1.0.0",
"meta": {
"title": "Button",
"description": "Use Bootstrap Vue’s <b-button> component for actions in forms, dialogs, and more. Includes support for a handful of contextual variations, sizes, states, and more.",
"description": "Use BootstrapVue’s <b-button> component for actions in forms, dialogs, and more. Includes support for a handful of contextual variations, sizes, states, and more.",
"components": [
{
"component": "BButton",
Expand Down
4 changes: 2 additions & 2 deletions src/components/dropdown/_dropdown-form.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ $bv-dropdown-form-defined: false !default;
// This test will only include these style definitions once
$bv-dropdown-form-defined: true;

// Custom styles for b-dropdown-form
// Based on class .dropdown-item
// Custom styles for <b-dropdown-form>
// Based on class `.dropdown-item`
.b-dropdown-form {
display: inline-block;
padding: $dropdown-item-padding-y $dropdown-item-padding-x;
Expand Down
4 changes: 2 additions & 2 deletions src/components/dropdown/_dropdown-text.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ $bv-dropdown-text-defined: false !default;
// This test will only include these style definitions once
$bv-dropdown-text-defined: true;

// Custom styles for b-dropdown-text
// Based on class .dropdown-item
// Custom styles for <b-dropdown-text>
// Based on class `.dropdown-item`
.b-dropdown-text {
display: inline-block;
padding: $dropdown-item-padding-y $dropdown-item-padding-x;
Expand Down
4 changes: 2 additions & 2 deletions src/components/dropdown/_dropdown.scss
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
$bv-dropdown-defined: false !default;

// Make sure to include these style definitions only once
@if $bv-dropdown-defined == false {
// This test will only include these style definitions once
$bv-dropdown-defined: true;

// Hide the caret for no-caret setting
// Hide the caret for `no-caret` setting
// See: https://github.com/bootstrap-vue/bootstrap-vue/issues/1473
// See: https://github.com/twbs/bootstrap/issues/23724
.dropdown {
Expand Down
14 changes: 6 additions & 8 deletions src/components/form-input/_form-input.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Temporary fix for cssnano bug: https://github.com/cssnano/cssnano/issues/712
// By moving center to last value in background-position property
// Bug will/may affect Nuxt.js users and docs site https://github.com/bootstrap-vue/bootstrap-vue/issues/2599
// By moving center to last value in `background-position` property
// See: https://github.com/bootstrap-vue/bootstrap-vue/issues/2599
@if $enable-validation-icons {
.form-control {
.was-validated &:invalid,
Expand Down Expand Up @@ -39,7 +39,7 @@ input[type="color"].form-control:disabled {
opacity: $btn-disabled-opacity;
}

/* Base .input-group > .custom-range styling (no PR yet on BS V4) */
// --- Base `.input-group > .custom-range` styling (no PR yet on BS V4) ---
.input-group {
> .custom-range {
position: relative;
Expand Down Expand Up @@ -116,8 +116,8 @@ input[type="color"].form-control:disabled {
@include border-radius($input-border-radius-sm);
}

/* b-form-input: custom-range validation styling - valid (no PR yet for BS V4.2) */
// Mixin for generating .input-group .custom-range validation styling
// --- <b-form-input>: custom-range validation styling - valid (no PR yet for BS V4.2) ---
// Mixin for generating `.input-group .custom-range` validation styling
@mixin bv-custom-range-validation-state($state, $color) {
.input-group .custom-range {
.was-validated &:#{$state},
Expand All @@ -134,7 +134,7 @@ input[type="color"].form-control:disabled {
.custom-range {
.was-validated &:#{$state},
&.is-#{$state} {
// Pseudo-elements must be split across multiple rulesets to have an affect.
// Pseudo-elements must be split across multiple rulesets to have an affect
&:focus {
&::-webkit-slider-thumb {
box-shadow: 0 0 0 1px $body-bg, 0 0 0 $input-btn-focus-width lighten($color, 35%);
Expand Down Expand Up @@ -174,8 +174,6 @@ input[type="color"].form-control:disabled {
&::-moz-range-track {
background: rgba($color, 0.35);
}
&::-moz-range-thumb {
}

~ .#{$state}-feedback,
~ .#{$state}-tooltip {
Expand Down
8 changes: 4 additions & 4 deletions src/components/input-group/_input-group.scss
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
$bv-input-group-dropdown-patched: false !default;

// Make sure to include these style definitions only once
@if $bv-input-group-dropdown-patched == false {
// Only include this style patch once in final CSS
$bv-input-group-dropdown-patched: true;

/* workaround for https://github.com/bootstrap-vue/bootstrap-vue/issues/1560 */
/* workaround for https://github.com/bootstrap-vue/bootstrap-vue/issues/2114 */
/* based on: bootstrap/scss/_input-group.scss */
// Workaround for https://github.com/bootstrap-vue/bootstrap-vue/issues/1560
// Workaround for https://github.com/bootstrap-vue/bootstrap-vue/issues/2114 */
// Based on: `~bootstrap/scss/_input-group.scss`
.input-group {
> .input-group-prepend > .btn-group,
> .input-group-append:not(:last-child) > .btn-group,
Expand Down
6 changes: 3 additions & 3 deletions src/components/jumbotron/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Anything else between the opening and closing tags will be rendered at the botto

```html
<div>
<b-jumbotron header="Bootstrap Vue" lead="Bootstrap 4 Components for Vue.js 2">
<b-jumbotron header="BootstrapVue" lead="Bootstrap 4 Components for Vue.js 2">
<p>For more information visit website</p>
<b-button variant="primary" href="#">More Info</b-button>
</b-jumbotron>
Expand All @@ -26,7 +26,7 @@ Anything else between the opening and closing tags will be rendered at the botto
```html
<div>
<b-jumbotron>
<template slot="header">Bootstrap Vue</template>
<template slot="header">BootstrapVue</template>

<template slot="lead">
This is a simple hero unit, a simple jumbotron-style component for calling extra attention to
Expand Down Expand Up @@ -87,7 +87,7 @@ jumbotron to use the default styling.
```html
<div>
<b-jumbotron bg-variant="info" text-variant="white" border-variant="dark">
<template slot="header">Bootstrap Vue</template>
<template slot="header">BootstrapVue</template>

<template slot="lead">
This is a simple hero unit, a simple jumbotron-style component for calling extra attention to
Expand Down
3 changes: 1 addition & 2 deletions src/components/pagination-nav/_pagination-nav.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
// Pagination and pagination-nav require the helper utility classes
// Note the utilities file will automatically only be included once
// <pagination> and <pagination-nav> require the helper utility classes
@import "../../utilities";
3 changes: 1 addition & 2 deletions src/components/pagination/_pagination.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
// Pagination and pagination-nav require the helper utility classes
// Note the utilities file will automatically only be included once
// <pagination> and <pagination-nav> require the helper utility classes
@import "../../utilities";
41 changes: 21 additions & 20 deletions src/components/table/_table.scss
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/* b-table: general styling */
// --- <b-table>: general styling ---
.b-table.table {
// table fixed header width layout
// Table fixed header width layout
&.b-table-fixed {
/* fixed width columns */
// Fixed width columns
table-layout: fixed;
}

Expand All @@ -15,7 +15,7 @@
> tbody > tr.b-table-details > td {
border-top: none !important;
}
// captioon positioning
// Caption positioning
> caption {
caption-side: bottom;

Expand All @@ -24,33 +24,33 @@
}
}

// make cells relatively position for thinks like tooltips, etc
// Make cells relatively position for thinks like tooltips, etc.
> thead,
> tfoot {
> tr {
> th,
> td {
// So dropdowns, tooltips, sorting, etc, will position properly
// So dropdowns, tooltips, sorting, etc., will position properly
position: relative;
}
}
}
}

/* b-table: header sort styling */
// --- <b-table>: header sort styling ---
.b-table.table {
// Sort Styling
// Sort styling
> thead,
> tfoot {
> tr {
> th {
&[aria-sort] {
// &.sorting
// `&.sorting`
position: relative;
padding-right: 1.125em;
cursor: pointer;

// Up/Down sort=null indicator
// Up/down sort=null indicator
&::after {
position: absolute;
display: block;
Expand All @@ -60,32 +60,32 @@
font-size: inherit;
line-height: inherit;
opacity: 0.4;
content: "\2195"; // \2195 up-down arrow
content: "\2195"; // Up/down arrow
speak: none;
}

// Ascending indicator
&[aria-sort="ascending"]::after {
// &.sorting_asc::after.sorting_asc
// `&.sorting_asc::after.sorting_asc`
opacity: 1;
content: "\2193"; // down arrow
content: "\2193"; // Down arrow
}

// Descending indicator
&[aria-sort="descending"]::after {
// &.sorting_desc::after
// `&.sorting_desc::after`
opacity: 1;
content: "\2191"; // up arrow
content: "\2191"; // Up arrow
}
}
}
}
}
}

/* b-table: stackled tables */
// --- <b-table>: stacked tables ---
// Generate series of `.table-stacked-*` classes for configuring the screen
// size of where your table will be stacked.
// size of where your table will be stacked
.b-table.table.b-table-stacked {
@each $breakpoint in map-keys($grid-breakpoints) {
$next: breakpoint-next($breakpoint, $grid-breakpoints);
Expand Down Expand Up @@ -125,7 +125,8 @@
> tr {
// Turn cells with labels into micro-grids
> [data-label] {
// convert TD/TH contents to "cells". Caveat: child elements become cells!
// Convert <td>/<th> contents to "cells"
// Caveat: child elements become cells!
display: grid;
grid-template-columns: 40% auto;
grid-gap: 0.25rem 1rem;
Expand All @@ -147,7 +148,7 @@
display: none;
}

// give the top of each "row" a heavy border
// Give the top of each "row" a heavy border
> :first-child {
border-top-width: (3 * $table-border-width);
}
Expand All @@ -158,7 +159,7 @@
}
}

/* b-table: selectable rows */
// --- <b-table>: selectable rows ---
.b-table.table.b-table-selectable {
& > tbody > tr {
cursor: pointer;
Expand Down
15 changes: 6 additions & 9 deletions src/index.scss
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
/*!
* BootstrapVue Custom CSS (https://bootstrap-vue.js.org)
*/
// Bootstrap
// --- BootstrapVue Custom SCSS ---

@import "node_modules/bootstrap/scss/functions";
@import "node_modules/bootstrap/scss/variables";
@import "node_modules/bootstrap/scss/mixins";

// Bootstrap Vue
// Requires at least the Bootstrap functions, variables and
// mixins to be imported first

// Include variables and utilities first
@import "variables";
@import "utilities";

// Include custom SCSS for components
@import "components/index";
2 changes: 1 addition & 1 deletion src/utils/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import warn from './warn'
import { isArray } from './array'
import { keys, isObject } from './object'

// General Bootstrap Vue configuration
// General BootstrapVue configuration
//
// BREAKPOINT DEFINITIONS
//
Expand Down