|
| 1 | +<template> |
| 2 | + <page-content page-title="Components - Progress"> |
| 3 | + <docs-component> |
| 4 | + <div slot="description"> |
| 5 | + <p>A linear progress indicator should always fill from 0% to 100% and never decrease in value. It should be represented by bars on the edge of a header or sheet that appear and disappear.</p> |
| 6 | + <p>The following classes can be applied to change the color palette:</p> |
| 7 | + <ul class="md-body-2"> |
| 8 | + <li><code>md-accent</code></li> |
| 9 | + <li><code>md-warn</code></li> |
| 10 | + </ul> |
| 11 | + </div> |
| 12 | + |
| 13 | + <div slot="api"> |
| 14 | + <api-table name="md-progress"> |
| 15 | + <md-table slot="properties"> |
| 16 | + <md-table-header> |
| 17 | + <md-table-row> |
| 18 | + <md-table-head>Name</md-table-head> |
| 19 | + <md-table-head>Type</md-table-head> |
| 20 | + <md-table-head>Description</md-table-head> |
| 21 | + </md-table-row> |
| 22 | + </md-table-header> |
| 23 | + |
| 24 | + <md-table-body> |
| 25 | + <md-table-row> |
| 26 | + <md-table-cell>md-indeterminate</md-table-cell> |
| 27 | + <md-table-cell><code>Boolean</code></md-table-cell> |
| 28 | + <md-table-cell>Enable the indeterminate state. Default <code>false</code></md-table-cell> |
| 29 | + </md-table-row> |
| 30 | + |
| 31 | + <md-table-row> |
| 32 | + <md-table-cell>md-progress</md-table-cell> |
| 33 | + <md-table-cell><code>Number</code></md-table-cell> |
| 34 | + <md-table-cell>Define the current progress of the progress. Default <code>0</code></md-table-cell> |
| 35 | + </md-table-row> |
| 36 | + </md-table-body> |
| 37 | + </md-table> |
| 38 | + </api-table> |
| 39 | + </div> |
| 40 | + |
| 41 | + <div slot="example"> |
| 42 | + <example-box card-title="Determinate"> |
| 43 | + <div class="progress-demo" slot="demo"> |
| 44 | + <div class="progress-area"> |
| 45 | + <md-progress :md-progress="progress" v-if="transition"></md-progress> |
| 46 | + <md-progress class="md-accent" :md-progress="progress" v-if="transition"></md-progress> |
| 47 | + <md-progress class="md-warn" :md-progress="progress" v-if="transition"></md-progress> |
| 48 | + </div> |
| 49 | + |
| 50 | + <md-button class="md-primary md-raised" @click.native="restartProgress">Restart</md-button> |
| 51 | + </div> |
| 52 | + |
| 53 | + <div slot="code"> |
| 54 | + <code-block lang="xml"> |
| 55 | + <md-progress :md-progress="progress"></md-progress> |
| 56 | + <md-progress class="md-accent" :md-progress="progress"></md-progress> |
| 57 | + <md-progress class="md-warn" :md-progress="progress"></md-progress> |
| 58 | + </code-block> |
| 59 | + </div> |
| 60 | + </example-box> |
| 61 | + |
| 62 | + <example-box card-title="Indeterminate"> |
| 63 | + <div class="progress-demo" slot="demo"> |
| 64 | + <div class="progress-area"> |
| 65 | + <md-progress md-indeterminate v-if="transition"></md-progress> |
| 66 | + <md-progress class="md-accent" md-indeterminate v-if="transition"></md-progress> |
| 67 | + <md-progress class="md-warn" md-indeterminate v-if="transition"></md-progress> |
| 68 | + </div> |
| 69 | + </div> |
| 70 | + |
| 71 | + <div slot="code"> |
| 72 | + <code-block lang="xml"> |
| 73 | + <md-progress md-indeterminate></md-progress> |
| 74 | + <md-progress class="md-accent" md-indeterminate></md-progress> |
| 75 | + <md-progress class="md-warn" md-indeterminate></md-progress> |
| 76 | + </code-block> |
| 77 | + </div> |
| 78 | + </example-box> |
| 79 | + |
| 80 | + <example-box card-title="Themes"> |
| 81 | + <div class="progress-demo" slot="demo"> |
| 82 | + <div class="progress-area"> |
| 83 | + <md-progress md-theme="orange" md-indeterminate v-if="transition"></md-progress> |
| 84 | + <md-progress md-theme="green" :md-progress="progress" v-if="transition"></md-progress> |
| 85 | + <md-progress md-theme="purple" md-indeterminate v-if="transition"></md-progress> |
| 86 | + </div> |
| 87 | + </div> |
| 88 | + |
| 89 | + <div slot="code"> |
| 90 | + <code-block lang="xml"> |
| 91 | + <md-progress md-theme="orange" md-indeterminate></md-progress> |
| 92 | + <md-progress md-theme="green" :md-progress="progress"></md-progress> |
| 93 | + <md-progress md-theme="purple" md-indeterminate></md-progress> |
| 94 | + </code-block> |
| 95 | + </div> |
| 96 | + </example-box> |
| 97 | + </div> |
| 98 | + </docs-component> |
| 99 | + </page-content> |
| 100 | +</template> |
| 101 | + |
| 102 | +<style lang="scss" scoped> |
| 103 | + .progress-area { |
| 104 | + height: 44px; |
| 105 | +
|
| 106 | + + .md-button { |
| 107 | + margin: 16px 0 0; |
| 108 | + } |
| 109 | + } |
| 110 | +
|
| 111 | + .md-progress { |
| 112 | + margin-bottom: 16px; |
| 113 | + } |
| 114 | +</style> |
| 115 | + |
| 116 | +<script> |
| 117 | + export default { |
| 118 | + data: () => ({ |
| 119 | + progress: 0, |
| 120 | + progressInterval: null, |
| 121 | + transition: true |
| 122 | + }), |
| 123 | + methods: { |
| 124 | + startProgress() { |
| 125 | + this.progressInterval = window.setInterval(() => { |
| 126 | + this.progress += 3; |
| 127 | +
|
| 128 | + if (this.progress > 100) { |
| 129 | + window.clearInterval(this.progressInterval); |
| 130 | + } |
| 131 | + }, 100); |
| 132 | + }, |
| 133 | + restartProgress() { |
| 134 | + this.progress = 0; |
| 135 | + this.transition = false; |
| 136 | +
|
| 137 | + window.clearInterval(this.progressInterval); |
| 138 | + window.setTimeout(() => { |
| 139 | + this.transition = true; |
| 140 | + this.startProgress(); |
| 141 | + }, 600); |
| 142 | + } |
| 143 | + }, |
| 144 | + mounted() { |
| 145 | + this.startProgress(); |
| 146 | + } |
| 147 | + }; |
| 148 | +</script> |
0 commit comments