mirror of
https://github.com/Hopiu/vue-material.git
synced 2026-05-20 21:11:52 +00:00
258 lines
9.4 KiB
Vue
258 lines
9.4 KiB
Vue
<template>
|
|
<page-content page-title="Components - Spinner">
|
|
<docs-component>
|
|
<div slot="description">
|
|
<p>Progress and activity indicators are visual indications of an app loading content.</p>
|
|
<p>The following classes can be applied to change the color palette:</p>
|
|
<ul class="md-body-2">
|
|
<li><code>md-accent</code></li>
|
|
<li><code>md-warn</code></li>
|
|
</ul>
|
|
</div>
|
|
|
|
<div slot="api">
|
|
<api-table name="md-spinner">
|
|
<md-table slot="properties">
|
|
<md-table-header>
|
|
<md-table-row>
|
|
<md-table-head>Name</md-table-head>
|
|
<md-table-head>Type</md-table-head>
|
|
<md-table-head>Description</md-table-head>
|
|
</md-table-row>
|
|
</md-table-header>
|
|
|
|
<md-table-body>
|
|
<md-table-row>
|
|
<md-table-cell>md-size</md-table-cell>
|
|
<md-table-cell><code>Number</code></md-table-cell>
|
|
<md-table-cell>The spinner size. Default <code>50</code></md-table-cell>
|
|
</md-table-row>
|
|
|
|
<md-table-row>
|
|
<md-table-cell>md-stroke</md-table-cell>
|
|
<md-table-cell><code>Number</code></md-table-cell>
|
|
<md-table-cell>The line width. Default <code>3.5</code></md-table-cell>
|
|
</md-table-row>
|
|
|
|
<md-table-row>
|
|
<md-table-cell>md-indeterminate</md-table-cell>
|
|
<md-table-cell><code>Boolean</code></md-table-cell>
|
|
<md-table-cell>Enable the indeterminate state. Default <code>false</code></md-table-cell>
|
|
</md-table-row>
|
|
|
|
<md-table-row>
|
|
<md-table-cell>md-progress</md-table-cell>
|
|
<md-table-cell><code>Number</code></md-table-cell>
|
|
<md-table-cell>Define the current progress of the spinner. Default <code>0</code></md-table-cell>
|
|
</md-table-row>
|
|
</md-table-body>
|
|
</md-table>
|
|
</api-table>
|
|
</div>
|
|
|
|
<div slot="example">
|
|
<example-box card-title="Determinate">
|
|
<div class="spinner-demo" slot="demo">
|
|
<md-button class="md-primary md-raised" @click.native="restartProgress">Restart</md-button>
|
|
<md-spinner :md-progress="progress" v-if="transition"></md-spinner>
|
|
<md-spinner :md-progress="progress" v-if="transition" class="md-accent"></md-spinner>
|
|
<md-spinner :md-progress="progress" v-if="transition" class="md-warn"></md-spinner>
|
|
</div>
|
|
|
|
<div slot="code">
|
|
<code-block lang="xml">
|
|
<md-spinner :md-progress="progress"></md-spinner>
|
|
<md-spinner :md-progress="progress" class="md-accent"></md-spinner>
|
|
<md-spinner :md-progress="progress" class="md-warn"></md-spinner>
|
|
</code-block>
|
|
</div>
|
|
</example-box>
|
|
|
|
<example-box card-title="Indeterminate">
|
|
<div class="spinner-demo" slot="demo">
|
|
<md-spinner md-indeterminate></md-spinner>
|
|
<md-spinner md-indeterminate class="md-accent"></md-spinner>
|
|
<md-spinner md-indeterminate class="md-warn"></md-spinner>
|
|
</div>
|
|
|
|
<div slot="code">
|
|
<code-block lang="xml">
|
|
<md-spinner md-indeterminate></md-spinner>
|
|
<md-spinner md-indeterminate class="md-accent"></md-spinner>
|
|
<md-spinner md-indeterminate class="md-warn"></md-spinner>
|
|
</code-block>
|
|
</div>
|
|
</example-box>
|
|
|
|
<example-box card-title="Sizes">
|
|
<div class="spinner-demo" slot="demo">
|
|
<md-spinner :md-size="20" md-indeterminate class="md-accent"></md-spinner>
|
|
<md-spinner :md-size="60" md-indeterminate class="md-warn"></md-spinner>
|
|
<md-spinner :md-size="150" md-indeterminate></md-spinner>
|
|
|
|
<md-spinner :md-size="20" :md-stroke="2.5" md-indeterminate class="md-accent"></md-spinner>
|
|
<md-spinner :md-size="60" :md-stroke="1.5" md-indeterminate class="md-warn"></md-spinner>
|
|
<md-spinner :md-size="150" :md-stroke="1" md-indeterminate></md-spinner>
|
|
</div>
|
|
|
|
<div slot="code">
|
|
<code-block lang="xml">
|
|
<md-spinner :md-size="20" md-indeterminate class="md-accent"></md-spinner>
|
|
<md-spinner :md-size="60" md-indeterminate class="md-warn"></md-spinner>
|
|
<md-spinner :md-size="150" md-indeterminate></md-spinner>
|
|
|
|
<md-spinner :md-size="20" :md-stroke="2" md-indeterminate class="md-accent"></md-spinner>
|
|
<md-spinner :md-size="60" :md-stroke="1.5" md-indeterminate class="md-warn"></md-spinner>
|
|
<md-spinner :md-size="150" :md-stroke="1" md-indeterminate></md-spinner>
|
|
</code-block>
|
|
</div>
|
|
</example-box>
|
|
|
|
<example-box card-title="Complete Example">
|
|
<div slot="demo">
|
|
<md-theme class="complete-example" md-name="orange">
|
|
<md-button class="md-fab" @click.native="restartProgress" :class="{ 'md-primary': done }">
|
|
<md-icon v-if="!done">cloud_upload</md-icon>
|
|
<md-icon v-if="done">done</md-icon>
|
|
</md-button>
|
|
|
|
<md-spinner :md-size="74" :md-stroke="2.2" :md-progress="progress" v-if="transition && progress < 115"></md-spinner>
|
|
</md-theme>
|
|
</div>
|
|
|
|
<div slot="code">
|
|
<code-block lang="xml">
|
|
<md-theme class="complete-example" md-name="orange">
|
|
<md-button class="md-fab" @click.native="restartProgress" :class="{ 'md-primary': done }">
|
|
<md-icon v-if="!done">cloud_upload</md-icon>
|
|
<md-icon v-if="done">done</md-icon>
|
|
</md-button>
|
|
|
|
<md-spinner :md-size="74" :md-stroke="2.2" :md-progress="progress" v-if="transition && progress < 115"></md-spinner>
|
|
</md-theme>
|
|
</code-block>
|
|
|
|
<code-block lang="scss">
|
|
.complete-example {
|
|
width: 56px;
|
|
height: 56px;
|
|
position: relative;
|
|
|
|
.md-fab {
|
|
margin: 0;
|
|
}
|
|
|
|
.md-spinner {
|
|
position: absolute;
|
|
top: 50%;
|
|
left: 50%;
|
|
transform: translate(-50%, -50%);
|
|
}
|
|
}
|
|
</code-block>
|
|
|
|
<code-block lang="javascript">
|
|
export default {
|
|
data: () => ({
|
|
progress: 0,
|
|
progressInterval: null,
|
|
done: false,
|
|
transition: true
|
|
}),
|
|
methods: {
|
|
startProgress() {
|
|
this.progressInterval = window.setInterval(() => {
|
|
this.progress += 3;
|
|
|
|
if (this.progress > 115) {
|
|
this.done = true;
|
|
window.clearInterval(this.progressInterval);
|
|
window.setTimeout(() => {
|
|
this.done = false;
|
|
}, 3000);
|
|
}
|
|
}, 100);
|
|
},
|
|
restartProgress() {
|
|
this.progress = 0;
|
|
this.transition = false;
|
|
this.done = false;
|
|
|
|
window.clearInterval(this.progressInterval);
|
|
window.setTimeout(() => {
|
|
this.transition = true;
|
|
this.startProgress();
|
|
}, 600);
|
|
}
|
|
}
|
|
};
|
|
</code-block>
|
|
</div>
|
|
</example-box>
|
|
</div>
|
|
</docs-component>
|
|
</page-content>
|
|
</template>
|
|
|
|
<style lang="scss" scoped>
|
|
.spinner-demo {
|
|
min-height: 55px;
|
|
}
|
|
|
|
.complete-example {
|
|
width: 56px;
|
|
height: 56px;
|
|
position: relative;
|
|
|
|
.md-fab {
|
|
margin: 0;
|
|
}
|
|
|
|
.md-spinner {
|
|
position: absolute;
|
|
top: 50%;
|
|
left: 50%;
|
|
transform: translate(-50%, -50%);
|
|
}
|
|
}
|
|
</style>
|
|
|
|
<script>
|
|
export default {
|
|
data: () => ({
|
|
progress: 0,
|
|
progressInterval: null,
|
|
done: false,
|
|
transition: true
|
|
}),
|
|
methods: {
|
|
startProgress() {
|
|
this.progressInterval = window.setInterval(() => {
|
|
this.progress += 3;
|
|
|
|
if (this.progress > 115) {
|
|
this.done = true;
|
|
window.clearInterval(this.progressInterval);
|
|
window.setTimeout(() => {
|
|
this.done = false;
|
|
}, 3000);
|
|
}
|
|
}, 100);
|
|
},
|
|
restartProgress() {
|
|
this.progress = 0;
|
|
this.transition = false;
|
|
this.done = false;
|
|
|
|
window.clearInterval(this.progressInterval);
|
|
window.setTimeout(() => {
|
|
this.transition = true;
|
|
this.startProgress();
|
|
}, 600);
|
|
}
|
|
},
|
|
mounted() {
|
|
this.startProgress();
|
|
}
|
|
};
|
|
</script>
|