2.0.59 • Published 29 days ago

@kong-ui-public/sandbox-layout v2.0.59

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
29 days ago

@kong-ui-public/sandbox-layout

A layout component for Vue component sandboxes. Simply slot in your component (default slot) and component controls (controls slot).

Requirements

Usage

Install

Install the package in your host application

Important This package should always be installed as a devDependency as it is only utilized when building component sandbox apps and should never be compiled into a package's /dist folder.

yarn add -D @kong-ui-public/sandbox-layout

Props

links

  • type: SandboxNavigationItem[]
  • required: false
  • default: []

An array containing SandboxNavigationItem objects adhering to this interface:

interface SandboxNavigationItem {
  /** The name of the item to display in the navigation, e.g. `My page` */
  name: string
  /** The router link object, e.g. `{ name: 'my-page' }` */
  to: RouteLocationRaw
}

title

  • type: string
  • required: false
  • default: ''

A string to display as the title

controlsMinWidth

  • type: Number
  • required: false
  • default: 240

The minimum width of the controls sidebar. A number that is converted to pixels. Defaults to 240

Slots

default

The default slot should be utilized for main component display.

controls

The controls slot should be utilized for interactive controls, used to manipulate the component displayed in the default slot. The default width of this slot is 240px.

Example

Initialize the component in your sandbox app's entry file along with the router and links object.

// main.ts

import { createApp } from 'vue'
import App from './App.vue'
import { createRouter, createWebHistory } from 'vue-router'

// Import component, types, and styles
import { SandboxLayout } from '@kong-ui-public/sandbox-layout'
import type { SandboxNavigationItem } from '@kong-ui-public/sandbox-layout'
import '@kong-ui-public/sandbox-layout/dist/style.css'

const app = createApp(App)

// Globally register the component in your sandbox app
app.component('SandboxLayout', SandboxLayout)

const router = createRouter({
  history: createWebHistory(),
  routes: [
    {
      path: '/',
      name: 'sandbox-home',
      component: () => import('./pages/HomePage.vue'),
    },
    {
      path: '/example',
      name: 'example',
      component: () => import('./pages/ExamplePage.vue'),
    },
  ],
})

// Define the sandbox layout links here to inject into your application
const appLinks: SandboxNavigationItem[] = ([
  {
    name: 'Sandbox Homepage',
    to: { name: 'sandbox-home' },
  },
  {
    name: 'Example Page',
    to: { name: 'example' },
  },
])

// Provide the app links to the SandboxLayout components
app.provide('app-links', appLinks)
// Init the router
app.use(router)
// Mount the app
app.mount('#app')

Set up your sandbox app's App.vue

<template>
  <router-view />
</template>

Utilize the SandboxLayout component in your sandbox app's page components

<!-- ExamplePage.vue -->
<template>
  <SandboxLayout
    :links="appLinks"
    title="My chart component"
  >
    <!-- Inject the interactive controls into the `#controls` slot -->
    <template #controls>
      <label>Chart Type</label>
      <input type="radio" name="chartType" value="bar" />
      <input type="radio" name="chartType" value="line" />
    </template>

    <!-- Add your component in the `default` slot -->
    <MyChartComponent />
  </SandboxLayout>
</template>

<script setup lang="ts">
import { inject } from 'vue'
import type { SandboxNavigationItem } from '@kong-ui-public/sandbox-layout'

// Inject the app-links from the entry file
const appLinks: SandboxNavigationItem[] = inject('app-links', [])
</script>
2.0.59

30 days ago

2.0.58

1 month ago

2.0.57

1 month ago

2.0.56

1 month ago

2.0.55

1 month ago

2.0.54

1 month ago

2.0.53

1 month ago

2.0.52

2 months ago

2.0.51

2 months ago

2.0.50

2 months ago

2.0.49

2 months ago

2.0.48

2 months ago

2.0.47

3 months ago

2.0.46

3 months ago

2.0.45

3 months ago

2.0.44

3 months ago

2.0.42

3 months ago

2.0.43

3 months ago

2.0.41

3 months ago

2.0.40

3 months ago

2.0.39

3 months ago

2.0.38

3 months ago

2.0.37

4 months ago

2.0.36

4 months ago

2.0.35

4 months ago

2.0.34

4 months ago

2.0.33

4 months ago

2.0.32

4 months ago

2.0.29

5 months ago

2.0.31

5 months ago

2.0.30

5 months ago

2.0.28

5 months ago

2.0.26

5 months ago

2.0.27

5 months ago

2.0.25

5 months ago

2.0.24

5 months ago

2.0.23

5 months ago

2.0.22

5 months ago

2.0.20

5 months ago

2.0.21

5 months ago

2.0.19

5 months ago

2.0.18

6 months ago

2.0.17

6 months ago

2.0.16

6 months ago

2.0.15

6 months ago

2.0.14

6 months ago

2.0.13

6 months ago

2.0.12

6 months ago

2.0.11

6 months ago

2.0.10

6 months ago

2.0.9

6 months ago

2.0.8

6 months ago

2.0.7

7 months ago

2.0.6

7 months ago

2.0.5

7 months ago

2.0.4

7 months ago

2.0.3

7 months ago

2.0.2

7 months ago

2.0.1

7 months ago

2.0.0

7 months ago

0.1.9

7 months ago

0.1.8

7 months ago

0.1.7

7 months ago

0.1.6

7 months ago

0.1.5

7 months ago

0.1.4

8 months ago

0.1.3

8 months ago

0.1.2

8 months ago

0.1.1

8 months ago

0.1.0

8 months ago