jbx 1.3.0 → 1.7.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/.editorconfig ADDED
@@ -0,0 +1,12 @@
1
+ root = true
2
+
3
+ [*]
4
+ charset = utf-8
5
+ indent_style = space
6
+ indent_size = 2
7
+ insert_final_newline = true
8
+ trim_trailing_whitespace = true
9
+
10
+ [*.md]
11
+ max_line_length = off
12
+ trim_trailing_whitespace = false
package/.prettierrc ADDED
@@ -0,0 +1,13 @@
1
+ {
2
+ "singleQuote": true,
3
+ "printWidth": 100,
4
+ "editor.formatOnSave": true,
5
+ "proseWrap": "always",
6
+ "tabWidth": 2,
7
+ "requireConfig": false,
8
+ "useTabs": false,
9
+ "trailingComma": "none",
10
+ "bracketSpacing": true,
11
+ "jsxBracketSameLine": false,
12
+ "semi": true
13
+ }
package/CHANGELOG.md CHANGED
@@ -1,11 +1,33 @@
1
- # 1.3.0
1
+ # v1.7.0
2
+
3
+ - Add `touch-action: pan-y;`.
4
+
5
+ # v1.6.0
6
+
7
+ - `Button` now moves when clicked.
8
+
9
+ # v1.5.0
10
+
11
+ - Add `SmallText`.
12
+ - Add `MainHeader`.
13
+ - Prevent `Checkbox` from resizing from responsive `size`.
14
+
15
+ # v1.3.0
16
+
17
+ - Add `Checkbox`.
18
+
19
+ # v1.3.0
20
+
2
21
  - Add `CodeSnippet` component.
3
22
 
4
- # 1.2.0
23
+ # v1.2.0
24
+
5
25
  - Increase padding of `Container`.
6
26
 
7
- # 1.1.0
27
+ # v1.1.0
28
+
8
29
  - Add padding to `Container`.
9
30
 
10
- # 1.0.0
31
+ # v1.0.0
32
+
11
33
  - Initial release
package/README.md CHANGED
@@ -5,38 +5,22 @@ npm i jbx@latest capsize@latest styled-components@latest
5
5
  ```
6
6
 
7
7
  ```jsx
8
- import {
9
- JBX,
10
- HeaderH1,
11
- Text,
12
- Space,
13
- Container,
14
- } from 'jbx';
8
+ import { JBX, MainHeader, Text, Space, Container } from "jbx";
15
9
 
