Skip to content

v1.0.0-beta.26

Compare
Choose a tag to compare
@jacob-8 jacob-8 released this 23 Apr 15:47
· 49 commits to main since this release

   🚀 Features and🚨 Breaking Changes

  • simplify variant and composition apis by @jacob-8 in #36

For variants, what used to be:

import type { Variant, Viewports } from 'kitbook'
import type Component from './Foo.svelte'

export const viewports: Viewports[] = [
  { width: 500, height: 200 }
]

export const variants: Variant<Component>[] = [
  {
    name: 'First',
    props: {
      foo: 'a',
    }
  },
  {
    name: 'Second',
    description: 'This is the second variant.',
    props: {
      foo: 'b',
    },
  },
]

Is now:

import type { Variant, VariantMeta } from 'kitbook'
import type Component from './Foo.svelte'

export const shared_meta: VariantMeta = {
  viewports: [
    { width: 500, height: 200 }
  ]
}

export const First: Variant<Component> = {
  foo: 'a',
}

export const Second: Variant<Component> = {
  foo: 'b',
  _meta: {
    description: 'This is the second variant.',
  },
}

As you are able, update to the new api which only exports the optional shared_meta property plus the variants themselves. Kitbook will still accept the deprecated variants array api, but the types will throw errors. As you are transitioning, for the moment you can just find-replace all the Variant types to be DeprecatedVariant.

A quick tip to upgrade is to delete your variants.ts file and then create a new one using Kitbook's Add Variant button. Then use VS Code's version control to paste from your old file into the new. Alternatively, you can ask an LLM to help you. I've added a one-shot prompt to help out with that.

Compositions also still work with the old api, but moving forward config should be defined in this manner to get intellisense and prepare for removal of the deprecation in a future version:

<script context="module" lang="ts">
  import { defineComposition } from 'kitbook'

  export const config = defineComposition({
    viewports: [{ height: 50 }],
  })
</script>

Full Changelog: v1.0.0-beta.24...v1.0.0-beta.26