forked from quasarframework/quasar
-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(QStep): simplify rules to apply *-color and *-icon props and doc…
…ument the rules quasarframework#12547, quasarframework#15259
- Loading branch information
Showing
5 changed files
with
274 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,204 @@ | ||
<template> | ||
<div class="q-pa-md q-gutter-y-sm"> | ||
<q-card> | ||
<q-card-section> | ||
<q-card-section class="items-center q-col-gutter-md" style="flex-wrap: wrap" horizontal> | ||
<div class="col-6 col-md-3 column no-wrap q-gutter-y-sm" v-for="prop in stepperProps" :key="prop"> | ||
<q-toggle | ||
v-model="stepper[`${prop}Color`]" | ||
:true-value="getProp(`${prop}Color`)" | ||
:false-value="null" | ||
:color="getProp(`${prop}Color`)" | ||
:label="`${prop} color`" | ||
size="48px" | ||
dense | ||
/> | ||
<q-toggle | ||
v-model="stepper[`${prop}Icon`]" | ||
toggle-indeterminate | ||
:true-value="getProp(`${prop}Icon`)" | ||
indeterminate-value="none" | ||
:checked-icon="getProp(`${prop}Icon`)" | ||
indeterminate-icon="looks_one" | ||
unchecked-icon="library_add_check" | ||
:false-value="null" | ||
color="dark" | ||
:label="`${prop} icon`" | ||
size="48px" | ||
dense | ||
/> | ||
</div> | ||
</q-card-section> | ||
</q-card-section> | ||
|
||
<q-card-section v-for="step in steps" :key="step.name"> | ||
<q-card-section class="items-center q-col-gutter-md" style="flex-wrap: wrap" horizontal> | ||
<div class="col column no-wrap q-gutter-y-xs"> | ||
<div class="text-center">Step {{ step.name }}</div> | ||
<q-toggle | ||
v-model="step.color" | ||
:true-value="stepColor" | ||
:false-value="null" | ||
:color="stepColor" | ||
label="step color" | ||
size="48px" | ||
dense | ||
/> | ||
<q-toggle | ||
v-model="step.icon" | ||
toggle-indeterminate | ||
:true-value="stepIcon" | ||
indeterminate-value="none" | ||
:checked-icon="stepIcon" | ||
indeterminate-icon="looks_one" | ||
unchecked-icon="library_add_check" | ||
:false-value="null" | ||
color="dark" | ||
label="step icon" | ||
size="48px" | ||
dense | ||
/> | ||
</div> | ||
|
||
<div class="col column no-wrap q-gutter-y-xs"> | ||
<q-toggle v-model="step.disable" color="dark" label="isDisabled" size=48px dense /> | ||
<q-toggle v-model="step.error" color="negative" label="isError" size=48px dense /> | ||
<q-toggle v-model="step.done" color="positive" label="isDone" size=48px dense /> | ||
</div> | ||
|
||
<div class="col-6 col-md-3 column no-wrap q-gutter-y-sm" v-for="prop in stepProps" :key="prop"> | ||
<q-toggle | ||
v-model="step[`${prop}Color`]" | ||
:true-value="getProp(`${prop}Color`)" | ||
:false-value="null" | ||
:color="getProp(`${prop}Color`)" | ||
:label="`${prop} color`" | ||
size="48px" | ||
dense | ||
/> | ||
<q-toggle | ||
v-model="step[`${prop}Icon`]" | ||
toggle-indeterminate | ||
:true-value="getProp(`${prop}Icon`)" | ||
indeterminate-value="none" | ||
:checked-icon="getProp(`${prop}Icon`)" | ||
indeterminate-icon="looks_one" | ||
unchecked-icon="library_add_check" | ||
:false-value="null" | ||
color="dark" | ||
:label="`${prop} icon`" | ||
size="48px" | ||
dense | ||
/> | ||
</div> | ||
</q-card-section> | ||
|
||
</q-card-section> | ||
|
||
<q-card-actions align="right"> | ||
<q-btn flat color="primary" label="Reset" /> | ||
</q-card-actions> | ||
</q-card> | ||
<div class="column no-wrap q-gutter-y-sm"> | ||
</div> | ||
|
||
<q-stepper | ||
header-nav | ||
animated | ||
v-bind="mapBind(stepper)" | ||
@input="step => { this.stepper.value = step }" | ||
> | ||
<q-step | ||
v-for="step in steps" | ||
:key="step.name" | ||
v-bind="mapBind(step)" | ||
>{{ lorem }}</q-step> | ||
</q-stepper> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
function initSteps (steps) { | ||
return Array(steps).fill(null).map((_, i) => ({ | ||
name: i + 1, | ||
prefix: i + 1, | ||
title: `Step ${i + 1}`, | ||
caption: `Step ${i + 1} caption`, | ||
done: false, | ||
error: false, | ||
disable: false, | ||
color: null, | ||
icon: null, | ||
errorColor: null, | ||
activeColor: null, | ||
doneColor: null, | ||
errorIcon: null, | ||
activeIcon: null, | ||
doneIcon: null | ||
})) | ||
} | ||
function initStepper () { | ||
return { | ||
value: 1, | ||
errorColor: null, | ||
activeColor: null, | ||
doneColor: null, | ||
inactiveColor: null, | ||
errorIcon: null, | ||
activeIcon: null, | ||
doneIcon: null, | ||
inactiveIcon: null | ||
} | ||
} | ||
export default { | ||
data () { | ||
return { | ||
lorem: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.', | ||
steps: initSteps(3), | ||
stepper: initStepper(), | ||
stepProps: ['error', 'active', 'done'], | ||
stepperProps: ['inactive', 'error', 'active', 'done'], | ||
stepColor: 'cyan-7', | ||
errorColor: 'red-7', | ||
activeColor: 'purple-7', | ||
doneColor: 'green-7', | ||
inactiveColor: 'blue-grey-6', | ||
stepIcon: 'star', | ||
errorIcon: 'error_outline', | ||
activeIcon: 'visibility', | ||
doneIcon: 'verified', | ||
inactiveIcon: 'schedule' | ||
} | ||
}, | ||
methods: { | ||
reset () { | ||
this.steps = initSteps(3) | ||
this.steper = initStepper() | ||
}, | ||
getProp (prop) { | ||
return this[prop] | ||
}, | ||
mapBind (props) { | ||
return Object.keys(props).reduce((acc, key) => { | ||
acc[key] = props[key] === null ? void 0 : props[key] | ||
return acc | ||
}, {}) | ||
} | ||
} | ||
} | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.