storybook

package
v0.2.598 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 1, 2024 License: MIT Imports: 20 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewHandler

func NewHandler(name string, f interface{}, args ...Arg) http.Handler

Types

type Arg

type Arg struct {
	Name    string
	Value   interface{}
	Control interface{}
	Get     func(q url.Values) interface{}
}

Controls for the configuration. See https://storybook.js.org/docs/react/essentials/controls

func BooleanArg

func BooleanArg(name string, value bool) Arg

func FloatArg

func FloatArg(name string, value float64, min, max, step float64) Arg

func IntArg

func IntArg(name string, value int, conf IntArgConf) Arg

func ObjectArg

func ObjectArg(name string, value interface{}, valuePtr interface{}) Arg

func TextArg

func TextArg(name, value string) Arg

type Conf

type Conf struct {
	Title      string          `json:"title"`
	Parameters StoryParameters `json:"parameters"`
	Args       *SortedMap      `json:"args"`
	ArgTypes   *SortedMap      `json:"argTypes"`
	Stories    []Story         `json:"stories"`
}

func NewConf

func NewConf(title string, args ...Arg) *Conf

func (*Conf) AddStory

func (c *Conf) AddStory(name string, args ...Arg)

type IntArgConf

type IntArgConf struct{ Min, Max, Step *int }

type SortedMap

type SortedMap struct {
	// contains filtered or unexported fields
}

func NewSortedMap

func NewSortedMap() *SortedMap

func (*SortedMap) Add

func (sm *SortedMap) Add(key string, value interface{})

func (*SortedMap) MarshalJSON

func (sm *SortedMap) MarshalJSON() (output []byte, err error)

type Story

type Story struct {
	Name string `json:"name"`
	Args *SortedMap
}

type StoryParameters

type StoryParameters struct {
	Server map[string]interface{} `json:"server"`
}

type Storybook

type Storybook struct {
	// Path to the storybook-server directory, defaults to ./storybook-server.
	Path string
	// RoutePrefix is the prefix of HTTP routes, e.g. /prod/
	RoutePrefix string
	// Config of the Stories.
	Config map[string]*Conf
	// Handlers for each of the components.
	Handlers map[string]http.Handler
	// Handler used to serve Storybook, defaults to filesystem at ./storybook-server/storybook-static.
	StaticHandler http.Handler
	Header        string
	Server        http.Server
	Log           *zap.Logger
}

func New

func New(conf ...StorybookConfig) *Storybook

func (*Storybook) AddComponent

func (sh *Storybook) AddComponent(name string, componentConstructor interface{}, args ...Arg)

func (*Storybook) Build

func (sh *Storybook) Build(ctx context.Context) (err error)

func (*Storybook) ListenAndServeWithContext

func (sh *Storybook) ListenAndServeWithContext(ctx context.Context) (err error)

func (*Storybook) ServeHTTP

func (sh *Storybook) ServeHTTP(w http.ResponseWriter, r *http.Request)

type StorybookConfig

type StorybookConfig func(*Storybook)

func WithHeader added in v0.2.184

func WithHeader(header string) StorybookConfig

func WithServerAddr

func WithServerAddr(addr string) StorybookConfig

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL