jbx 2.3.0 → 2.4.0
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/CHANGELOG.md +4 -0
- package/index.js +9 -7
- package/package.json +1 -1
- package/style.css +4 -0
package/CHANGELOG.md
CHANGED
package/index.js
CHANGED
|
@@ -6,10 +6,10 @@ const SIZE = window.innerWidth > 1280 ? 16 : window.innerWidth > 640 ? 14 : 12;
|
|
|
6
6
|
const BASE_RADIUS = SIZE / 2;
|
|
7
7
|
const BASE_FONT_SIZE = SIZE;
|
|
8
8
|
|
|
9
|
-
export function Component(className, styleSrc, config = {}) {
|
|
9
|
+
export function Component(className, styleSrc = {}, config = {}) {
|
|
10
10
|
const { element = `div`, styleProps } = config;
|
|
11
11
|
|
|
12
|
-
return function MakeComponent({ children, ...props }) {
|
|
12
|
+
return function MakeComponent({ children, style = {}, ...props }) {
|
|
13
13
|
const passProps = styleProps
|
|
14
14
|
? Object.keys(props)
|
|
15
15
|
.filter((e) => !styleProps.includes(e))
|
|
@@ -19,11 +19,13 @@ export function Component(className, styleSrc, config = {}) {
|
|
|
19
19
|
}, {})
|
|
20
20
|
: props;
|
|
21
21
|
|
|
22
|
+
const calculatedStyle = typeof styleSrc === 'function' ? styleSrc(props) : styleSrc;
|
|
23
|
+
|
|
22
24
|
return React.createElement(
|
|
23
25
|
element,
|
|
24
26
|
{
|
|
25
27
|
className,
|
|
26
|
-
style:
|
|
28
|
+
style: { ...style, ...calculatedStyle },
|
|
27
29
|
...passProps
|
|
28
30
|
},
|
|
29
31
|
children
|
|
@@ -170,8 +172,8 @@ export const CodeTextarea = Component(`jbx-code-area`, null, { element: 'textare
|
|
|
170
172
|
|
|
171
173
|
export const CheckboxHidden = Component(`jbx-checkbox-hidden`, ({ checked }) => {
|
|
172
174
|
return {
|
|
173
|
-
height:
|
|
174
|
-
width:
|
|
175
|
+
height: SIZE * 2 - 4,
|
|
176
|
+
width: SIZE * 2 - 4,
|
|
175
177
|
paddingTop: 2,
|
|
176
178
|
paddingLeft: 2,
|
|
177
179
|
backgroundColor: checked ? 'var(--accent-color)' : 'white',
|
|
@@ -208,8 +210,8 @@ export const Checkbox = function Checkbox({ label, checked, onChange }) {
|
|
|
208
210
|
'svg',
|
|
209
211
|
{
|
|
210
212
|
xmlns: 'http://www.w3.org/2000/svg',
|
|
211
|
-
width:
|
|
212
|
-
height:
|
|
213
|
+
width: SIZE * 2 - 8,
|
|
214
|
+
height: SIZE * 2 - 8,
|
|
213
215
|
fill: 'none',
|
|
214
216
|
stroke: 'currentColor',
|
|
215
217
|
strokeLinecap: 'round',
|
package/package.json
CHANGED