Skip to content
This repository has been archived by the owner on Jun 1, 2023. It is now read-only.

Commit

Permalink
#27 Expose footer content as a scoped slot
Browse files Browse the repository at this point in the history
  • Loading branch information
cristijora committed Jul 31, 2017
1 parent 69d05ee commit 4dae549
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 15 deletions.
7 changes: 7 additions & 0 deletions dev-example/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@
<div v-if="error">
{{error}}
</div>
<template slot="footer" scope="props">
<div class="wizard-footer-right">
<wizard-button :style="props.fillButtonStyle">Cancel</wizard-button>
<wizard-button @click.native="props.nextTab()" class="wizard-footer-right" :style="props.fillButtonStyle">Next</wizard-button>
</div>

</template>
</form-wizard>
</div>
</template>
Expand Down
38 changes: 24 additions & 14 deletions src/components/FormWizard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@
:style="tab.active ? stepTitleStyle : {}">
{{tab.title}}
</span>

</a>
</li>
</ul>
Expand All @@ -46,44 +45,55 @@
</div>

<div class="wizard-card-footer clearfix" v-if="!hideButtons">
<template>
<slot name="footer"
:next-tab="nextTab"
:prev-tab="prevTab"
:active-tab-index="activeTabIndex"
:is-last-step="isLastStep"
:fill-button-style="fillButtonStyle">

<template>
<span @click="prevTab" v-if="displayPrevButton" class="wizard-footer-left">
<slot name="prev">
<button type="button" class="wizard-btn btn-default wizard-btn-wd" :style="fillButtonStyle"
<wizard-button :style="fillButtonStyle"
:disabled="loading">
{{backButtonText}}
</button>
</wizard-button>
</slot>
</span>
</template>
</template>

<template>
<template>
<span @click="finish" class="wizard-footer-right" v-if="isLastStep">
<slot name="finish">
<button type="button" class="wizard-btn btn-fill wizard-btn-wd btn-next" :style="fillButtonStyle">
<wizard-button :style="fillButtonStyle">
{{finishButtonText}}
</button>
</wizard-button>
</slot>
</span>
</template>
</template>

<template>
<template>
<span @click="nextTab" class="wizard-footer-right" v-if="!isLastStep">
<slot name="next">
<button type="button" class="wizard-btn btn-fill wizard-btn-wd btn-next" :style="fillButtonStyle"
<wizard-button :style="fillButtonStyle"
:disabled="loading">
{{nextButtonText}}
</button>
</wizard-button>
</slot>
</span>
</template>

</template>
</slot>
</div>
</div>
</template>
<script>
import WizardButton from './WizardButton.vue'
export default{
name: 'form-wizard',
components: {
WizardButton
},
props: {
title: {
type: String,
Expand Down
10 changes: 10 additions & 0 deletions src/components/WizardButton.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<template>
<button type="button" class="wizard-btn btn-fill wizard-btn-wd">
<slot></slot>
</button>
</template>
<script>
export default {}
</script>
<style>
</style>
5 changes: 4 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
import FormWizard from './components/FormWizard.vue'
import TabContent from './components/TabContent.vue'
import WizardButton from './components/WizardButton.vue'
const VueFormWizard = {
install (Vue) {
Vue.component('form-wizard', FormWizard)
Vue.component('tab-content', TabContent)
Vue.component('wizard-button', WizardButton)
}
}
// Automatic installation if Vue has been added to the global scope.
Expand All @@ -14,5 +16,6 @@ if (typeof window !== 'undefined' && window.Vue) {
export default VueFormWizard
export {
FormWizard,
TabContent
TabContent,
WizardButton
}

0 comments on commit 4dae549

Please sign in to comment.