Skip to content

Commit

Permalink
Add improved docs
Browse files Browse the repository at this point in the history
  • Loading branch information
wooorm committed Apr 1, 2022
1 parent e70ba2a commit 2f8c133
Show file tree
Hide file tree
Showing 9 changed files with 134 additions and 110 deletions.
21 changes: 21 additions & 0 deletions example.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import {h, s} from './index.js'

// Children as an array:
console.log(
h('.foo#some-id', [
h('span', 'some text'),
h('input', {type: 'text', value: 'foo'}),
h('a.alpha', {class: 'bravo charlie', download: 'download'}, [
'delta',
'echo'
])
])
)

// SVG:
console.log(
s('svg', {xmlns: 'http://www.w3.org/2000/svg', viewbox: '0 0 500 500'}, [
s('title', 'SVG `<circle>` element'),
s('circle', {cx: 120, cy: 120, r: 100})
])
)
4 changes: 2 additions & 2 deletions html.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @typedef {import('./lib/index.js').Child} Child Acceptable child value
* @typedef {import('./lib/index.js').Properties} Properties Acceptable properties value.
* @typedef {import('./lib/index.js').Child} Child
* @typedef {import('./lib/index.js').Properties} Properties
*/

export {h} from './lib/html.js'
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @typedef {import('./lib/index.js').Child} Child Acceptable child value
* @typedef {import('./lib/index.js').Properties} Properties Acceptable properties value.
* @typedef {import('./lib/index.js').Child} Child
* @typedef {import('./lib/index.js').Properties} Properties
*/

export {h, s} from './lib/index.js'
2 changes: 2 additions & 0 deletions lib/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,12 @@
* @typedef {Array<string|number>} HArrayValue
* @typedef {HPrimitiveValue|HArrayValue} HPropertyValue
* @typedef {{[property: string]: HPropertyValue|HStyle}} HProperties
* Acceptable properties value.
*
* @typedef {string|number|null|undefined} HPrimitiveChild
* @typedef {Array<Node|HPrimitiveChild>} HArrayChild
* @typedef {Node|HPrimitiveChild|HArrayChild} HChild
* Acceptable child value
*/

import {find, normalize} from 'property-information'
Expand Down
4 changes: 2 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @typedef {import('./core.js').HChild} Child Acceptable child value
* @typedef {import('./core.js').HProperties} Properties Acceptable properties value.
* @typedef {import('./core.js').HChild} Child
* @typedef {import('./core.js').HProperties} Properties
*/

export {h} from './html.js'
Expand Down
2 changes: 1 addition & 1 deletion lib/runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* @typedef {import('./core.js').HStyle} HStyle
* @typedef {import('./core.js').core} Core
*
* @typedef {{[x: string]: HPropertyValue|HStyle|HChild}} JSXProps
* @typedef {Record<string, HPropertyValue|HStyle|HChild>} JSXProps
*/

/**
Expand Down
4 changes: 2 additions & 2 deletions lib/svg.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* @typedef {import('./core.js').HChild} Child Acceptable child value
* @typedef {import('./core.js').HProperties} Properties Acceptable properties value.
* @typedef {import('./core.js').HChild} Child
* @typedef {import('./core.js').HProperties} Properties
*
* @typedef {import('./jsx-classic').Element} s.JSX.Element
* @typedef {import('./jsx-classic').IntrinsicAttributes} s.JSX.IntrinsicAttributes
Expand Down
Loading

0 comments on commit 2f8c133

Please sign in to comment.