Skip to content

Instantly share code, notes, and snippets.

@gegeke
Created October 14, 2021 12:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gegeke/24b4d68b249bd8d86e309e9b497fe2f9 to your computer and use it in GitHub Desktop.
Save gegeke/24b4d68b249bd8d86e309e9b497fe2f9 to your computer and use it in GitHub Desktop.
VStepperIcon
<script>
import { VStepper } from 'vuetify/lib';
// stepper step types by component name, so the VStepperIcon
// is able to display different types of stepper steps
const STEPPER_STEP_COMPONENTS = ['v-stepper-step', 'v-stepper-step-icon']
// comparing name to possible stepper step component names
const isStepperStepComponent = (componentList) => {
return (name) => componentList.includes(name)
}
// function to check if a string is in the allowed componentList
const isStep = isStepperStepComponent(STEPPER_STEP_COMPONENTS)
export default {
// name is in dash-case, as Vuetify uses that
// eslint-disable-next-line
name: 'v-stepper-icon',
extends: VStepper,
methods: {
register(item) {
if (isStep(item.$options.name)) {
this.steps.push(item);
} else if (item.$options.name === 'v-stepper-content') {
item.isVertical = this.vertical;
this.content.push(item);
}
},
unregister(item) {
if (isStep(item.$options.name)) {
this.steps = this.steps.filter((i) => i !== item);
} else if (item.$options.name === 'v-stepper-content') {
item.isVertical = this.vertical;
this.content = this.content.filter((i) => i !== item);
}
},
},
};
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment