vue-snippet-toggler
We wanted to have a nice way to show various snippets of code inside of our docs, so we figured we'd open source that component as well!
Installation
npm install @directus/vue-snippet-toggler
Usage
<script setup>
import { ref } from 'vue';
import { SnippetToggler } from '@directus/vue-snippet-toggler';
import '@directus/vue-snippet-toggler/style.css';
const pref = ref('REST');
</script>
<template>
<SnippetToggler
v-model="pref"
:choices="['REST', 'GraphQL']"
label="API"
>
<template #rest>
<!-- Your REST example -->
</template>
<template #graphql>
<!-- Your REST example -->
</template>
</SnippetToggler>
</template>
Contributing
This component was made for internal use, so it may or may not be flexible (enough) for your project. Contributions are more than welcome! Make sure to open an issue first outlining the change you'd like to make.
Cutting Releases
To push a new version of the library, run pnpm version <minor | patch>
to update the version number and create the tag, and push both changes to GitHub with git push
and git push --tags
.
License
MIT