Skip to content

Commit

Permalink
feat: add an option to provide button labels for the default UI
Browse files Browse the repository at this point in the history
resolves #44
  • Loading branch information
fatihsolhan committed Aug 28, 2022
1 parent f87e049 commit e5880e3
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 3 deletions.
9 changes: 9 additions & 0 deletions docs/pages/3.props/2.options.md
Expand Up @@ -28,6 +28,11 @@ You can override `VOnboardingWrapper`'s options by passing options to `VOnboardi
block: 'center',
inline: 'center'
}
},
labels: {
previousButton: 'Previous',
nextButton: 'Next',
finishButton: 'Finish'
}
}
```
Expand All @@ -42,6 +47,10 @@ You can override `VOnboardingWrapper`'s options by passing options to `VOnboardi
| `scrollToStep` | | |
| `scrollToStep.enabled` | `Boolean` | `true` |
| `scrollToStep.options` | [Scroll Into View Options](https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollIntoView) | `{ behavior: 'smooth', block: 'center', inline: 'center' }` |
| `labels` | | |
| `labels.previousButton` | `String` | `Previous` |
| `labels.nextButton` | `String` | `Next` |
| `labels.finishButton` | `String` | `Finish` |



Expand Down
14 changes: 11 additions & 3 deletions src/components/VOnboardingStep.vue
Expand Up @@ -38,12 +38,12 @@
type="button"
@click="onPrevious"
class="v-onboarding-btn-secondary"
>Previous</button>
>{{ buttonLabels.previous }}</button>
<button
@click="onNext"
type="button"
class="v-onboarding-btn-primary"
>{{ isLast ? 'Finish' : 'Next' }}</button>
>{{ isLast ? buttonLabels.finish : buttonLabels.next }}</button>
</div>
</div>
</slot>
Expand Down Expand Up @@ -71,6 +71,13 @@ export default defineComponent({
const isFirst = inject<ComputedRef<boolean>>('is-first-step')
const isLast = inject<ComputedRef<boolean>>('is-last-step')
const step = inject<ComputedRef<StepEntity>>('step', {} as ComputedRef<StepEntity>);
const buttonLabels = computed(() => {
return {
previous: mergedOptions.value?.labels?.previousButton,
next: mergedOptions.value?.labels?.nextButton,
finish: mergedOptions.value?.labels?.finishButton,
}
})
const onNext = () => {
beforeStepEnd();
Expand Down Expand Up @@ -132,7 +139,8 @@ export default defineComponent({
step,
isFirst,
isLast,
exit
exit,
buttonLabels
};
},
})
Expand Down
10 changes: 10 additions & 0 deletions src/types/VOnboardingWrapper.ts
Expand Up @@ -23,6 +23,11 @@ export interface VOnboardingWrapperOptions {
enabled?: boolean
options?: ScrollIntoViewOptions
}
labels?: {
previousButton?: string
nextButton?: string
finishButton?: string
}
}

export const defaultVOnboardingWrapperOptions: VOnboardingWrapperOptions = {
Expand All @@ -39,5 +44,10 @@ export const defaultVOnboardingWrapperOptions: VOnboardingWrapperOptions = {
block: 'center',
inline: 'center'
}
},
labels: {
previousButton: 'Previous',
nextButton: 'Next',
finishButton: 'Finish'
}
}

0 comments on commit e5880e3

Please sign in to comment.