🌐 AI搜索 & 代理 主页
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
c27f9ce
feature(b-icon): add spinning icon options
tmorehouse Mar 12, 2020
91c716b
Update _icons.scss
tmorehouse Mar 12, 2020
41dc904
Update icon-base.js
tmorehouse Mar 12, 2020
378d5f5
Update package.json
tmorehouse Mar 12, 2020
4c4f2a5
Update icon-base.js
tmorehouse Mar 12, 2020
12f5034
Update README.md
tmorehouse Mar 12, 2020
7e68cd7
Update README.md
tmorehouse Mar 12, 2020
35c38d4
Update _icons.scss
tmorehouse Mar 12, 2020
c44024b
Update _icons.scss
tmorehouse Mar 12, 2020
5609994
Update _icons.scss
tmorehouse Mar 12, 2020
8f91937
Update icon-base.js
tmorehouse Mar 12, 2020
1bc6521
Update package.json
tmorehouse Mar 12, 2020
437e431
Update README.md
tmorehouse Mar 12, 2020
0e06f2b
Update _icons.scss
tmorehouse Mar 12, 2020
db11f5b
Update _icons.scss
tmorehouse Mar 12, 2020
ce739f9
Update _icons.scss
tmorehouse Mar 12, 2020
376ecd8
Update _icons.scss
tmorehouse Mar 12, 2020
5e54668
Update README.md
tmorehouse Mar 12, 2020
4c6f30a
Update README.md
tmorehouse Mar 12, 2020
bed7283
Update README.md
tmorehouse Mar 12, 2020
966256c
Update _icons.scss
tmorehouse Mar 12, 2020
79f21e6
Update README.md
tmorehouse Mar 12, 2020
54cd2fe
Merge branch 'dev' into feat/4720
tmorehouse Mar 12, 2020
6bdb27f
Update README.md
tmorehouse Mar 12, 2020
8e45ba1
Update icons.spec.js
tmorehouse Mar 12, 2020
cd0ca78
Merge branch 'dev' into feat/4720
jacobmllr95 Mar 12, 2020
a967cad
Update icons.spec.js
tmorehouse Mar 12, 2020
b5ed8bc
Update README.md
tmorehouse Mar 12, 2020
9f07d5b
Update README.md
jacobmllr95 Mar 12, 2020
e83b92a
Merge branch 'feat/4720' of https://github.com/bootstrap-vue/bootstra…
jacobmllr95 Mar 12, 2020
d6e7c21
Update README.md
jacobmllr95 Mar 12, 2020
41bf723
Update README.md
tmorehouse Mar 12, 2020
87f74b6
Update icon-base.js
tmorehouse Mar 12, 2020
2276e0e
Update icons.spec.js
tmorehouse Mar 12, 2020
db495fa
Update _icons.scss
tmorehouse Mar 12, 2020
36af74d
Update package.json
tmorehouse Mar 12, 2020
9fbe1ea
Update package.json
tmorehouse Mar 12, 2020
b9ed4e0
Merge branch 'dev' into feat/4720
jacobmllr95 Mar 12, 2020
ad9c26c
Update README.md
tmorehouse Mar 12, 2020
b5d6131
Update README.md
tmorehouse Mar 12, 2020
0effe85
Update README.md
tmorehouse Mar 12, 2020
05d4a16
Update README.md
jacobmllr95 Mar 12, 2020
82620cd
Update package.json
jacobmllr95 Mar 12, 2020
b0f7e54
Add SCSS variables for icon animation duration
jacobmllr95 Mar 12, 2020
6354fb5
Merge branch 'feat/4720' of https://github.com/bootstrap-vue/bootstra…
jacobmllr95 Mar 12, 2020
e74bcc4
Update icons.scss
jacobmllr95 Mar 12, 2020
8628e01
Update icons.scss
tmorehouse Mar 12, 2020
8152bdd
Revert "Update icons.scss"
jacobmllr95 Mar 12, 2020
0dbc618
Merge branch 'feat/4720' of https://github.com/bootstrap-vue/bootstra…
jacobmllr95 Mar 12, 2020
9dba3c0
Update _variables.scss
jacobmllr95 Mar 12, 2020
f7fff7a
Revert "Revert "Update icons.scss""
jacobmllr95 Mar 12, 2020
80a435c
Update icons.scss
tmorehouse Mar 12, 2020
68ed9af
Merge branch 'feat/4720' of https://github.com/bootstrap-vue/bootstra…
jacobmllr95 Mar 12, 2020
3f7d9af
Properly handle standalone `icons.scss` file
jacobmllr95 Mar 12, 2020
b270704
Regenerate icons
jacobmllr95 Mar 12, 2020
97eb198
Merge branch 'dev' into feat/4720
jacobmllr95 Mar 12, 2020
bc7d756
Update nuxt.config.js
tmorehouse Mar 12, 2020
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
2 changes: 1 addition & 1 deletion docs/nuxt.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ module.exports = {
'highlight.js/styles/atom-one-light.css',
'codemirror/lib/codemirror.css',
'bootstrap/dist/css/bootstrap.css',
'../scripts/build.scss', // BootstrapVue SCSS
'../scripts/index.scss', // BootstrapVue SCSS
'@assets/css/docs.min.css',
'@assets/scss/styles.scss'
]
Expand Down
6 changes: 3 additions & 3 deletions scripts/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -96,16 +96,16 @@ node-sass --output-style expanded \
--source-map true \
--source-map-contents true \
--precision 6 \
scripts/build.scss \
scripts/index.scss \
dist/bootstrap-vue.css
postcss --config scripts/postcss.config.js \
--replace dist/bootstrap-vue.css
# Icons only CSS
# BootstrapVue Icons only CSS
node-sass --output-style expanded \
--source-map true \
--source-map-contents true \
--precision 6 \
src/icons.scss \
scripts/icons.scss \
dist/bootstrap-vue-icons.css
postcss --config scripts/postcss.config.js \
--replace dist/bootstrap-vue-icons.css
Expand Down
11 changes: 11 additions & 0 deletions scripts/icons.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*!
* BootstrapVue Icons 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 Icons custom SCSS
@import "../src/icons.scss";
File renamed without changes.
7 changes: 7 additions & 0 deletions src/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,13 @@ $b-custom-file-height-inner-sm: calc(
#{$b-custom-file-line-height-sm * 1em} + #{$b-custom-file-padding-y-sm * 2}
) !default;

