Skip to content

Commit

Permalink
Initial support for react
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinresol committed May 18, 2020
0 parents commit 54b4bd6
Show file tree
Hide file tree
Showing 45 changed files with 8,545 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
bin
.haxelib
node_modules
4 changes: 4 additions & 0 deletions .haxerc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"version": "4.0.5",
"resolveLibs": "scoped"
}
4 changes: 4 additions & 0 deletions .storybook/main.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module.exports = {
stories: ['../bin/demo.js'],
addons: ['@storybook/addon-actions', '@storybook/addon-links'],
};
26 changes: 26 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
sudo: required
dist: trusty

language: haxe

os:
- linux
- osx

# you can specify futher versions as found at http://haxe.org/website-content/downloads/versions.json
haxe:
- "3.4.0"
- development

matrix:
allow_failures:
- haxe: development

install:
- haxelib install travix
# to always use the latest version of travix comment out the previous line and uncomment the next
# - haxelib git travix https://github.com/back2dos/travix && pushd . && cd $(haxelib config)travix/git && haxe build-neko.hxml && popd
- haxelib run travix install

script:
- haxelib run travix js
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"haxe.enableCompilationServer": false
}
20 changes: 20 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"version": "2.0.0",
"tasks": [
{
"type": "haxe",
"args": "active configuration",
"problemMatcher": [
"$haxe-absolute",
"$haxe",
"$haxe-error",
"$haxe-trace"
],
"group": {
"kind": "build",
"isDefault": true
},
"label": "haxe: active configuration"
}
]
}
46 changes: 46 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Storybook support for Coconut

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

### Usage

