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.
- package/README.md +41 -11
- 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
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
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
|
-
|
|
116
|
-
|
|
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
|
-
|
|
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
|