All Projects → ktsn → birdseye

ktsn / birdseye

Licence: other
Next generation component catalog

Programming Languages

typescript
32286 projects
Vue
7211 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to birdseye

Storybook
📓 The UI component explorer. Develop, document, & test React, Vue, Angular, Web Components, Ember, Svelte & more!
Stars: ✭ 67,445 (+164400%)
Mutual labels:  styleguide, web-components
Catalog
Create living style guides using Markdown or React
Stars: ✭ 1,527 (+3624.39%)
Mutual labels:  styleguide, catalog
vue-custom-element
Vue Custom Element - Web Components' Custom Elements for Vue.js
Stars: ✭ 1,886 (+4500%)
Mutual labels:  web-components
bashtemplate
A bash template for better bash coding.
Stars: ✭ 75 (+82.93%)
Mutual labels:  styleguide
SIES-Library
A simple catalog app for SIESGST Library using Google Books API
Stars: ✭ 34 (-17.07%)
Mutual labels:  catalog
papyrum
Papyrum is a tool that will help you in the creation of your design system, style guide or in the documentation of your project based on react
Stars: ✭ 19 (-53.66%)
Mutual labels:  styleguide
byu-theme-components
Web Components implementing the BYU web theme.
Stars: ✭ 21 (-48.78%)
Mutual labels:  web-components
rocket
The modern web setup for static sites with a sprinkle of JavaScript
Stars: ✭ 169 (+312.2%)
Mutual labels:  web-components
ascii-image
Web Component that displays an image as ASCII art
Stars: ✭ 15 (-63.41%)
Mutual labels:  web-components
placeholders
SVG-based placeholders in web components
Stars: ✭ 28 (-31.71%)
Mutual labels:  web-components
sonar-gherkin-plugin
SonarQube Cucumber Gherkin Analyzer
Stars: ✭ 33 (-19.51%)
Mutual labels:  styleguide
web-components-good-practices
😎☑️ Good Practices for build Web Components.
Stars: ✭ 80 (+95.12%)
Mutual labels:  web-components
component-runtime
Talend Component Kit (implementation repository)
Stars: ✭ 22 (-46.34%)
Mutual labels:  catalog
squest
Service request portal on top of Ansible Tower/AWX
Stars: ✭ 115 (+180.49%)
Mutual labels:  catalog
custom-element-boilerplate
Boilerplate for creating a custom element.
Stars: ✭ 137 (+234.15%)
Mutual labels:  web-components
TimeDoser-v2
🕑 Dosify your time (version 2, retired)
Stars: ✭ 52 (+26.83%)
Mutual labels:  web-components
vf-core
A (primarily CSS) framework that targets needs of life science websites and services
Stars: ✭ 16 (-60.98%)
Mutual labels:  styleguide
decanter
A collection of front end web resources.
Stars: ✭ 31 (-24.39%)
Mutual labels:  styleguide
vaadin-checkbox
The Web Component for customized checkboxes. Part of the Vaadin components.
Stars: ✭ 18 (-56.1%)
Mutual labels:  web-components
Fore
Fore - declarative programming with web components
Stars: ✭ 34 (-17.07%)
Mutual labels:  web-components

Birdseye

This project is under work in progress. Some features may not be implemented or have bugs. APIs would be changed near the future

Next generation component catalog.

Concept

  • No need to write source code for each component guide.
  • Essentially both build tool and view library agnostic.
  • Use Web Components instead of iframe to encapsulate styles for better dev experience.

Getting Started

Birdseye currently supports the following view libraries. Please refer the guide for a lib that you are using.

  • Vue.js

Vue.js with Vue CLI v3

Install @birdseye/app and @birdseye/vue in your Vue CLI project:

$ npm i -D @birdseye/app @birdseye/vue

Writing catalog by code

Create catalog file:

// birdseye/catalogs/MyButton.catalog.js
import { catalogFor } from '@birdseye/vue'
import MyButton from '@/components/MyButton.vue'

export default catalogFor(MyButton, 'MyButton')
  .add('primary', {
    props: {
      primary: true
    },
    slots: {
      default: 'Button Text'
    }
  })
  .add('hovered state', {
    data: {
      hover: true
    },
    slots: {
      default: 'Hovered'
    }
  })

Make birdseye/preview.js and bootstrap component catalog:

// birdseye/preview.js
import birdseye from '@birdseye/app'

// Load all your catalogs
const load = ctx => ctx.keys().map(x => ctx(x).default)
const catalogs = load(require.context('./catalogs/', true, /\.catalog\.js$/))