16
10
  function App() {
17
11
  return (
18
12
  <Container>
19
- <JBX accent={'#eb4d4b'} />
20
- <HeaderH1
21
- style={{
22
- fontWeight: 900,
23
- display: 'inline-block',
24
- width: 'auto',
25
- padding: '6px',
26
- backgroundColor: 'var(--accent-color)'
27
- }}
28
- >
29
- React Blur
30
- </HeaderH1>
13
+ <JBX accent={"#eb4d4b"} />
14
+ <MainHeader>React Blur</MainHeader>
31
15
  <Space h={1} />
32
16
  <Text>
33
- Tool that creates animated CSS transitions. Add sprites and get the code ready to paste in
34
- your site.
17
+ Tool that creates animated CSS transitions. Add sprites and get the code
18
+ ready to paste in your site.
35
19
  </Text>
36
20
  <Space h={2} />
37
21
  <Text>
38
- Tool that creates animated CSS transitions. Add sprites and get the code ready to paste in
39
- your site.
22
+ Tool that creates animated CSS transitions. Add sprites and get the code
23
+ ready to paste in your site.
40
24
  </Text>
41
25
  </Container>
42
26
  );
@@ -44,4 +28,3 @@ function App() {
44
28
 
45
29
  export default App;
46
30
  ```
47
-
package/index.js CHANGED
@@ -1,9 +1,22 @@
1
- import React from "react";
1
+ import { createElement, Fragment } from 'react';
2
2
 
3
- import Styled from "styled-components";
4
- import capsize from "capsize";
3
+ import Styled from 'styled-components';
4
+ import capsize from 'capsize';
5
5
 
6
- import { createGlobalStyle } from "styled-components";
6
+ import { createGlobalStyle } from 'styled-components';
7
+
8
+ const BASE_SIZE = 16;
9
+ const SIZE = window.innerHeight > 640 ? 16 : 14;
10
+ const BASE_RADIUS = SIZE / 2;
11
+ const SPACE = SIZE;
12
+ const BASE_FONT_SIZE = SIZE;
13
+
14
+ const fontMetrics = {
15
+ capHeight: 1364,
16
+ ascent: 1950,
17
+ descent: -494,
18
+ unitsPerEm: 2048
19
+ };
7
20
 
8
21
  export const JBX = createGlobalStyle`
9
22
  html {
@@ -23,12 +36,14 @@ export const JBX = createGlobalStyle`
23
36
 
24
37
  body {
25
38
  touch-action: manipulation;
39
+ touch-action: pan-y;
26
40
  }
27
41
 
28
42
  body,
29
43
  input,
30
44
  textarea {
31
45
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", sans-serif;
46
+ font-size: 16px;
32
47
  }
33
48
 
34
49
  body {
@@ -41,109 +56,108 @@ export const JBX = createGlobalStyle`
41
56
  }
42
57
  `;
43
58
 
44
- const SIZE = window.innerHeight > 640 ? 16 : 14;
45
-
46
- const SPACE = SIZE;
47
- const BASE_FONT_SIZE = SIZE;
48
-
49
- const fontMetrics = {
50
- capHeight: 1364,
51
- ascent: 1950,
52
- descent: -494,
53
- unitsPerEm: 2048,
54
- };
55
-
56
59
  const BaseText = Styled.div({});
57
60
 
58
61
  function textProps(capsizeConfig) {
59
62
  const capsizeComputed = {
60
63
  fontMetrics,
61
64
  lineGap: BASE_FONT_SIZE * 0.618,
62
- ...capsizeConfig,
65
+ ...capsizeConfig
63
66
  };
64
67
 
65
68
  return capsize(capsizeComputed);
66
69
  }
67
70
 
68
71
  export const Container = Styled.div({
69
- maxWidth: "1080px",
70
- margin: "0 auto",
71
- padding: `${SIZE * 2.5}px ${SIZE * 1.5}px ${SIZE * 4}px`,
72
+ maxWidth: '1080px',
73
+ margin: '0 auto',
74
+ padding: `${SIZE * 2.5}px ${SIZE * 1.5}px ${SIZE * 4}px`
72
75
  });
73
76
 
74
77
  export const Text = Styled(BaseText)({
75
- margin: "0",
76
78
  ...textProps({
77
- capHeight: (BASE_FONT_SIZE * 3) / 3,
78
- }),
79
+ capHeight: BASE_FONT_SIZE
80
+ })
81
+ });
82
+
83
+ export const SmallText = Styled(BaseText)({
84
+ ...textProps({
85
+ capHeight: BASE_FONT_SIZE * 0.8,
86
+ lineGap: BASE_FONT_SIZE / 3
87
+ })
79
88
  });
80
89
 
81
90
  export const ButtonContainer = Styled.button({
82
- appearance: "none",
83
- userSelect: "none",
84
- cursor: "pointer",
85
- display: "inline-block",
86
- backgroundColor: "#eee",
87
- boxShadow: "3px 3px 0 #ccc",
91
+ appearance: 'none',
92
+ userSelect: 'none',
93
+ cursor: 'pointer',
94
+ display: 'inline-block',
95
+ backgroundColor: '#eee',
96
+ boxShadow: '3px 3px 0 #ccc',
88
97
  padding: `0 ${SPACE / 2}px`,
89
- border: "none",
98
+ border: 'none',
90
99
  height: SPACE * 2.5,
100
+ '&:active': {
101
+ top: 1,
102
+ left: 1,
103
+ boxShadow: '2px 2px 0 #ccc'
104
+ }
91
105
  });
92
106
 
93
- export const Button = function (props) {
107
+ export const Button = function Button(props) {
94
108
  const { children, ...other } = props;
95
- return React.createElement(ButtonContainer, other, React.createElement(Text, {}, children));
109
+ return createElement(ButtonContainer, other, createElement(Text, {}, children));
96
110
  };
97
111
 
98
112
  export const Input = Styled.input({
99
- "-webkit-text-fill-color": "#777",
113
+ '-webkit-text-fill-color': '#777',
100
114
  opacity: 1,
101
115
  flex: 1,
102
- display: "block",
103
- appearance: "none",
104
- border: "none",
116
+ display: 'block',
117
+ appearance: 'none',
118
+ border: 'none',
105
119
  borderRadius: 0,
106
120
  height: SPACE * 2.5,
107
- backgroundColor: "#eee",
121
+ backgroundColor: '#eee',
108
122
  ...textProps({
109
- capHeight: (BASE_FONT_SIZE * 3) / 3,
123
+ capHeight: (BASE_FONT_SIZE * 3) / 3
110
124
  }),
111
125
  padding: `0 ${SPACE / 2}px`,
112
126
  boxShadow: `inset rgba(0, 0, 0, 0.04) 3px 3px 0, inset rgba(0, 0, 0, 0.03) 0.5px 0.5px 0`,
113
- color: "#777",
127
+ color: '#777'
114
128
  });
115
129
 
116
130
  export const Range = Styled.input({
117
131
  flex: 1,
118
- width: "100%",
119
- appearance: "none",
120
- backgroundColor: "var(--accent-color)",
132
+ width: '100%',
133
+ appearance: 'none',
134
+ backgroundColor: 'var(--accent-color)',
121
135
  height: SPACE,
122
136
  borderRadius: 0,
123
- "&::-webkit-slider-thumb": {
124
- appearance: "none",
125
- boxShadow: "none",
137
+ '&::-webkit-slider-thumb': {
138
+ appearance: 'none',
139
+ boxShadow: 'none',
126
140
  borderRadius: 0,
127
141
  height: SPACE * 2,
128
142
  width: SPACE,
129
- backgroundColor: "#000",
130
- border: "none",
143
+ backgroundColor: '#000',
144
+ border: 'none'
131
145
  },
132
- "&::-moz-range-thumb": {
133
- appearance: "none",
134
- boxShadow: "none",
146
+ '&::-moz-range-thumb': {
147
+ appearance: 'none',
148
+ boxShadow: 'none',
135
149
  borderRadius: 0,
136
150
  height: SPACE * 2,
137
151
  width: SPACE,
138
- backgroundColor: "#000",
139
- border: "none",
152
+ backgroundColor: '#000',
153
+ border: 'none'
140
154
  },
141
- "&::-webkit-slider-runnable-track": {
142
- appearance: "none",
143
- },
144
- ":focus": {
145
- outline: "none",
155
+ '&::-webkit-slider-runnable-track': {
156
+ appearance: 'none'
146
157
  },
158
+ ':focus': {
159
+ outline: 'none'
160
+ }
147
161
  });
148
162
 
149
163
  export const HeaderH4 = Styled.h4({
@@ -153,8 +167,8 @@ export const HeaderH4 = Styled.h4({
153
167
  fontWeight: 700,
154
168
  ...textProps({
155
169
  capHeight: BASE_FONT_SIZE,
156
- lineGap: BASE_FONT_SIZE,
157
- }),
170
+ lineGap: BASE_FONT_SIZE
171
+ })
158
172
  });
159
173
  export const HeaderH3 = Styled.h3({
160
174
  margin: 0,
@@ -163,8 +177,8 @@ export const HeaderH3 = Styled.h3({
163
177
  fontWeight: 500,
164
178
  ...textProps({
165
179
  capHeight: BASE_FONT_SIZE * 1 * 1.25,
166
- lineGap: BASE_FONT_SIZE,
167
- }),
180
+ lineGap: BASE_FONT_SIZE
181
+ })
168
182
  });
169
183
  export const HeaderH2 = Styled.h2({
170
184
  margin: 0,
@@ -173,35 +187,59 @@ export const HeaderH2 = Styled.h2({
173
187
  fontWeight: 500,
174
188
  ...textProps({
175
189
  capHeight: BASE_FONT_SIZE * 1.5,
176
- lineGap: 12,
177
- }),
190
+ lineGap: 12
191
+ })
178
192
  });
179
193
  export const HeaderH1 = Styled.h1({
180
194
  letterSpacing: -1,
181
- margin: "2px 0",
195
+ margin: '2px 0',
182
196
  fontWeight: 700,
183
197
  ...textProps({
184
198
  capHeight: BASE_FONT_SIZE * 3 - 4,
185
- lineGap: BASE_FONT_SIZE,
186
- }),
199
+ lineGap: BASE_FONT_SIZE
200
+ })
187
201
  });
188
202
 
203
+ export const MainHeader = function MainHeader({ children }) {
204
+ const content = String(children).split(' ');
205
+
206
+ return createElement(
207
+ Fragment,
208
+ {},
209
+ content.map((word) =>
210
+ createElement(
211
+ HeaderH1,
212
+ {
213
+ key: word,
214
+ style: {
215
+ fontWeight: 900,
216
+ display: 'inline-block',
217
+ width: 'auto',
218
+ padding: '6px',
219
+ margin: 0,
220
+ backgroundColor: 'var(--accent-color)'
221
+ }
222
+ },
223
+ word
224
+ )
225
+ )
226
+ );
227
+ };
228
+
189
229
  export const A = Styled.a({
190
- // color: "#2980b9",
191
- color: "#000",
192
- // backgroundColor: "rgba(32,32,32,0.1)",
193
- boxShadow: "var(--accent-color) 0 2px 0, inset var(--accent-color) 0 -2px 0",
230
+ color: '#000',
231
+ boxShadow: 'var(--accent-color) 0 2px 0, inset var(--accent-color) 0 -2px 0',
194
232
  fontWeight: 700,
195
- textDecoration: "none",
196
- "&:hover": {
197
- color: "#34495e",
198
- },
233
+ textDecoration: 'none',
234
+ '&:hover': {
235
+ color: '#34495e'
236
+ }
199
237
  });
200
238
 
201
239
  export const Space = Styled.div({
202
- display: (props) => (props.inline ? "inline-block" : "block"),
240
+ display: (props) => (props.inline ? 'inline-block' : 'block'),
203
241
  height: (props) => `${SPACE * props.h}px`,
204
- width: (props) => `${SPACE * props.w}px`,
242
+ width: (props) => `${SPACE * props.w}px`
205
243
  });
206
244
 
207
245
  export const Box = Styled.div({
@@ -215,122 +253,184 @@ export const Box = Styled.div({
215
253
  return paddingArr.map((paddingValue) => `${paddingValue * SPACE}px`).join(` `);
216
254
  },
217
255
 
218
- "@media (max-width: 768px)": {
219
- display: ({ hideOnSmall }) => (hideOnSmall ? "none" : undefined),
256
+ '@media (max-width: 768px)': {
257
+ display: ({ hideOnSmall }) => (hideOnSmall ? 'none' : undefined)
220
258
  },
221
259
 
222
- "@media (max-width: 1080px)": {
223
- display: ({ hideOnMedium }) => (hideOnMedium ? "none" : undefined),
224
- },
260
+ '@media (max-width: 1080px)': {
261
+ display: ({ hideOnMedium }) => (hideOnMedium ? 'none' : undefined)
262
+ }
225
263
  });
226
264
 
227
265
  export const Inline = Styled.div({
228
- display: "flex",
229
- flexWrap: "wrap",
266
+ display: 'flex',
267
+ flexWrap: 'wrap',
230
268
  marginLeft: ({ h }) => `${h * SPACE}px`,
231
269
  marginRight: ({ h }) => `${h * SPACE}px`,
232
270
  marginTop: ({ v }) => `${v * SPACE}px`,
233
- marginBottom: ({ v }) => `${v * SPACE}px`,
271
+ marginBottom: ({ v }) => `${v * SPACE}px`
234
272
  });
235
273
 
236
274
  export const LinkButton = Styled.a({
237
275
  capHeight: BASE_FONT_SIZE,
238
- color: "#3498db",
239
- cursor: "pointer",
276
+ color: '#3498db',
277
+ cursor: 'pointer',
240
278
  borderRadius: 5,
241
- borderTop: "1px solid #3498db10",
242
- borderBottom: "1px solid #0000",
243
- backgroundColor: "#3498db20",
279
+ borderTop: '1px solid #3498db10',
280
+ borderBottom: '1px solid #0000',
281
+ backgroundColor: '#3498db20',
244
282
  height: BASE_FONT_SIZE * 2,
245
- display: "flex",
246
- alignItems: "center",
247
- alignContent: "center",
248
- justifyContent: "center",
283
+ display: 'flex',
284
+ alignItems: 'center',
285
+ alignContent: 'center',
286
+ justifyContent: 'center',
249
287
  padding: 0,
250
- "&:hover": {
251
- boxShadow: `rgba(0, 0, 0, 0.1) 0 1px 1px, rgba(0, 0, 0, 0.1) 0 3px 12px`,
252
- },
288
+ '&:hover': {
289
+ boxShadow: `rgba(0, 0, 0, 0.1) 0 1px 1px, rgba(0, 0, 0, 0.1) 0 3px 12px`
290
+ }
253
291
  });
254
292
 
255
293
  export const Dropzone = Styled.div({
256
- height: "120px",
294
+ height: '120px',
257
295
  flex: 1,
258
- "max-width": "320px",
259
- display: "flex",
260
- "text-align": "center",
261
- "align-items": "center",
262
- "align-content": "center",
263
- "justify-content": "center",
264
- "flex-direction": "column",
265
- border: "2px dashed #000",
266
- color: "#000",
267
- padding: "0",
268
- cursor: "pointer",
269
- "& span": {
270
- width: "100%",
271
- cursor: "pointer",
272
- },
273
- "&:hover": {
274
- "border-color": "#999",
296
+ 'max-width': '320px',
297
+ display: 'flex',
298
+ 'text-align': 'center',
299
+ 'align-items': 'center',
300
+ 'align-content': 'center',
301
+ 'justify-content': 'center',
302
+ 'flex-direction': 'column',
303
+ border: '2px dashed #000',
304
+ color: '#000',
305
+ padding: '0',
306
+ cursor: 'pointer',
307
+ '& span': {
308
+ width: '100%',
309
+ cursor: 'pointer'
275
310
  },
276
- "& input": {
277
- position: "absolute",
278
- top: "0",
279
- left: "0",
280
- height: "100%",
281
- width: "100%",
282
- opacity: "0",
283
- cursor: "pointer",
311
+ '&:hover': {
312
+ 'border-color': '#999'
284
313
  },
314
+ '& input': {
315
+ position: 'absolute',
316
+ top: '0',
317
+ left: '0',
318
+ height: '100%',
319
+ width: '100%',
320
+ opacity: '0',
321
+ cursor: 'pointer'
322
+ }
285
323
  });
286
324
 
287
325
  export const Ul = Styled.ul({
288
326
  margin: 0,
289
- padding: `0 0 0 ${BASE_FONT_SIZE / 4}px`,
327
+ padding: `0 0 0 ${BASE_FONT_SIZE / 4}px`
290
328
  });
291
329
 
292
330
  export const Li = Styled.li({
293
331
  margin: `0 0 0 ${SIZE}px`,
294
- padding: `${SIZE / 4}px 0`,
332
+ padding: `${SIZE / 4}px 0`
295
333
  });
296
334
 
297
335
  export const Tabs = Styled.div({});
298
336
 
299
337
  export const Tab = Styled.div({
300
- userSelect: "none",
338
+ userSelect: 'none',
301
339
  padding: SIZE / 2,
302
- cursor: "pointer",
303
- backgroundColor: (props) => (props.active ? "#000" : props.info ? "#fff" : "#ecf0f1"),
304
- color: (props) => (props.active ? "#fff" : "#000"),
305
- paddingLeft: (props) => (props.info ? 0 : undefined),
340
+ cursor: 'pointer',
341
+ backgroundColor: (props) => (props.active ? '#000' : props.info ? '#fff' : '#ecf0f1'),
342
+ color: (props) => (props.active ? '#fff' : '#000'),
343
+ paddingLeft: (props) => (props.info ? 0 : undefined)
306
344
  });
307
345
 
308
346
  export const CodeSnippet = Styled.pre({
309
- borderRadius: SIZE / 2,
310
- "font-family": "monaco, monospace",
311
- border: "none",
312
- width: "100%",
313
- "font-size": SIZE - 2,
314
- "line-height": "1.5",
347
+ borderRadius: BASE_RADIUS,
348
+ 'font-family': 'monaco, monospace',
349
+ border: 'none',
350
+ width: '100%',
351
+ 'font-size': SIZE - 2,
352
+ 'line-height': '1.5',
315
353
  padding: SIZE,
316
- background: "#ecf0f1",
317
- color: "#34495e",
318
- ":focus": {
319
- outline: "none",
320
- },
354
+ background: '#ecf0f1',
355
+ color: '#34495e',
356
+ ':focus': {
357
+ outline: 'none'
358
+ }
359
+ });
360
+
361
+ export const CheckboxHidden = Styled.div(({ checked }) => {
362
+ return {
363
+ height: BASE_SIZE * 2 - 4,
364
+ width: BASE_SIZE * 2 - 4,
365
+ paddingTop: 2,
366
+ paddingLeft: 2,
367
+ backgroundColor: checked ? 'var(--accent-color)' : 'white',
368
+ borderRadius: BASE_RADIUS,
369
+ boxShadow: checked
370
+ ? 'inset rgba(0, 0, 0, 0.07) 0 0 0 1px'
371
+ : 'inset rgba(0, 0, 0, 0.33) 0 0 0 1.5px',
372
+ cursor: 'pointer'
373
+ };
321
374
  });
322
375
 
376
+ export const Checkbox = function Checkbox({ label, checked, onChange }) {
377
+ return createElement(
378
+ Inline,
379
+ {
380
+ onClick: () => {
381
+ if (onChange) {
382
+ onChange(!checked);
383
+ }
384
+ },
385
+ style: {
386
+ alignItems: 'center',
387
+ cursor: 'pointer'
388
+ }
389
+ },
390
+ [
391
+ createElement(
392
+ CheckboxHidden,
393
+ {
394
+ key: 0,
395
+ checked
396
+ },
397
+ createElement(
398
+ 'svg',
399
+ {
400
+ xmlns: 'http://www.w3.org/2000/svg',
401
+ width: '24',
402
+ height: '24',
403
+ fill: 'none',
404
+ stroke: 'currentColor',
405
+ strokeLinecap: 'round',
406
+ strokeLinejoin: 'round',
407
+ strokeWidth: '2',
408
+ className: 'feather feather-check',
409
+ viewBox: '0 0 24 24',
410
+ color: checked ? 'white' : '#ddd'
411
+ },
412
+ createElement('path', {
413
+ d: 'M20 6L9 17 4 12'
414
+ })
415
+ )
416
+ ),
417
+ createElement(Space, { key: 1, w: 0.5 }),
418
+ createElement(Text, { key: 2, style: { userSelect: 'none' } }, label)
419
+ ]
420
+ );
421
+ };
422
+
323
423
  export const Code = Styled.textarea({
324
- "font-family": "monaco, monospace",
325
- border: "none",
326
- width: "100%",
327
- height: "256px",
328
- "font-size": "12px",
329
- "line-height": "1.309",
330
- padding: "16px 18px",
331
- background: "#ecf0f1",
332
- color: "#34495e",
333
- ":focus": {
334
- outline: "none",
335
- },
424
+ 'font-family': 'monaco, monospace',
425
+ border: 'none',
426
+ width: '100%',
427
+ height: '256px',
428
+ 'font-size': '12px',
429
+ 'line-height': '1.309',
430
+ padding: '16px 18px',
431
+ background: '#ecf0f1',
432
+ color: '#34495e',
433
+ ':focus': {
434
+ outline: 'none'
435
+ }
336
436
  });
package/package.json CHANGED
@@ -1,17 +1,8 @@
1
1
  {
2
2
  "name": "jbx",
3
- "version": "1.3.0",
3
+ "version": "1.7.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
- "scripts": {
7
- "test": "echo \"Error: no test specified\" && exit 1"
8
- },
9
- "peerDependencies": {
10
- "capsize": "^1.1.0",
11
- "react": "16.13.1",
12
- "react-dom": "16.13.1",
13
- "styled-components": "^5.2.0"
14
- },
15
- "author": "",
16
- "license": "ISC"
6
+ "author": "hi@javier.xyz",
7
+ "license": "Unlicensed"
17
8
  }