ywana-core8 0.1.44 → 0.1.46

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ywana-core8",
3
- "version": "0.1.44",
3
+ "version": "0.1.46",
4
4
  "description": "ywana-core8",
5
5
  "homepage": "https://ywana.github.io/workspace",
6
6
  "author": "Ernesto Roldan Garcia",
@@ -8,7 +8,7 @@
8
8
 
9
9
  .checkbox .checkmark {
10
10
  width: 1.5rem;
11
- height: 1.4rem;
11
+ height: 1.5rem;
12
12
  display: flex;
13
13
  align-items: center;
14
14
  justify-content: center;
@@ -18,6 +18,10 @@
18
18
  padding-bottom: .1rem;
19
19
  }
20
20
 
21
+ .checkbox.readonly>.checkmark {
22
+ border: solid 1px var(--text-color-light);
23
+ }
24
+
21
25
  .checkbox .checkmark:after {
22
26
  content: "";
23
27
  width: 0.3rem;
@@ -31,7 +35,12 @@
31
35
  z-index: 0;
32
36
  }
33
37
 
34
- .checkbox > input {
38
+ .checkbox.readonly .checkmark:after {
39
+ border-color: var(--text-color-lighter);
40
+ }
41
+
42
+
43
+ .checkbox>input {
35
44
  position: absolute;
36
45
  flex: 1;
37
46
  width: 2rem;
@@ -40,16 +49,16 @@
40
49
  z-index: 1;
41
50
  }
42
51
 
43
- input:checked ~ .checkmark:after {
44
- display: block;
45
- }
52
+ input:checked~.checkmark:after {
53
+ display: block;
54
+ }
46
55
 
47
- .checkbox > label {
48
- color: var(--text-color-light);
56
+ .checkbox>label {
57
+ color: var(--text-color);
49
58
  font-size: 1rem;
50
59
  font-weight: normal;
51
60
  }
52
61
 
53
- .checkbox .icon {
54
- position: absolute;
62
+ .checkbox.readonly>label {
63
+ color: var(--text-color-light);
55
64
  }
@@ -1,6 +1,5 @@
1
- import React from 'react'
1
+ import React, { useEffect } from 'react'
2
2
  import { Text } from './text'
3
- import { Icon } from './icon'
4
3
  import './checkbox.css'
5
4
 
6
5
  /**
@@ -8,58 +7,51 @@ import './checkbox.css'
8
7
  */
9
8
  export const CheckBox = (props) => {
10
9
 
11
- const { id, label, placeholder, value, readOnly=false, onChange } = props
10
+ const { id, label, value = false, readOnly = false, onChange } = props
11
+
12
+ const [checked, setChecked] = React.useState(value)
13
+
14
+ useEffect(() => {
15
+ setChecked(value)
16
+ }, [value])
12
17
 
13
18
  function change(event) {
14
19
  event.stopPropagation()
15
- event.preventDefault()
16
- const value = event.target.checked
17
- if (onChange) onChange(id, value)
20
+ const nextValue = event.target.checked
21
+ setChecked(nextValue)
22
+ if (onChange) onChange(id, nextValue)
18
23
  }
19
24
 
20
- const labelTxt = <Text>{label}</Text>
21
- const placeholderTxt = <Text>{placeholder}</Text>
25
+ const labelTxt = label && <Text>{label}</Text>
22
26
 
23
-
24
- if (readOnly===true) {
25
- return value === true ? (
26
- <div className="checkbox" key={`${id}1`}>
27
- <Icon id={id} icon="check" size="small" />
28
- <span className="checkmark" />
29
- <label htmlFor={id}>{labelTxt}</label>
30
- </div>
31
- ) : (
32
- <div className="checkbox" key={`${id}0`}>
33
- <span className="checkmark" />
34
- <label htmlFor={id}>{labelTxt}</label>
35
- </div>
36
- )
37
- }
38
-
39
- return value === true ? (
40
- <div className="checkbox" key={`${id}1`}>
41
- <input id={id} type="checkbox" placeholder={placeholderTxt} checked value={value} onChange={change} readOnly />
42
- <span className="checkmark" />
43
- <label htmlFor={id}>{labelTxt}</label>
44
- </div>
45
- ) : (
46
- <div className="checkbox" key={`${id}0`}>
47
- <input id={id} type="checkbox" placeholder={placeholderTxt} value={value} onChange={change} readOnly />
27
+ return (
28
+ <div className={`checkbox ${readOnly ? "readonly" : ""}`} key={`${id}1`}>
29
+ <input id={id} key={`${id}_${checked}`} type="checkbox" checked={checked} onChange={change} disabled={readOnly} />
48
30
  <span className="checkmark" />
49
31
  <label htmlFor={id}>{labelTxt}</label>
50
32
  </div>
51
33
  )
52
34
  }
53
35
 
54
-
55
36
  const CheckBoxTest = (props) => {
56
37
 
38
+ const [checked, setChecked] = React.useState({
39
+ check1: true,
40
+ check2: false,
41
+ check3: true,
42
+ check4: false
43
+ })
44
+
45
+ function change(id, value) {
46
+ setChecked({ ...checked, [id]: value })
47
+ }
48
+
57
49
  return (
58
50
  <div>
59
- <CheckBox id="check1" label="Check 1" placeholder="Check 1" value={true} />
60
- <CheckBox id="check2" label="Check 2" placeholder="Check 2" value={false} />
61
- <CheckBox id="check3" label="Check 3" placeholder="Check 3" value={true} readOnly />
62
- <CheckBox id="check4" label="Check 4" placeholder="Check 4" value={false} readOnly />
51
+ <CheckBox id="check1" label="Check 1" value={checked.check1} onChange={change} />
52
+ <CheckBox id="check2" label="Check 2" value={checked.check2} onChange={change} />
53
+ <CheckBox id="check3" label="Check 3" value={checked.check3} onChange={change} readOnly/>
54
+ <CheckBox id="check4" label="Check 4" value={checked.check4} onChange={change} readOnly/>
63
55
  </div>
64
56
  )
65
57
  }
@@ -46,6 +46,10 @@
46
46
  color: rgba(150,150,150,1);
47
47
  }
48
48
 
49
+ .textfield-outlined.no-label > .icon {
50
+ top: .5rem;
51
+ }
52
+
49
53
  .textfield-date>.icon,
50
54
  .textfield-DATE>.icon {
51
55
  right: 2.5rem;
@@ -7,7 +7,7 @@ import { UPLOAD_STATES } from './UploadStates'
7
7
  const UploadAreaTest = (props) => {
8
8
  return (
9
9
  <div style={{ padding: "1rem" }}>
10
- <UploadArea icon="cloud_upload" label="UploadArea Test" />
10
+ <UploadArea icon="cloud_upload" label="UploadArea Test" disabled={true} />
11
11
  </div>
12
12
  )
13
13
  }
@@ -0,0 +1,6 @@
1
+ .upload-area6.disabled {
2
+ background-color: #f5f5f5;
3
+ border-color: #e0e0e0;
4
+ color: #9e9e9e;
5
+ cursor: not-allowed;
6
+ }
@@ -1,12 +1,12 @@
1
1
  import React, { useState, useEffect, useRef } from 'react'
2
2
  import { Icon } from '../../html'
3
-
3
+ import './UploadArea.css'
4
4
  /**
5
5
  * Upload Area
6
6
  */
7
7
  export const UploadArea = (props) => {
8
8
 
9
- const { icon, label = 'Add file or drop file here...' } = props
9
+ const { icon, label = 'Add file or drop file here...', disabled= false } = props
10
10
  const areaElement = useRef()
11
11
  const [drag, setDrag] = useState(false)
12
12
  const { resumable } = props
@@ -18,22 +18,25 @@ export const UploadArea = (props) => {
18
18
  }, [])
19
19
 
20
20
  const onDragOver = () => {
21
+ if (disabled) return
21
22
  setDrag(true)
22
23
  }
23
24
 
24
25
  const onDragLeave = () => {
26
+ if (disabled) return
25
27
  setDrag(false)
26
28
  }
27
29
 
28
30
  const dragging = drag === true ? 'drag-over' : ''
31
+ const disabledStyle = disabled === true ? 'disabled' : ''
29
32
 
30
33
  return (
31
- <div className={`upload-area6 ${dragging}`}
34
+ <div className={`upload-area6 ${dragging} ${disabledStyle}`}
32
35
  onDragOver={onDragOver}
33
36
  onDragLeave={onDragLeave}
34
37
  ref={areaElement}
35
38
  >
36
- <UploadIcon resumable={resumable}/>
39
+ <UploadIcon icon={icon} resumable={resumable} disabled={disabled}/>
37
40
  <label>{label}</label>
38
41
  </div>
39
42
  )
@@ -42,7 +45,7 @@ export const UploadArea = (props) => {
42
45
  /**
43
46
  * Upload Icon
44
47
  */
45
- export const UploadIcon = ({ icon = "folder_open", resumable }) => {
48
+ export const UploadIcon = ({ icon = "folder_open", resumable, disabled=false }) => {
46
49
 
47
50
  const iconElement = useRef()
48
51
 
@@ -54,7 +57,7 @@ export const UploadIcon = ({ icon = "folder_open", resumable }) => {
54
57
 
55
58
  return (
56
59
  <div className="upload-icon" ref={iconElement}>
57
- <Icon icon={icon} clickable/>
60
+ <Icon icon={icon} clickable disabled={disabled}/>
58
61
  </div>
59
62
  )
60
63
  }
@@ -6,7 +6,7 @@ import { SiteContext, Dialog } from '../../site';
6
6
  /**
7
7
  * Upload Dialog
8
8
  */
9
- export const UploadDialog = ({ label, target, accept, onSuccess, onComplete, onClose, children, className, disabled, onCanClose, overlayCanClose = true }) => {
9
+ export const UploadDialog = ({ label, target, accept, onSuccess, onComplete, onClose, children, className, disabled=false, onCanClose, overlayCanClose = true }) => {
10
10
 
11
11
  const site = useContext(SiteContext);
12
12
 
@@ -38,7 +38,7 @@ export const UploadDialog = ({ label, target, accept, onSuccess, onComplete, onC
38
38
  const title = <Text use="headline6">{label}</Text>
39
39
  return (
40
40
  <Dialog title={title} open={true} onAction={onAction} actions={actions} className={className} overlayCanClose={overlayCanClose}>
41
- { disabled ? "" : <Uploader label={label} accept={accept} target={target} onSuccess={success} onComplete={complete} /> }
41
+ <Uploader label={label} accept={accept} target={target} onSuccess={success} onComplete={complete} disabled={disabled} />
42
42
  {children}
43
43
  </Dialog>
44
44
  )
@@ -9,7 +9,7 @@ import './Uploader.css'
9
9
  /**
10
10
  * Uploader
11
11
  */
12
- export const Uploader = ({ icon, label, view="area", target, accept, simultaneousUploads = 1, className, onProgress, onSuccess, onError, onComplete }) => {
12
+ export const Uploader = ({ icon, label, view="area", target, accept, simultaneousUploads = 1, className, onProgress, onSuccess, onError, onComplete, disabled = false }) => {
13
13
 
14
14
  const resumable = useMemo(() => {
15
15
  const config = {
@@ -65,9 +65,9 @@ export const Uploader = ({ icon, label, view="area", target, accept, simultaneou
65
65
 
66
66
  function renderView() {
67
67
  switch (view) {
68
- case "area": return <UploadArea resumable={resumable} icon={icon} label={label} />
69
- case "icon": return <UploadIcon resumable={resumable} icon={icon} />
70
- default: return <UploadArea resumable={resumable} icon={icon} label={label} />
68
+ case "area": return <UploadArea resumable={resumable} icon={icon} label={label} disabled={disabled} />
69
+ case "icon": return <UploadIcon resumable={resumable} icon={icon} disabled={disabled} />
70
+ default: return <UploadArea resumable={resumable} icon={icon} label={label} disabled={disabled} />
71
71
  }
72
72
  }
73
73