feat(spinner): add lines-sharp, lines-sharp-small, update styles for ios 14 (#22397)

Co-authored-by: Liam DeBeasi <liamdebeasi@icloud.com>
This commit is contained in:
Hans Krywalsky
2021-02-11 20:21:56 +01:00
committed by GitHub
parent 3d615cb3c7
commit 2a5b272a32
9 changed files with 103 additions and 39 deletions

View File

@ -160,12 +160,12 @@ export default defineComponent({
## Properties
| Property | Attribute | Description | Type | Default |
| ---------- | ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- | ----------- |
| `color` | `color` | The color to use from your application's color palette. Default options are: `"primary"`, `"secondary"`, `"tertiary"`, `"success"`, `"warning"`, `"danger"`, `"light"`, `"medium"`, and `"dark"`. For more information on colors, see [theming](/docs/theming/basics). | `string \| undefined` | `undefined` |
| `duration` | `duration` | Duration of the spinner animation in milliseconds. The default varies based on the spinner. | `number \| undefined` | `undefined` |
| `name` | `name` | The name of the SVG spinner to use. If a name is not provided, the platform's default spinner will be used. | `"bubbles" \| "circles" \| "circular" \| "crescent" \| "dots" \| "lines" \| "lines-small" \| undefined` | `undefined` |
| `paused` | `paused` | If `true`, the spinner's animation will be paused. | `boolean` | `false` |
| Property | Attribute | Description | Type | Default |
| ---------- | ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------- | ----------- |
| `color` | `color` | The color to use from your application's color palette. Default options are: `"primary"`, `"secondary"`, `"tertiary"`, `"success"`, `"warning"`, `"danger"`, `"light"`, `"medium"`, and `"dark"`. For more information on colors, see [theming](/docs/theming/basics). | `string \| undefined` | `undefined` |
| `duration` | `duration` | Duration of the spinner animation in milliseconds. The default varies based on the spinner. | `number \| undefined` | `undefined` |
| `name` | `name` | The name of the SVG spinner to use. If a name is not provided, the platform's default spinner will be used. | `"bubbles" \| "circles" \| "circular" \| "crescent" \| "dots" \| "lines" \| "lines-sharp" \| "lines-sharp-small" \| "lines-small" \| undefined` | `undefined` |
| `paused` | `paused` | If `true`, the spinner's animation will be paused. | `boolean` | `false` |
## CSS Custom Properties

View File

@ -81,6 +81,41 @@ const spinners = {
},
'lines': {
dur: 1000,
lines: 8,
fn: (dur: number, index: number, total: number) => {
const transform = `rotate(${ (360 / total) * index + (index < (total / 2) ? 180 : -180) }deg)`;
const animationDelay = `${ (dur * index / total) - dur }ms`;
return {
y1: 14,
y2: 26,
style: {
'transform': transform,
'animation-delay': animationDelay,
}
};
}
},
'lines-small': {
dur: 1000,
lines: 8,
fn: (dur: number, index: number, total: number) => {
const transform = `rotate(${(360 / total) * index + (index < (total / 2) ? 180 : -180)}deg)`;
const animationDelay = `${ (dur * index / total) - dur }ms`;
return {
y1: 12,
y2: 20,
style: {
'transform': transform,
'animation-delay': animationDelay,
}
};
}
},
'lines-sharp': {
dur: 1000,
lines: 12,
fn: (dur: number, index: number, total: number) => {
@ -98,7 +133,7 @@ const spinners = {
}
},
'lines-small': {
'lines-sharp-small': {
dur: 1000,
lines: 12,
fn: (dur: number, index: number, total: number) => {

View File

@ -36,18 +36,31 @@ svg {
}
// Spinner: lines / lines-small
// Spinner: lines / lines-small / lines-sharp / lines-sharp-small
// --------------------------------------------------
:host(.spinner-lines) line,
:host(.spinner-lines-small) line {
stroke-width: 7px;
}
:host(.spinner-lines-sharp) line,
:host(.spinner-lines-sharp-small) line {
stroke-width: 4px;
}
:host(.spinner-lines) line,
:host(.spinner-lines-small) line,
:host(.spinner-lines-sharp) line,
:host(.spinner-lines-sharp-small) line {
stroke-linecap: round;
stroke: currentColor;
}
:host(.spinner-lines) svg,
:host(.spinner-lines-small) svg {
:host(.spinner-lines-small) svg,
:host(.spinner-lines-sharp) svg,
:host(.spinner-lines-sharp-small) svg {
animation: spinner-fade-out 1s linear infinite;
}

View File

@ -70,7 +70,7 @@ export class Spinner implements ComponentInterface {
class={createColorClasses(self.color, {
[mode]: true,
[`spinner-${spinnerName}`]: true,
'spinner-paused': !!self.paused || config.getBoolean('_testing')
'spinner-paused': self.paused || config.getBoolean('_testing')
})}
role="progressbar"
style={spinner.elmDuration ? { animationDuration: duration + 'ms' } : {}}
@ -104,7 +104,7 @@ const buildLine = (spinner: SpinnerConfig, duration: number, index: number, tota
return (
<svg viewBox={data.viewBox || '0 0 64 64'} style={data.style}>
<line transform="translate(32,32)" y1={data.y1} y2={data.y2}></line>
<line transform="translate(32,32)" y1={data.y1} y2={data.y2} />
</svg>
);
};

View File

@ -39,6 +39,14 @@
<ion-spinner slot="start" name="lines-small"></ion-spinner>
<code>lines-small</code>
</ion-item>
<ion-item>
<ion-spinner slot="start" name="lines-sharp"></ion-spinner>
<code>lines-sharp</code>
</ion-item>
<ion-item>
<ion-spinner slot="start" name="lines-sharp-small"></ion-spinner>
<code>lines-sharp-small</code>
</ion-item>
<ion-item>
<ion-spinner slot="start" name="circular"></ion-spinner>
<code>circular</code>
@ -74,6 +82,14 @@
<ion-spinner slot="start" name="lines-small" paused></ion-spinner>
<code>lines-small</code>
</ion-item>
<ion-item>
<ion-spinner slot="start" name="lines-sharp" paused></ion-spinner>
<code>lines-sharp</code>
</ion-item>
<ion-item>
<ion-spinner slot="start" name="lines-sharp-small" paused></ion-spinner>
<code>lines-sharp-small</code>
</ion-item>
<ion-item>
<ion-spinner slot="start" name="circular" paused></ion-spinner>
<code>circular</code>