arche 0.3.2 → 0.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +41 -11
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -96,27 +96,57 @@ import Arche from 'https://unpkg.com/arche/es.js'
96
96
  ```coffeescript [specscript]
97
97
  Arche(React {
98
98
  createElement: (type, props?, children?)=>ReactElement,
99
+ }, options? {
100
+ styled?: {
101
+ div: function,
102
+ p: funcion,
103
+ span: function,
104
+ // etc
105
+ },
106
+ styledMemoizationCap?: number, // defaults to 1000
99
107
  }) -> ReactElement
100
108
  ```
101
109
 
102
110
  # Usage
111
+ Set Arche elements globally for a great developer experience.
103
112
  ```javascript
113
+ // global.js
114
+
104
115
  const ReactElement = Arche(React)
105
116
 
106
- const {
107
- A, P, B, Q, I, Ul, Ol, Li,
108
- H1, H2, H3, H4, H5, H6, Hr, Br,
109
- Script, Html, Body, Nav, Section, Article, Footer, Span, Div, Img, Video,
110
- Form, Fieldset, Input, Label, Textarea, Select, Option,
111
- Button, Iframe, Blockquote, Code, Pre,
112
- } = ReactElement
117
+ window.ReactElement = ReactElement
118
+
119
+ for (const elementName in ReactElement) {
120
+ window[elementName] = ReactElement[elementName]
121
+ }
122
+
123
+ // Arche for now does not export every element
124
+ // create the ones you need like so
125
+ window.Aside = ReactElement('aside')
126
+ window.Svg = ReactElement('svg')
127
+ window.Path = ReactElement('path')
113
128
  ```
114
129
 
115
- Don't see an element you need? Just create it!
116
- ```javascript [playground]
117
- const ReactElement = Arche(React)
130
+ ## Using styled
131
+ Arche accepts a `styled` option from css-in-js libraries like [Styled Components](https://styled-components.com/) to enable a `css` prop on the base elements. This does not apply to composite components (those created with `ReactElement(props => {...})` syntax)
118
132
 
119
- const Aside = ReactElement('aside')
133
+ ```javascript
134
+ // global.js
135
+ const ReactElement = Arche(React, { styled })
136
+ ```
137
+
138
+ Elements can now specify a `css` prop to use css-in-js.
139
+
140
+ ```javascript
141
+ // MyComponent.js
142
+ const MyComponent = ReactElement(props => {
143
+ return Div({
144
+ css: `
145
+ width: 500px;
146
+ background-color: pink;
147
+ `,
148
+ })
149
+ })
120
150
  ```
121
151
 
122
152
  ## Using React Context
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "arche",
3
- "version": "0.3.2",
3
+ "version": "0.3.3",
4
4
  "description": "HTML as JavaScript",
5
5
  "author": "Richard Tong",
6
6
  "license": "MIT",