// --- Icons ---

// Animations
$b-icon-animation-spin-duration: 2s !default;
$b-icon-animation-pulse-duration: 1s !default;
$b-icon-animation-cylon-duration: 0.75s !default;

// --- Tables ---

// Table busy state
Expand Down
4 changes: 4 additions & 0 deletions src/components/spinner/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,4 +222,8 @@ label is provided. You can easily customize the role if required via prop `role`
As well, when no label is provided, the spinner will automatically have the attribute
`aria-hidden="true"` to hide the spinner from screen reader users.

## See also

An alternative to the `<b-spinner>` component are [animated icons](/docs/icons/#animated-icons).

<!-- Component reference added automatically from component package.json -->
5 changes: 4 additions & 1 deletion src/icons.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
// --- BootstrapVue Icons Custom SCSS ---

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

// Include custom SCSS for icons
// Temporary until Bootstrap v5 (maybe)
@import "icons/index";
62 changes: 61 additions & 1 deletion src/icons/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@ With the use of Bootstrap's border and background
<!-- icons-styling.vue -->
```

## Transforms
## SVG transforms

BootstrapVue icons provide several props for applying basic SVG transforms to the `<svg>`. All
transforms can be combined for added effect. Note that the transforms are applied to the `<svg>`
Expand Down Expand Up @@ -428,6 +428,64 @@ Shifting is applied after any rotation transforms. As with scaling, backgrounds
affected. If you need to shift the border/background with the icon, use Bootstrap's margin
[spacing utility classes](/docs/reference/utility-classes).

## Animated icons

<span class="badge badge-info small">v2.7.0+</span>

BootstrapVue includes two spinning animation options for icons: `spin` and `pulse`. Both animations
spin the icon clockwise, but pulse uses a stepped spin. A third animation called `cylon` is also
provided.

To use the spin animation, set the `animation` prop to one of the animation names `'spin'`,
`'pulse'` or `'cylon'`.

```html
<template>
<div>
<p>Spinning animation:</p>
<b-icon icon="arrow-clockwise" animation="spin" font-scale="4"></b-icon>

<p class="mt-3">Pulsing animation:</p>
<b-icon icon="arrow-clockwise" animation="pulse" font-scale="4"></b-icon>

<p class="mt-3">Cylon animation:</p>
<b-icon icon="three-dots" animation="cylon" font-scale="4"></b-icon>
</div>
</template>

<!-- b-icon-spin-aminations.vue -->
```

Note with the `cylon` animation, the left-right movement extends past the icon's bounding box by
`25%`, so you may need to adjust padding or margins to compensate for your use case.

As the animations are CSS based, they are applied _after_ any SVG transforms have taken place:

```html
<template>
<div class="p-4">
<b-icon icon="clock" animation="spin" font-scale="4" shift-v="8"></b-icon>
</div>
</template>

<!-- b-icon-spin-aminations-transforms.vue -->
```

The BootstrapVue defined icon animation effects require BootstrapVue's custom CSS. The `animation`
prop translates to the class name `b-icon-animation-{animationName}`.

Need a different style animation? Just create a custom class defining the animation, and apply that
class to the icon component, or create a new animation class in the form of
`b-icon-animation-{animationName}` and pass the custom animation name to the `animation` prop.

**Note:** The BootstrapVue defined animation effects of this component is dependent on the
`prefers-reduced-motion` media query. See the
[reduced motion section of our accessibility documentation](/docs/reference/accessibility) for
additional details.

Side note: the `cylon` animation gets its name from the "eye" of the Cylons from the _original_
[1978 Battlestar Galactica TV series](https://www.youtube.com/watch?v=5a5bEIf0UaU).

## Stacking icons

<span class="badge badge-info small">v2.3.0+</span>
Expand Down Expand Up @@ -492,6 +550,8 @@ Stacked icon notes:
- The `font-scale` prop cannot be used on the inner icon components
- The `width` and `height` attributes cannot be applied to the inner icon components
- Stacked icons **cannot** be stacked inside another `<b-iconstack>`
- Note the animation props on the child icons will have no effect, however you _can_ use the
animation props on the `<b-iconstack>` component.

## Using in components

Expand Down
41 changes: 41 additions & 0 deletions src/icons/_icons.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,47 @@
// Perhaps this values should be SASS variables?
vertical-align: -0.15em;
}

&.b-icon-animation-spin {
animation: $b-icon-animation-spin-duration infinite linear b-icon-animation-spin;
@media (prefers-reduced-motion: reduce) {
animation: none;
}
}

&.b-icon-animation-pulse {
animation: $b-icon-animation-pulse-duration infinite steps(8) b-icon-animation-spin;
@media (prefers-reduced-motion: reduce) {
animation: none;
}
}

&.b-icon-animation-cylon {
animation: $b-icon-animation-cylon-duration infinite ease-in-out alternate
b-icon-animation-cylon;
@media (prefers-reduced-motion: reduce) {
animation: none;
}
}
}

// Animation for spinning icons
@keyframes b-icon-animation-spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(359deg);
}
}

@keyframes b-icon-animation-cylon {
0% {
transform: translateX(-25%);
}
100% {
transform: translateX(25%);
}
}

// Make icons slightly larger in buttons, nav-links, dropdowns, and input-group-text
Expand Down
10 changes: 9 additions & 1 deletion src/icons/helpers/icon-base.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ export const commonIconProps = {
shiftV: {
type: [Number, String],
default: 0
},
animation: {
type: String,
default: null
}
}

Expand Down Expand Up @@ -73,6 +77,7 @@ export const BVIconBase = /*#__PURE__*/ Vue.extend({
const shiftV = toFloat(props.shiftV) || 0
const flipH = props.flipH
const flipV = props.flipV
const animation = props.animation
// Compute the transforms
// Note that order is important as SVG transforms are applied in order from
// left to right and we want flipping/scale to occur before rotation
Expand Down Expand Up @@ -116,7 +121,10 @@ export const BVIconBase = /*#__PURE__*/ Vue.extend({
mergeData(
{
staticClass: 'b-icon bi',
class: { [`text-${props.variant}`]: !!props.variant },
class: {
[`text-${props.variant}`]: !!props.variant,
[`b-icon-animation-${animation}`]: !!animation
},
attrs: baseAttrs,
style: isStacked ? {} : { fontSize: fontScale === 1 ? null : `${fontScale * 100}%` }
},
Expand Down
2 changes: 1 addition & 1 deletion src/icons/icons.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// --- BEGIN AUTO-GENERATED FILE ---
//
// @IconsVersion: 1.0.0-alpha2
// @Generated: 2020-01-22T07:06:51.693Z
// @Generated: 2020-03-12T09:18:47.956Z
//
// This file is generated on each build. Do not edit this file!

Expand Down
2 changes: 1 addition & 1 deletion src/icons/icons.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// --- BEGIN AUTO-GENERATED FILE ---
//
// @IconsVersion: 1.0.0-alpha2
// @Generated: 2020-01-22T07:06:51.693Z
// @Generated: 2020-03-12T09:18:47.956Z
//
// This file is generated on each build. Do not edit this file!

Expand Down
18 changes: 18 additions & 0 deletions src/icons/icons.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -430,4 +430,22 @@ describe('icons', () => {
)
expect(wrapper.find('svg > g > g > path').exists()).toBe(true)
})

it('b-icon animation prop works', async () => {
const wrapper = mount(BIcon, {
localVue: localVue,
parentComponent: parentComponent,
propsData: {
icon: 'circle-fill',
animation: 'spin'
}
})

expect(wrapper.exists()).toBe(true)
expect(wrapper.is('svg')).toBe(true)
expect(wrapper.classes()).toContain('b-icon')
expect(wrapper.classes()).toContain('bi')
expect(wrapper.classes()).toContain('bi-circle-fill')
expect(wrapper.classes()).toContain('b-icon-animation-spin')
})
})
Loading