Skip to content

Commit ee741fb

Browse files
committed
Add README and bower.json
1 parent e4f5a39 commit ee741fb

File tree

5 files changed

+85
-0
lines changed

5 files changed

+85
-0
lines changed

README.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# purescript-halogen-custom-element
2+
3+
A library to convert Halogen components to [custom elements](https://developer.mozilla.org/en-US/docs/Web/Web_Components/Using_custom_elements).
4+
5+
## Usage
6+
7+
```
8+
import Halogen.CustomElement as CustomElement
9+
10+
main :: Effect Unit
11+
main = do
12+
CustomElement.define "halogen-hello" component
13+
```
14+
15+
Now include `main.js` in your HTML file, then put `<halogen-hello></halogen-hello>` anywhere in your HTML, and the Halogen component will be rendered there.
16+
17+
The original purpose of this library is to support putting Halogen component inside Markdown, so that write documentation together with demos becomes easy. See the [documentation of halogen-nselect](https://nonbili.github.io/purescript-halogen-nselect/) as an example.
18+
19+
## Limitation
20+
21+
Currently, the component passed to `CustomElement.define` is required to have `Unit` as input type.
22+
23+
```purescript
24+
module Halogen.CustomElement (define) where
25+
26+
define
27+
:: forall query output
28+
. String
29+
-> H.Component HH.HTML query Unit output Aff
30+
-> Effect Unit
31+
```
32+
33+
However, I think it's possible to collect all attributes of the defined custome element, and pass a `Foreign` or `Json` back to the underlying Halogen component.
34+
35+
36+
## Development
37+
38+
```
39+
cd example
40+
yarn start
41+
```

bower.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"name": "purescript-halogen-custom-element",
3+
"description": "Convert Halogen components to custom elements",
4+
"authors": [
5+
"Ping Chen <remotenonsense@gmail.com>"
6+
],
7+
"repository": {
8+
"type": "git",
9+
"url": "git://github.com/nonbili/purescript-halogen-custom-element.git"
10+
},
11+
"license": "BSD-3-Clause",
12+
"ignore": [
13+
"**/.*",
14+
"node_modules",
15+
"bower_components",
16+
"output"
17+
],
18+
"dependencies": {
19+
"purescript-halogen": "^5.0.0-rc.7"
20+
}
21+
}

example/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Use Halogen component as a custom element
2+
3+
The following text is rendered by a Halogen component, run `yarn start` to see it rendered.
4+
5+
<halogen-hello></halogen-hello>
6+
7+
<script src="main.js"></script>

example/package.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"scripts": {
3+
"start": "parcel README.md"
4+
},
5+
"devDependencies": {
6+
"marked": "^0.8.0"
7+
}
8+
}

example/yarn.lock

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2+
# yarn lockfile v1
3+
4+
5+
marked@^0.8.0:
6+
version "0.8.0"
7+
resolved "https://registry.yarnpkg.com/marked/-/marked-0.8.0.tgz#ec5c0c9b93878dc52dd54be8d0e524097bd81a99"
8+
integrity sha512-MyUe+T/Pw4TZufHkzAfDj6HarCBWia2y27/bhuYkTaiUnfDYFnCP3KUN+9oM7Wi6JA2rymtVYbQu3spE0GCmxQ==

0 commit comments

Comments
 (0)