// Mount component catalog
birdseye('#app', catalogs)

Serve the component catalog by running vue-cli-service:

$ npm run serve -- birdseye/preview.js

Tweaking preview container style

When you want to modify preview container style (such as padding, background-color etc.), specify containerStyle option in your catalog:

import { catalogFor } from '@birdseye/vue'
import MyButton from '@/components/MyButton.vue'

export default catalogFor(MyButton, 'MyButton').add('white button', {
  props: {
    white: true
  },
  slots: {
    default: 'Button Text'
  },

  // Make background color black
  containerStyle: {
    backgroundColor: 'black'
  }
})

The above example makes the preview background color black. You can specify any CSS properties in containerStyle option.

Injecting slots and scoped slots

You can inject slots and scoped slots by using slots option of add function. Pass a template string for a slot:

import { catalogFor } from '@birdseye/vue'
import MyButton from '@/components/MyButton.vue'

export default catalogFor(MyButton, 'MyButton')
  .add('primary', {
    props: {
      primary: true
    },
    slots: {
      // Directly pass template string for the slot
      default: '<span>Button Text</span>'
    }
  })

Pass a function for a scoped slot. The first argument is injected scoped slot props. You can get $createElement helper via this context:

import { catalogFor } from '@birdseye/vue'
import MyButton from '@/components/MyButton.vue'

export default catalogFor(MyButton, 'MyButton')
  .add('primary', {
    props: {
      primary: true
    },
    slots: {
      // Pass scoped slot function
      default(props) {
        const h = this.$createElement
        return h('span', ['Button Text ', props.message])
      }
    }
  })

Wrapping catalog component with another element

You can use mapRender option to modify rendered element structure. mapRender should be a function that receives createElement function and original VNode object as arguments respectively.

The following example maps the catalog component with VApp component of Vuetify.

import { catalogFor } from '@birdseye/vue'
import { VApp } from 'vuetify/lib'
import MyButton from '@/components/MyButton.vue'

export default catalogFor(MyButton, {
  name: 'MyButton',

  // Define map function to render
  mapRender: (h, vnode) => {
    return h(VApp, [vnode])
  }
}).add('white button', {
  props: {
    white: true
  },
  slots: {
    default: 'Button Text'
  }
})

Writing catalog in SFC

Update the webpack config in vue.config.js:

module.exports = {
  chainWebpack: config => {
    if (process.env.NODE_ENV !== 'production') {
      // Process <birdseye> custom block with @birdseye/vue/webpack-loader
      // prettier-ignore
      config.module
        .rule('birdseye-vue')
          .resourceQuery(/blockType=birdseye/)
          .use('birdseye-vue-loader')
            .loader('@birdseye/vue/webpack-loader')
    }
  }
}

You write rendering patterns of a component in <birdseye> custom block. In each patterns item, you can specify props and data value which will be passed to the component. For example, in the following code, component guide will have two patterns for this component (named Test Component). The first pattern (Pattern Name 1) shows the component having "First pattern" as foo value and 123 as bar value.

<template>
  <div>
    <p>This is Vue.js component</p>
    <p>foo value: {{ foo }}</p>
    <p>bar value: {{ bar }}</p>
  </div>
</template>

<script>
export default {
  props: {
    foo: {
      type: String,
      default: ''
    }
  },

  data() {
    return {
      bar: 0
    }
  }
}
</script>

<birdseye>
{
  "name": "Test Component",
  "patterns": [
    {
      "name": "Pattern Name 1",
      "props": {
        "foo": "First pattern"
      },
      "data": {
        "bar": 123
      }
    },
    {
      "name": "Pattern Name 2",
      "props": {
        "foo": "Second pattern"
      },
      "data": {
        "bar": 456
      }
    }
  ]
}
</birdseye>

Finally, make birdseye/preview.js and bootstrap component catalog:

import birdseye from '@birdseye/app'
import { instrument } from '@birdseye/vue'

// Load all your component
const load = ctx => ctx.keys().map(x => ctx(x).default)
const components = load(require.context('../src/components', true, /\.vue$/))

// Mount component catalog
birdseye('#app', instrument(components))

You can serve the component catalog by running vue-cli-service:

$ npm run serve -- birdseye/preview.js

Visual Regression Testing

If you want to visual regression test your component catalog, use @birdseye/snapshot package. See docs of @birdseye/snapshot

License

MIT

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].