Fixed #250 - ReImplemented Steps styles

pull/256/head
mertsincan 2020-03-24 01:29:10 +03:00
parent 10018852f6
commit c87638c960
10 changed files with 24051 additions and 30618 deletions

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,5 +1,5 @@
<template> <template>
<div :class="containerClass"> <div :id="id" :class="containerClass">
<ul role="tablist"> <ul role="tablist">
<li v-for="(item,index) of model" :key="item.to" :class="getItemClass(item)" :style="item.style" role="tab" :aria-selected="isActive(item)" :aria-expanded="isActive(item)"> <li v-for="(item,index) of model" :key="item.to" :class="getItemClass(item)" :style="item.style" role="tab" :aria-selected="isActive(item)" :aria-expanded="isActive(item)">
<router-link :to="item.to" class="p-menuitem-link" @click.native="onItemClick($event, item)" v-if="!isItemDisabled(item)" role="presentation"> <router-link :to="item.to" class="p-menuitem-link" @click.native="onItemClick($event, item)" v-if="!isItemDisabled(item)" role="presentation">
@ -16,8 +16,14 @@
</template> </template>
<script> <script>
import UniqueComponentId from '../utils/UniqueComponentId';
export default { export default {
props: { props: {
id: {
type: String,
default: UniqueComponentId()
},
model: { model: {
type: Array, type: Array,
default: null default: null
@ -27,6 +33,17 @@ export default {
default: true default: true
} }
}, },
stepsStyle: null,
watch: {
model(newValue) {
if (this.model !== newValue) {
this.createStyle();
}
}
},
mounted() {
this.createStyle();
},
methods: { methods: {
onItemClick(event, item) { onItemClick(event, item) {
if (item.disabled || this.readonly) { if (item.disabled || this.readonly) {
@ -52,6 +69,21 @@ export default {
}, },
isItemDisabled(item) { isItemDisabled(item) {
return (item.disabled || (this.readonly && !this.isActive(item))); return (item.disabled || (this.readonly && !this.isActive(item)));
},
createStyle() {
if (!this.stepsStyle) {
this.stepsStyle = document.createElement('style');
this.stepsStyle.type = 'text/css';
document.body.appendChild(this.stepsStyle);
}
let innerHTML = `
#${this.id} .p-steps-item {
flex: 1 0 ${ (100/ this.model.length) }%
}
`;
this.stepsStyle.innerHTML = innerHTML;
} }
}, },
computed: { computed: {
@ -70,16 +102,17 @@ export default {
list-style-type: none; list-style-type: none;
padding: 0; padding: 0;
margin: 0; margin: 0;
} display: flex;
flex-wrap: nowrap;
.p-steps ul:after { flex-direction: row;
content: "";
display: table;
clear: both;
} }
.p-steps .p-steps-item { .p-steps .p-steps-item {
float: left; width: 100%;
box-sizing: border-box;
position: relative;
display: flex;
justify-content: center;
} }
.p-steps.p-steps-readonly .p-steps-item { .p-steps.p-steps-readonly .p-steps-item {
@ -88,10 +121,10 @@ export default {
.p-steps .p-steps-item .p-menuitem-link { .p-steps .p-steps-item .p-menuitem-link {
text-decoration: none; text-decoration: none;
display: block;
padding: 1em; padding: 1em;
position: relative; display: inline-flex;
text-align: center; flex-direction: column;
align-items: center;
} }
.p-steps .p-steps-item.p-steps-current .p-menuitem-link, .p-steps .p-steps-item.p-steps-current .p-menuitem-link,
@ -110,15 +143,12 @@ export default {
} }
@media (max-width: 40em) { @media (max-width: 40em) {
.p-steps ul {
flex-wrap: wrap;
}
.p-steps .p-steps-item .p-menuitem-link { .p-steps .p-steps-item .p-menuitem-link {
padding: 0.5em; padding: 0.5em;
} }
.p-steps .p-steps-item .p-steps-title {
display: none;
}
} }
.p-steps .p-steps-item {
width: 25%;
}
</style> </style>