mirror of
https://github.com/Hopiu/vue-material.git
synced 2026-05-20 21:11:52 +00:00
Merge pull request #295 from marcosmoura/components/mdProgress
Components/md progress
This commit is contained in:
commit
b288937c04
10 changed files with 339 additions and 9 deletions
|
|
@ -95,6 +95,10 @@
|
|||
<router-link exact to="/components/menu">Menu</router-link>
|
||||
</md-list-item>
|
||||
|
||||
<md-list-item class="md-inset">
|
||||
<router-link exact to="/components/progress">Progress</router-link>
|
||||
</md-list-item>
|
||||
|
||||
<md-list-item class="md-inset">
|
||||
<router-link exact to="/components/radio">Radio</router-link>
|
||||
</md-list-item>
|
||||
|
|
|
|||
148
docs/src/pages/components/Progress.vue
Normal file
148
docs/src/pages/components/Progress.vue
Normal file
|
|
@ -0,0 +1,148 @@
|
|||
<template>
|
||||
<page-content page-title="Components - Progress">
|
||||
<docs-component>
|
||||
<div slot="description">
|
||||
<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>
|
||||
<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-progress">
|
||||
<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-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 progress. 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="progress-demo" slot="demo">
|
||||
<div class="progress-area">
|
||||
<md-progress :md-progress="progress" v-if="transition"></md-progress>
|
||||
<md-progress class="md-accent" :md-progress="progress" v-if="transition"></md-progress>
|
||||
<md-progress class="md-warn" :md-progress="progress" v-if="transition"></md-progress>
|
||||
</div>
|
||||
|
||||
<md-button class="md-primary md-raised" @click.native="restartProgress">Restart</md-button>
|
||||
</div>
|
||||
|
||||
<div slot="code">
|
||||
<code-block lang="xml">
|
||||
<md-progress :md-progress="progress"></md-progress>
|
||||
<md-progress class="md-accent" :md-progress="progress"></md-progress>
|
||||
<md-progress class="md-warn" :md-progress="progress"></md-progress>
|
||||
</code-block>
|
||||
</div>
|
||||
</example-box>
|
||||
|
||||
<example-box card-title="Indeterminate">
|
||||
<div class="progress-demo" slot="demo">
|
||||
<div class="progress-area">
|
||||
<md-progress md-indeterminate v-if="transition"></md-progress>
|
||||
<md-progress class="md-accent" md-indeterminate v-if="transition"></md-progress>
|
||||
<md-progress class="md-warn" md-indeterminate v-if="transition"></md-progress>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div slot="code">
|
||||
<code-block lang="xml">
|
||||
<md-progress md-indeterminate></md-progress>
|
||||
<md-progress class="md-accent" md-indeterminate></md-progress>
|
||||
<md-progress class="md-warn" md-indeterminate></md-progress>
|
||||
</code-block>
|
||||
</div>
|
||||
</example-box>
|
||||
|
||||
<example-box card-title="Themes">
|
||||
<div class="progress-demo" slot="demo">
|
||||
<div class="progress-area">
|
||||
<md-progress md-theme="orange" md-indeterminate v-if="transition"></md-progress>
|
||||
<md-progress md-theme="green" :md-progress="progress" v-if="transition"></md-progress>
|
||||
<md-progress md-theme="purple" md-indeterminate v-if="transition"></md-progress>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div slot="code">
|
||||
<code-block lang="xml">
|
||||
<md-progress md-theme="orange" md-indeterminate></md-progress>
|
||||
<md-progress md-theme="green" :md-progress="progress"></md-progress>
|
||||
<md-progress md-theme="purple" md-indeterminate></md-progress>
|
||||
</code-block>
|
||||
</div>
|
||||
</example-box>
|
||||
</div>
|
||||
</docs-component>
|
||||
</page-content>
|
||||
</template>
|
||||
|
||||
<style lang="scss" scoped>
|
||||
.progress-area {
|
||||
height: 44px;
|
||||
|
||||
+ .md-button {
|
||||
margin: 16px 0 0;
|
||||
}
|
||||
}
|
||||
|
||||
.md-progress {
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
export default {
|
||||
data: () => ({
|
||||
progress: 0,
|
||||
progressInterval: null,
|
||||
transition: true
|
||||
}),
|
||||
methods: {
|
||||
startProgress() {
|
||||
this.progressInterval = window.setInterval(() => {
|
||||
this.progress += 3;
|
||||
|
||||
if (this.progress > 100) {
|
||||
window.clearInterval(this.progressInterval);
|
||||
}
|
||||
}, 100);
|
||||
},
|
||||
restartProgress() {
|
||||
this.progress = 0;
|
||||
this.transition = false;
|
||||
|
||||
window.clearInterval(this.progressInterval);
|
||||
window.setTimeout(() => {
|
||||
this.transition = true;
|
||||
this.startProgress();
|
||||
}, 600);
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
this.startProgress();
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
|
@ -21,6 +21,7 @@ const InkRipple = (resolve) => require(['./pages/components/InkRipple'], resolve
|
|||
const Input = (resolve) => require(['./pages/components/Input'], resolve);
|
||||
const List = (resolve) => require(['./pages/components/List'], resolve);
|
||||
const Menu = (resolve) => require(['./pages/components/Menu'], resolve);
|
||||
const Progress = (resolve) => require(['./pages/components/Progress'], resolve);
|
||||
const Radio = (resolve) => require(['./pages/components/Radio'], resolve);
|
||||
const Select = (resolve) => require(['./pages/components/Select'], resolve);
|
||||
const Sidenav = (resolve) => require(['./pages/components/Sidenav'], resolve);
|
||||
|
|
@ -146,6 +147,11 @@ const components = [
|
|||
name: 'components:menu',
|
||||
component: Menu
|
||||
},
|
||||
{
|
||||
path: '/components/progress',
|
||||
name: 'components:progress',
|
||||
component: Progress
|
||||
},
|
||||
{
|
||||
path: '/components/radio',
|
||||
name: 'components:radio',
|
||||
|
|
|
|||
8
src/components/mdProgress/index.js
Normal file
8
src/components/mdProgress/index.js
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
import mdProgress from './mdProgress.vue';
|
||||
import mdProgressTheme from './mdProgress.theme';
|
||||
|
||||
export default function install(Vue) {
|
||||
Vue.component('md-progress', Vue.extend(mdProgress));
|
||||
|
||||
Vue.material.styles.push(mdProgressTheme);
|
||||
}
|
||||
84
src/components/mdProgress/mdProgress.scss
Normal file
84
src/components/mdProgress/mdProgress.scss
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
@import '../../core/stylesheets/variables.scss';
|
||||
|
||||
.md-progress {
|
||||
width: 100%;
|
||||
height: 4px;
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
transition: $swift-ease-out;
|
||||
|
||||
&.md-indeterminate .md-progress-track {
|
||||
right: 0;
|
||||
|
||||
&:before,
|
||||
&:after {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
will-change: left, right;
|
||||
content: '';
|
||||
}
|
||||
|
||||
&:before {
|
||||
animation: progress-indeterminate 2.3s cubic-bezier(.65, .815, .735, .395) infinite;
|
||||
}
|
||||
|
||||
&:after {
|
||||
animation: progress-indeterminate-short 2.3s cubic-bezier(.165, .84, .44, 1) infinite;
|
||||
animation-delay: 1.15s;
|
||||
}
|
||||
}
|
||||
|
||||
&.md-progress-enter,
|
||||
&.md-progress-leave-active {
|
||||
opacity: 0;
|
||||
transform: scaleY(0) translateZ(0);
|
||||
}
|
||||
|
||||
&.md-progress-enter-active {
|
||||
transform: scaleY(1) translateZ(0);
|
||||
}
|
||||
}
|
||||
|
||||
.md-progress-track {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
transition: $swift-ease-out;
|
||||
}
|
||||
|
||||
@keyframes progress-indeterminate {
|
||||
0% {
|
||||
right: 100%;
|
||||
left: -35%;
|
||||
}
|
||||
|
||||
60% {
|
||||
right: -100%;
|
||||
left: 100%;
|
||||
}
|
||||
|
||||
100% {
|
||||
right: -100%;
|
||||
left: 100%;
|
||||
}
|
||||
}
|
||||
|
||||
@keyframes progress-indeterminate-short {
|
||||
0% {
|
||||
right: 100%;
|
||||
left: -200%;
|
||||
}
|
||||
|
||||
60% {
|
||||
right: -8%;
|
||||
left: 107%;
|
||||
}
|
||||
|
||||
100% {
|
||||
right: -8%;
|
||||
left: 107%;
|
||||
}
|
||||
}
|
||||
46
src/components/mdProgress/mdProgress.theme
Normal file
46
src/components/mdProgress/mdProgress.theme
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
.THEME_NAME {
|
||||
&.md-progress {
|
||||
background-color: #{'PRIMARY-COLOR-0.38'};
|
||||
|
||||
&:not(.md-indeterminate) .md-progress-track {
|
||||
background-color: #{'PRIMARY-COLOR'};
|
||||
}
|
||||
|
||||
.md-progress-track {
|
||||
&:after,
|
||||
&:before {
|
||||
background-color: #{'PRIMARY-COLOR'};
|
||||
}
|
||||
}
|
||||
|
||||
&.md-accent {
|
||||
background-color: #{'ACCENT-COLOR-0.38'};
|
||||
|
||||
&:not(.md-indeterminate) .md-progress-track {
|
||||
background-color: #{'ACCENT-COLOR'};
|
||||
}
|
||||
|
||||
.md-progress-track {
|
||||
&:after,
|
||||
&:before {
|
||||
background-color: #{'ACCENT-COLOR'};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
&.md-warn {
|
||||
background-color: #{'WARN-COLOR-0.38'};
|
||||
|
||||
&:not(.md-indeterminate) .md-progress-track {
|
||||
background-color: #{'WARN-COLOR'};
|
||||
}
|
||||
|
||||
.md-progress-track {
|
||||
&:after,
|
||||
&:before {
|
||||
background-color: #{'WARN-COLOR'};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
38
src/components/mdProgress/mdProgress.vue
Normal file
38
src/components/mdProgress/mdProgress.vue
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
<template>
|
||||
<transition name="md-progress" appear>
|
||||
<div class="md-progress" :class="[themeClass, classes]">
|
||||
<div class="md-progress-track" :style="styles"></div>
|
||||
</div>
|
||||
</transition>
|
||||
</template>
|
||||
|
||||
<style lang="scss" src="./mdProgress.scss"></style>
|
||||
|
||||
<script>
|
||||
import theme from '../../core/components/mdTheme/mixin';
|
||||
|
||||
export default {
|
||||
props: {
|
||||
mdIndeterminate: Boolean,
|
||||
mdProgress: {
|
||||
type: Number,
|
||||
default: 0
|
||||
}
|
||||
},
|
||||
mixins: [theme],
|
||||
computed: {
|
||||
classes() {
|
||||
return {
|
||||
'md-indeterminate': this.mdIndeterminate
|
||||
};
|
||||
},
|
||||
styles() {
|
||||
if (!this.mdIndeterminate) {
|
||||
return {
|
||||
width: this.mdProgress + '%'
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
|
@ -1,18 +1,18 @@
|
|||
.THEME_NAME {
|
||||
&.md-spinner {
|
||||
.md-spinner-path {
|
||||
stroke: #{'PRIMARY-COLOR'}
|
||||
stroke: #{'PRIMARY-COLOR'};
|
||||
}
|
||||
|
||||
&.md-accent {
|
||||
.md-spinner-path {
|
||||
stroke: #{'ACCENT-COLOR'}
|
||||
stroke: #{'ACCENT-COLOR'};
|
||||
}
|
||||
}
|
||||
|
||||
&.md-warn {
|
||||
.md-spinner-path {
|
||||
stroke: #{'WARN-COLOR'}
|
||||
stroke: #{'WARN-COLOR'};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,12 +57,6 @@
|
|||
|
||||
return `${progress}, 200`;
|
||||
}
|
||||
},
|
||||
data: () => ({
|
||||
|
||||
}),
|
||||
methods: {
|
||||
|
||||
}
|
||||
};
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -16,6 +16,7 @@ import MdInputContainer from './components/mdInputContainer';
|
|||
import MdLayout from './components/mdLayout';
|
||||
import MdList from './components/mdList';
|
||||
import MdMenu from './components/mdMenu';
|
||||
import MdProgress from './components/mdProgress';
|
||||
import MdRadio from './components/mdRadio';
|
||||
import MdSelect from './components/mdSelect';
|
||||
import MdSidenav from './components/mdSidenav';
|
||||
|
|
@ -48,6 +49,7 @@ const options = {
|
|||
MdLayout,
|
||||
MdList,
|
||||
MdMenu,
|
||||
MdProgress,
|
||||
MdRadio,
|
||||
MdSelect,
|
||||
MdSidenav,
|
||||
|
|
|
|||
Loading…
Reference in a new issue