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 CHANGED
@@ -1,3 +1,7 @@
1
+ # 2.4.0
2
+
3
+ - Respect `style` properties on `Box`.
4
+
1
5
  # 2.3.0
2
6
 
3
7
  - Add CodeTextarea.
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: typeof styleSrc === 'function' ? styleSrc(props) : styleSrc,
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: BASE_SIZE * 2 - 4,
174
- width: BASE_SIZE * 2 - 4,
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: BASE_SIZE * 2 - 8,
212
- height: BASE_SIZE * 2 - 8,
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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jbx",
3
- "version": "2.3.0",
3
+ "version": "2.4.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "author": "hi@javier.xyz",
package/style.css CHANGED
@@ -153,6 +153,10 @@ body,
153
153
  padding: calc(var(--size) * 2.5) calc(var(--size) * 1.5) calc(var(--size) * 4);
154
154
  }
155
155
 
156
+ .jbx-box {
157
+ flex: 1;
158
+ }
159
+
156
160
  .jbx-inline {
157
161
  flex: 1;
158
162
  display: flex;