GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - MVCoconut/coconut.storybook: Coconut + Storybook.js

BranchesTags
Open more actions menu

Latest commit

 

History

54 Commits
54 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/workflows
.github/workflows
 
 
.storybook
.storybook
 
 
.vscode
.vscode
 
 
haxe_libraries
haxe_libraries
 
 
src/coconut/storybook
src/coconut/storybook
 
 
tests
tests
 
 
.gitignore
.gitignore
 
 
.haxerc
.haxerc
 
 
README.md
README.md
 
 
demo.hxml
demo.hxml
 
 
extraParams.hxml
extraParams.hxml
 
 
haxelib.json
haxelib.json
 
 
package.json
package.json
 
 
tests.hxml
tests.hxml
 
 
yarn.lock
yarn.lock
 
 

Repository files navigation

Storybook support for Coconut

Storybook: https://storybook.js.org/

Usage

First, setup Storybook according to the official guide.

Note1: For coconut.vdom support, use the npm package "storybook-coconut" instead of "@storybook/react".
Note2: Multiple coconut target is not supported, that's limitation of storybook's architecture.

Then...

Main.hx:

import coconut.storybook.*;

static function main() {
	Storybook.add(new Button(), new AnotherComponent());
}

@:title('foo/Button') // optional title, default to full path of the class separated by a slash ("/")
class Button extends Component {
	@:story // functions tagged with @:story will be added to storybook
	function withText() '
		<button>Hello Button</button>
	';
	
	@:story('with emoji') // custom story name
	@:decorator(this.wrap) // decorators
	@:parameter({note: 'component note'}, foo = 1) // parameters, expressions will be forwarded to `tink.Anon.merge`
	function withEmoji() '
		<button>
			<span role="img" aria-label="so cool">
				šŸ˜€ šŸ˜Ž šŸ‘ šŸ’Æ
			</span>
		</button>
	';
	
	@:story
	@:state(var value:Int = 0) // add state to a story
	function withState() '
		<button onclick=${value += 1}>
			Clicked ${value} time(s)
		</button>
	';
	
	function wrap(f:()->ReactSingleFragment) '
		<div style=${{backgroundColor: 'black'}}>${f()}</div>
	';
}

class AnotherComponent extends Component {
	// ...
}

.storybook/main.js:

module.exports = {
	stories: ['path/to/haxe/generated/output.js'],
	// ....
};

Note

@:decorator and @:parameter are supported at both component (class) and story (method) level.

In all the metadata, you can use explicit this to reference fields of the class instance. e.g.

@:title('Button: ' + this.variant)
class Button {
	public final variant:String;
}

About

Coconut + Storybook.js

storybook.js.org/

Resources

Readme
Activity
Custom properties

Stars

9 stars

Watchers

1 watching

Forks

2 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800Ɨ600. No cookies required.