Vue
Use staticview components in Vue templates.
TypeScript Configuration
Add the component types to your TypeScript configuration:
{ "compilerOptions": { "types": [ // Required: types the component tags in Vue templates // For one component: "@staticview/ui/types/vue/[component-name]" "@staticview/ui/types/vue",
// Optional: types what `querySelector` and `createElement` return for each tag // For one component: "@staticview/ui/types/dom/[component-name]" "@staticview/ui/types/dom",
// Optional: declares each component type globally, with no import // For one component: "@staticview/ui/types/global/[component-name]" "@staticview/ui/types/global", ], },}Importing Web Components
Since components register globally, import each one once, in your app's entry point:
import "@staticview/ui/[component-name]";Setting Properties
Set a property with v-bind:[propertyName].prop or its shorthand :[propertyName].prop:
<component-name v-bind:opened.prop="isOpen" :disabled.prop="isDisabled"></component-name>Setting Attributes
Set a static attribute as in plain HTML:
<component-name label="Title"></component-name>Boolean Attributes
A boolean attribute is on whenever it is present, and close-button="false" turns the close button on. Since Vue turns any attribute value other than null or undefined into a string, :close-button="hasCloseButton" renders close-button="false", and you bind the property instead:
<component-name :closeButton.prop="hasCloseButton"></component-name>Otherwise pass "" to turn it on and undefined to turn it off:
<component-name :close-button="hasCloseButton ? '' : undefined"></component-name>Handling Events
Listen to component events with v-on:[eventName] or its shorthand @[eventName]:
<component-name v-on:clicked="handleClick" @openedchange="handleOpenedChange"></component-name>Using Slots
Put the content between the tags, with a slot attribute for a named slot:
<component-name> <span slot="title">Title</span> <span>Content</span></component-name>