First, setup Storybook according to the [official guide](https://storybook.js.org/docs/guides/guide-react/).

Then...

`Main.hx`:
```haxe
import coconut.storybook.*;
static function main() {
Storybook.add(new Button(), new AnotherComponent());
}
class Button extends Component {
@:story // functions tagged with @:story will be added to storybook
function withText() '
<button>Hello Button</button>
';
@:story
function withEmoji() '
<button>
<span role="img" aria-label="so cool">
😀 😎 👍 💯
</span>
</button>
';
}
class AnotherComponent extends Component {
// ...
}
```

`.storybook/main.js`:
```js
module.exports = {
stories: ['path/to/haxe/generated/output.js'],
// ....
};
```
6 changes: 6 additions & 0 deletions demo.hxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
-cp tests
-main Demo
-js bin/demo.js

-lib coconut.storybook
-lib coconut.react-dom
8 changes: 8 additions & 0 deletions haxe_libraries/coconut.data.hxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# @install: lix --silent download "gh://github.com/MVCoconut/coconut.data#777a1b617fa1fce831c03f428b4c65e5ceb92345" into coconut.data/0.9.0/github/777a1b617fa1fce831c03f428b4c65e5ceb92345
-lib tink_anon
-lib tink_lang
-lib tink_pure
-lib tink_state
-cp ${HAXE_LIBCACHE}/coconut.data/0.9.0/github/777a1b617fa1fce831c03f428b4c65e5ceb92345/src
-D coconut.data=0.9.0
--macro coconut.data.macros.Setup.run()
6 changes: 6 additions & 0 deletions haxe_libraries/coconut.react-core.hxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# @install: lix --silent download "gh://github.com/MVCoconut/coconut.react#a6ea79792947ced43364cd5ecbf2dc4e3c687d6a" into coconut.react-core/0.1.0/github/a6ea79792947ced43364cd5ecbf2dc4e3c687d6a
-lib coconut.ui
-lib react-next
-cp ${HAXE_LIBCACHE}/coconut.react-core/0.1.0/github/a6ea79792947ced43364cd5ecbf2dc4e3c687d6a/src
-D coconut.react-core=0.1.0
--macro coconut.react.macros.Setup.all()
6 changes: 6 additions & 0 deletions haxe_libraries/coconut.react-dom.hxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# @install: lix --silent download "gh://github.com/MVCoconut/coconut.react-dom#df454a3e3288d0ae55c3bdb933c8631234cdbe9b" into coconut.react-dom/0.3.0/github/df454a3e3288d0ae55c3bdb933c8631234cdbe9b
-lib coconut.react-core
-lib tink_domspec
-cp ${HAXE_LIBCACHE}/coconut.react-dom/0.3.0/github/df454a3e3288d0ae55c3bdb933c8631234cdbe9b/src
-D coconut.react-dom=0.3.0
--macro coconut.react.macros.Html.registerTags()
4 changes: 4 additions & 0 deletions haxe_libraries/coconut.storybook.hxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-lib coconut.ui
-cp ${SCOPE_DIR}/./src
-D coconut.storybook=0.0.0
--macro Sys.println("haxe_libraries/coconut.storybook.hxml:3: [Warning] Using dev version of library coconut.storybook")
8 changes: 8 additions & 0 deletions haxe_libraries/coconut.ui.hxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# @install: lix --silent download "gh://github.com/MVCoconut/coconut.ui#ba6fc91a548cddd2bd1c87a3bb856ae934097ba7" into coconut.ui/0.10.0/github/ba6fc91a548cddd2bd1c87a3bb856ae934097ba7
-lib coconut.data
-lib tink_anon
-lib tink_hxx
-lib tink_lang
-cp ${HAXE_LIBCACHE}/coconut.ui/0.10.0/github/ba6fc91a548cddd2bd1c87a3bb856ae934097ba7/src
-D coconut.ui=0.10.0
-D coconut_ui
3 changes: 3 additions & 0 deletions haxe_libraries/html-entities.hxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# @install: lix --silent download "haxelib:/html-entities#1.0.0" into html-entities/1.0.0/haxelib
-cp ${HAXE_LIBCACHE}/html-entities/1.0.0/haxelib/src
-D html-entities=1.0.0
3 changes: 3 additions & 0 deletions haxe_libraries/js-object.hxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# @install: lix --silent download "haxelib:/js-object#0.0.7" into js-object/0.0.7/haxelib
-cp ${HAXE_LIBCACHE}/js-object/0.0.7/haxelib/src
-D js-object=0.0.7
9 changes: 9 additions & 0 deletions haxe_libraries/react-next.hxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# @install: lix --silent download "haxelib:/react-next#1.120.0" into react-next/1.120.0/haxelib
-lib js-object
-lib tink_hxx
-cp ${HAXE_LIBCACHE}/react-next/1.120.0/haxelib/src/lib
-D react-next=1.120.0
--macro react.jsx.JsxStaticMacro.addHook()
--macro addGlobalMetadata('', '@:build(react.jsx.JsxStaticMacro.build())')

-D react=1.120.0
4 changes: 4 additions & 0 deletions haxe_libraries/tink_anon.hxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# @install: lix --silent download "haxelib:/tink_anon#0.5.0" into tink_anon/0.5.0/haxelib
-lib tink_macro
-cp ${HAXE_LIBCACHE}/tink_anon/0.5.0/haxelib/src
-D tink_anon=0.5.0
3 changes: 3 additions & 0 deletions haxe_libraries/tink_chunk.hxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
-D tink_chunk=0.3.1
# @install: lix --silent download "haxelib:/tink_chunk#0.3.1" into tink_chunk/0.3.1/haxelib
-cp ${HAXE_LIBCACHE}/tink_chunk/0.3.1/haxelib/src
8 changes: 8 additions & 0 deletions haxe_libraries/tink_cli.hxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
-D tink_cli=0.4.1
# @install: lix --silent download "gh://github.com/haxetink/tink_cli#e40960a7ddd72bdb3ca723aefb20591c514fae33" into tink_cli/0.4.1/github/e40960a7ddd72bdb3ca723aefb20591c514fae33
-lib tink_io
-lib tink_stringly
-lib tink_macro
-cp ${HAXE_LIBCACHE}/tink_cli/0.4.1/github/e40960a7ddd72bdb3ca723aefb20591c514fae33/src
# Make sure docs are generated
-D use-rtti-doc
3 changes: 3 additions & 0 deletions haxe_libraries/tink_core.hxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# @install: lix --silent download "haxelib:/tink_core#1.26.0" into tink_core/1.26.0/haxelib
-cp ${HAXE_LIBCACHE}/tink_core/1.26.0/haxelib/src
-D tink_core=1.26.0
5 changes: 5 additions & 0 deletions haxe_libraries/tink_domspec.hxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# @install: lix --silent download "haxelib:/tink_domspec#0.3.0" into tink_domspec/0.3.0/haxelib
-lib tink_macro
-lib tink_svgspec
-cp ${HAXE_LIBCACHE}/tink_domspec/0.3.0/haxelib/src
-D tink_domspec=0.3.0
6 changes: 6 additions & 0 deletions haxe_libraries/tink_hxx.hxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# @install: lix --silent download "haxelib:/tink_hxx#0.23.0" into tink_hxx/0.23.0/haxelib
-lib html-entities
-lib tink_anon
-lib tink_parse
-cp ${HAXE_LIBCACHE}/tink_hxx/0.23.0/haxelib/src
-D tink_hxx=0.23.0
5 changes: 5 additions & 0 deletions haxe_libraries/tink_io.hxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-D tink_io=0.7.1
# @install: lix --silent download "haxelib:/tink_io#0.7.1" into tink_io/0.7.1/haxelib
-lib tink_chunk
-lib tink_streams
-cp ${HAXE_LIBCACHE}/tink_io/0.7.1/haxelib/src
5 changes: 5 additions & 0 deletions haxe_libraries/tink_lang.hxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-D tink_lang=0.6.2
# @install: lix --silent download "gh://github.com/haxetink/tink_lang#895de3a5bd70dac380425d9938c613d6f9182540" into tink_lang/0.6.2/github/895de3a5bd70dac380425d9938c613d6f9182540
-lib tink_syntaxhub
-cp ${HAXE_LIBCACHE}/tink_lang/0.6.2/github/895de3a5bd70dac380425d9938c613d6f9182540/src
--macro tink.lang.Sugar.use()
4 changes: 4 additions & 0 deletions haxe_libraries/tink_macro.hxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# @install: lix --silent download "haxelib:/tink_macro#0.19.1" into tink_macro/0.19.1/haxelib
-lib tink_core
-cp ${HAXE_LIBCACHE}/tink_macro/0.19.1/haxelib/src
-D tink_macro=0.19.1
4 changes: 4 additions & 0 deletions haxe_libraries/tink_parse.hxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# @install: lix --silent download "haxelib:/tink_parse#0.3.1" into tink_parse/0.3.1/haxelib
-lib tink_core
-cp ${HAXE_LIBCACHE}/tink_parse/0.3.1/haxelib/src
-D tink_parse=0.3.1
3 changes: 3 additions & 0 deletions haxe_libraries/tink_priority.hxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# @install: lix --silent download "haxelib:tink_priority#0.1.3" into tink_priority/0.1.3/haxelib
-D tink_priority=0.1.3
-cp ${HAXESHIM_LIBCACHE}/tink_priority/0.1.3/haxelib/src
3 changes: 3 additions & 0 deletions haxe_libraries/tink_pure.hxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# @install: lix --silent download "haxelib:tink_pure#0.3.2" into tink_pure/0.3.2/haxelib
-D tink_pure=0.3.2
-cp ${HAXESHIM_LIBCACHE}/tink_pure/0.3.2/haxelib/src
4 changes: 4 additions & 0 deletions haxe_libraries/tink_state.hxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-D tink_state=0.11.0
# @install: lix --silent download "gh://github.com/haxetink/tink_state#68829f7c2abdf0469404da3f4d8407bbd287aea5" into tink_state/0.11.0/github/68829f7c2abdf0469404da3f4d8407bbd287aea5
-lib tink_core
-cp ${HAXE_LIBCACHE}/tink_state/0.11.0/github/68829f7c2abdf0469404da3f4d8407bbd287aea5/src
6 changes: 6 additions & 0 deletions haxe_libraries/tink_streams.hxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
-D tink_streams=0.3.2
# @install: lix --silent download "haxelib:/tink_streams#0.3.2" into tink_streams/0.3.2/haxelib
-lib tink_core
-cp ${HAXE_LIBCACHE}/tink_streams/0.3.2/haxelib/src
# temp for development, delete this file when pure branch merged
-D pure
5 changes: 5 additions & 0 deletions haxe_libraries/tink_stringly.hxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# @install: lix --silent download "haxelib:tink_stringly#0.2.0" into tink_stringly/0.2.0/haxelib
-D tink_stringly=0.2.0
-cp ${HAXESHIM_LIBCACHE}/tink_stringly/0.2.0/haxelib/src

-lib tink_core
3 changes: 3 additions & 0 deletions haxe_libraries/tink_svgspec.hxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# @install: lix --silent download "haxelib:/tink_svgspec#0.0.1" into tink_svgspec/0.0.1/haxelib
-cp ${HAXE_LIBCACHE}/tink_svgspec/0.0.1/haxelib/src
-D tink_svgspec=0.0.1
6 changes: 6 additions & 0 deletions haxe_libraries/tink_syntaxhub.hxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
-D tink_syntaxhub=0.4.3
# @install: lix --silent download "gh://github.com/haxetink/tink_syntaxhub#8b928af11fb39170dcb7254d02923777cddcc678" into tink_syntaxhub/0.4.3/github/8b928af11fb39170dcb7254d02923777cddcc678
-lib tink_priority
-lib tink_macro
-cp ${HAXE_LIBCACHE}/tink_syntaxhub/0.4.3/github/8b928af11fb39170dcb7254d02923777cddcc678/src
--macro tink.SyntaxHub.use()
7 changes: 7 additions & 0 deletions haxe_libraries/travix.hxml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# @install: lix --silent download "gh://github.com/back2dos/travix#9b264bacf690b055951af5b0679f3e7bb289a2ec" into travix/0.14.1/github/9b264bacf690b055951af5b0679f3e7bb289a2ec
# @post-install: cd ${HAXE_LIBCACHE}/travix/0.14.1/github/9b264bacf690b055951af5b0679f3e7bb289a2ec && haxe -cp src --run travix.PostDownload
# @run: haxelib run-dir travix ${HAXE_LIBCACHE}/travix/0.14.1/github/9b264bacf690b055951af5b0679f3e7bb289a2ec
-lib tink_cli
-cp ${HAXE_LIBCACHE}/travix/0.14.1/github/9b264bacf690b055951af5b0679f3e7bb289a2ec/src
-D travix=0.14.1
--macro travix.Macro.setup()
14 changes: 14 additions & 0 deletions haxelib.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "coconut.storybook",
"license": "MIT",
"tags": [],
"classPath": "src",
"contributors": [
"kevinresol"
],
"releasenote": "initial release",
"version": "0.0.0",
"dependencies": {
"coconut.ui": ""
}
}
16 changes: 16 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"dependencies": {},
"devDependencies": {
"@babel/core": "^7.9.6",
"@storybook/addon-actions": "^5.3.18",
"@storybook/addon-links": "^5.3.18",
"@storybook/addons": "^5.3.18",
"@storybook/react": "^5.3.18",
"babel-loader": "^8.1.0",
"dts2hx": "^0.9.1"
},
"scripts": {
"storybook": "start-storybook -p 6006",
"build-storybook": "build-storybook"
}
}
7 changes: 7 additions & 0 deletions src/coconut/storybook/Component.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package coconut.storybook;

@:autoBuild(coconut.storybook.Component.build())
class Component {
public function new() {}
macro function hxx(ethis, e);
}
17 changes: 17 additions & 0 deletions src/coconut/storybook/Component.macro.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package coconut.storybook;

import haxe.macro.Context;

using tink.MacroApi;

class Component {
public static function build() {
var builder = new ClassBuilder();
if(!builder.target.meta.has(':tink'))
builder.target.meta.add(':tink', [], Context.currentPos());
return null;
}

macro function hxx(ethis, e)
return macro coconut.Ui.hxx($e);
}
7 changes: 7 additions & 0 deletions src/coconut/storybook/Storybook.hx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package coconut.storybook;

import haxe.macro.Expr;

class Storybook {
public static macro function add(exprs:Array<Expr>):Expr;
}
Loading

0 comments on commit 54b4bd6

Please sign in to comment.