UNPKG

5.67 kBSCSSView Raw
1// Copyright 2015 Palantir Technologies, Inc. All rights reserved.
2// Licensed under the BSD-3 License as modified (the “License”); you may obtain a copy
3// of the license at https://github.com/palantir/blueprint/blob/master/LICENSE
4// and https://github.com/palantir/blueprint/blob/master/PATENTS
5
6@import "~bourbon/app/assets/stylesheets/bourbon";
7@import "../../common/variables";
8
9/*
10Spinners
11
12Spinners indicate indeterminate progress.
13
14Styleguide components.progress.spinner
15*/
16
17/*
18CSS API
19
20You can create spinners manually by inserting their whole markup into your HTML.
21Spinners created via markup use same modifier classes as the [React `Spinner` component](#components.progress.spinner.js).
22
23Markup:
24<div class="pt-spinner {{.modifier}}">
25 <div class="pt-spinner-svg-container">
26 <svg viewBox="0 0 100 100">
27 <path class="pt-spinner-track" d="M 50,50 m 0,-44.5 a 44.5,44.5 0 1 1 0,89 a 44.5,44.5 0 1 1 0,-89"></path>
28 <path class="pt-spinner-head" d="M 94.5 50 A 44.5 44.5 0 0 0 50 5.5"></path>
29 </svg>
30 </div>
31</div>
32
33.pt-small - Small spinner
34.pt-large - Large spinner
35
36Styleguide components.progress.spinner.css
37*/
38
39/*
40JavaScript API
41
42The `Spinner` component is available in the __@blueprintjs/core__ package.
43Make sure to review the [general usage docs for JS components](#components.usage).
44
45A `Spinner` is a simple stateless component that renders HTML/SVG markup.
46It supports a `value` prop between 0 and 1 that determines how much of the track is filled by the head.
47When this prop is defined, the spinner head will not spin but it will smoothly animate as `value` updates.
48Omitting `value` will result in an "indeterminate" spinner where the head spins indefinitely
49(this is the default appearance).
50
51Note that the CSS modifiers described in the [CSS API](#components.progress.spinner.css)
52are supported via the `className` prop.
53
54<div class="pt-callout pt-intent-warning pt-icon-warning-sign">
55 <h5>IE11 compatibility note</h5>
56 IE11 [does not support CSS transitions on SVG elements][msdn-css-svg] so spinners with known `value` will not smoothly
57 transition as `value` changes. Indeterminate spinners still animate correctly because they rely on CSS animations, not
58 transitions.
59</div>
60
61@interface ISpinnerProps
62
63@react-example SpinnerExample
64
65[msdn-css-svg]: https://developer.microsoft.com/en-us/microsoft-edge/platform/status/csstransitionsforsvgelements/?q=svg
66
67Styleguide components.progress.spinner.js
68*/
69
70/*
71SVG spinner
72
73Use the `SVGSpinner` component to render a spinner inside an SVG element.
74
75<div class="pt-callout pt-intent-primary pt-icon-info-sign">
76 <h5>Sizing note</h5>
77 Because of the way SVG elements are sized, you may need to manually scale the spinner inside your SVG
78 to make it an appropriate size.
79</div>
80
81Styleguide components.progress.spinner.js.svg
82*/
83
84@mixin spinner-size($width-factor, $stroke-width, $speed) {
85 &:not(.pt-svg-spinner) {
86 width: $spinner-width * $width-factor;
87
88 .pt-spinner-svg-container {
89 animation-duration: $speed;
90 }
91 }
92
93 &.pt-svg-spinner {
94 animation-duration: $speed;
95 }
96
97 .pt-svg-spinner-transform-group {
98 transform: scale($width-factor);
99 }
100
101 path {
102 stroke-width: $stroke-width;
103 }
104}
105
106$spinner-track-color: rgba($gray1, 0.2);
107$spinner-head-color: rgba($gray1, 0.8);
108$dark-spinner-track-color: rgba($gray5, 0.2);
109$dark-spinner-head-color: $gray1;
110
111$spinner-width: $pt-grid-size * 10;
112$spinner-width-factor: 0.5;
113$spinner-width-factor-small: 0.24;
114$spinner-width-factor-large: 1;
115$spinner-stroke-width: 5;
116$spinner-stroke-width-small: 12;
117$spinner-stroke-width-large: 3;
118
119$spinner-speed: $pt-transition-duration * 4;
120$spinner-speed-small: $pt-transition-duration * 4;
121$spinner-speed-large: $pt-transition-duration * 4.5;
122
123// the relative path from blueprint.css to resources in the distribution package
124$resources-path: "./resources";
125
126// see https://css-tricks.com/scale-svg/
127// how to Scale SVG to Fit the Available Width (and adjust the height to match) Option 4
128
129.pt-spinner {
130 @include spinner-size($spinner-width-factor, $spinner-stroke-width, $spinner-speed);
131
132 path {
133 fill-opacity: 0;
134 }
135
136 .pt-spinner-head {
137 transition: stroke-dashoffset ($pt-transition-duration * 2) $pt-transition-ease;
138 stroke: $spinner-head-color;
139 stroke-linecap: round;
140 }
141
142 .pt-spinner-track {
143 stroke: $spinner-track-color;
144 }
145
146 &.pt-small {
147 @include spinner-size($spinner-width-factor-small, $spinner-stroke-width-small, $spinner-speed-small);
148 }
149
150 &.pt-large {
151 @include spinner-size($spinner-width-factor-large, $spinner-stroke-width-large, $spinner-speed-large);
152 }
153}
154
155.pt-spinner:not(.pt-svg-spinner) {
156 display: inline-block;
157
158 .pt-spinner-svg-container {
159 position: relative;
160 width: 100%;
161 height: 0;
162 padding: 0;
163 padding-bottom: 100%;
164 animation: pt-spinner-animation $spinner-speed linear infinite;
165 }
166
167 &.pt-no-spin .pt-spinner-svg-container {
168 animation: none;
169 }
170
171 svg {
172 position: absolute;
173 top: 0;
174 left: 0;
175 width: 100%;
176 height: 100%;
177 }
178}
179
180.pt-svg-spinner {
181 transform-origin: center;
182 animation: pt-spinner-animation $spinner-speed linear infinite;
183
184 &.pt-no-spin {
185 animation: none;
186 }
187}
188
189.pt-svg-spinner-transform-group {
190 transform-origin: center;
191}
192
193.pt-dark .pt-spinner {
194 .pt-spinner-head {
195 stroke: $dark-spinner-head-color;
196 }
197
198 .pt-spinner-track {
199 stroke: $dark-spinner-track-color;
200 }
201}
202
203@each $intent, $color in $pt-intent-colors {
204 .pt-spinner.pt-intent-#{$intent} .pt-spinner-head {
205 stroke: $color;
206 }
207}
208
209@keyframes pt-spinner-animation {
210 from { transform: rotate(0deg); }
211 to { transform: rotate(360deg); }
212}