Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

https://github.com/rnons/purescript-halogen-storybook

A library to assemble examples or develop components separately.
https://github.com/rnons/purescript-halogen-storybook

examples halogen purescript

Last synced: 19 days ago
JSON representation

A library to assemble examples or develop components separately.

Lists

README

        

# purescript-halogen-storybook


purescript-halogen-storybook on Pursuit

A library to assemble examples or develop components separately.

[DEMO](https://rnons.github.io/purescript-halogen-storybook/)

You might be interested in [purescript-halogen-custom-element](https://github.com/nonbili/purescript-halogen-custom-element) which allows embedding Halogen components anywhere in an HTML or Markdown file.

## How to use

First define the stories. Each story consists of a name and a component. If the name is empty string, it will be rendered as the index page.

```purescript
import Foreign.Object as Object
import Halogen.Storybook (Stories, runStorybook, proxy)

stories :: forall m. Stories m
stories = Object.fromFoldable
[ Tuple "" $ proxy ExpIndex.component -- override the index page
, Tuple "count" $ proxy ExpCount.component
, Tuple "input" $ proxy ExpInput.component
]
```

Then add a `runStorybook` line to your main function. That's it.

```purescript
main = HA.runHalogenAff do
HA.awaitBody >>=
runStorybook
{ stories
, logo: Nothing -- pass `Just HH.PlainHTML` to override the logo
}
```

You need to include the CSS by yourself, use [Storybook.css](https://github.com/rnons/purescript-halogen-storybook/blob/master/examples/src/Storybook.css) as an example.