ywana-core8 0.0.652 → 0.0.654

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.0.652",
3
+ "version": "0.0.654",
4
4
  "description": "ywana-core8",
5
5
  "homepage": "https://ywana.github.io/workspace",
6
6
  "author": "Ernesto Roldan Garcia",
@@ -6,7 +6,7 @@ import './button.css'
6
6
  /**
7
7
  * HTML Button
8
8
  */
9
- export const Button = ({ label, icon, action, disabled = false, outlined, raised }) => {
9
+ export const Button = ({ label, icon, action, disabled = false, outlined, raised, className }) => {
10
10
 
11
11
  function click(event) {
12
12
  if (!disabled) {
@@ -19,7 +19,7 @@ export const Button = ({ label, icon, action, disabled = false, outlined, raised
19
19
  let style = raised ? 'raised' : outlined ? 'outlined' : 'normal'
20
20
  if (disabled) style = `${style} disabled`
21
21
  return (
22
- <button className={`btn ${style}`} onClick={click}>
22
+ <button className={`btn ${style} ${className}`} onClick={click}>
23
23
  { icon ? <Icon icon={icon} size="small" clickable action={click} /> : null }
24
24
  <Text>{ label }</Text>
25
25
  </button>
@@ -0,0 +1 @@
1
+ export {Wizard } from './wizard'
@@ -0,0 +1,30 @@
1
+ .wizard {
2
+ border: solid 1px red;
3
+ }
4
+
5
+ .wizard-steps {
6
+ display: flex;
7
+ border-bottom: solid 1px var(--divider-color);
8
+ }
9
+
10
+ .wizard-step {
11
+ flex: 1;
12
+ padding: 0 .5rem;
13
+ display: flex;
14
+ align-items: center;
15
+ }
16
+
17
+ .wizard-step:not(:last-child) {
18
+ border-right: solid 1px var(--divider-color);
19
+ }
20
+
21
+ .wizard-content {
22
+ min-height: 10rem;
23
+ }
24
+
25
+ .wizard-actions {
26
+ border-top: solid 1px var(--divider-color);
27
+ display: flex;
28
+ justify-content: space-between;
29
+ padding: .5rem;
30
+ }
@@ -0,0 +1,57 @@
1
+ import React, { useState } from 'react'
2
+ import { Icon } from '../html'
3
+ import { Button } from '../html/button'
4
+ import './wizard.css'
5
+
6
+ export const Wizard = (props) => {
7
+
8
+ const { steps = [], init = 0, onClose } = props
9
+ const [current=0, setCurrent] = useState(init)
10
+
11
+ function prev() {
12
+ if (current > 0) setCurrent(current - 1)
13
+ }
14
+
15
+ function next() {
16
+ const step = steps[current]
17
+ if (step.onComplete) {
18
+ step.onComplete(() => { setCurrent(current + 1) })
19
+ } else {
20
+ setCurrent(current + 1)
21
+ }
22
+ }
23
+
24
+ function finish() {
25
+ const step = steps[current]
26
+ if (step.onComplete) step.onComplete(() => {
27
+ if (onClose) onClose()
28
+ })
29
+ }
30
+
31
+ return (
32
+ <div className="wizard">
33
+ <div className="wizard-steps">
34
+ {steps.map((step, index) => {
35
+ const active = index === current
36
+ const done = index < current
37
+ return (
38
+ <div key={index} className="wizard-step">
39
+ <div className="wizard-step-icon">
40
+ {done && <Icon icon="check" />}
41
+ {active && <Icon icon="play_arrow" />}
42
+ </div>
43
+ <div className="wizard-step-label">{step.label}</div>
44
+ </div>
45
+ )
46
+ })}
47
+ </div>
48
+ <div className="wizard-content">
49
+ {steps[current].content}
50
+ </div>
51
+ <div className="wizard-actions">
52
+ <Button label="Anterior" disabled={current === 0} action={prev} />
53
+ { current < steps.length -1 ? <Button label="Siguiente" disabled={current === steps.length - 1} action={next} /> : <Button label="Finalizar" action={finish} raised /> }
54
+ </div>
55
+ </div>
56
+ )
57
+ }
@@ -0,0 +1,16 @@
1
+ import React, { useState } from 'react'
2
+ import { Wizard } from './wizard'
3
+
4
+ const WizardTest = (prop) => {
5
+
6
+ return (
7
+ <>sa
8
+ <Wizard steps={[
9
+ { label: "Paso 1", content: <div>Contenido 1</div>, onComplete: (onSuccess, onError) => { console.log("complete 1"); onSuccess() } },
10
+ { label: "Paso 2", content: <div>Contenido 2</div>, onComplete: (onSuccess, onError) => { console.log("complete 2"); onSuccess() } },
11
+ { label: "Paso 3", content: <div>Contenido 3</div>, onComplete: (onSuccess, onError) => { console.log("complete 3"); onSuccess() } },
12
+ { label: "Paso 4", content: <div>Contenido 4</div>, onComplete: (onSuccess, onError) => { console.log("complete 4"); onSuccess() } },
13
+ ]} init={0} />
14
+ </>
15
+ )
16
+ }
package/src/index.js CHANGED
@@ -7,4 +7,7 @@ export * from './widgets'
7
7
  export * from './site'
8
8
  export * from './domain'
9
9
 
10
+
11
+ export * from './incubator'
12
+
10
13
  export const isFunction = value => value && (Object.prototype.toString.call(value) === "[object Function]" || "function" === typeof value || value instanceof Function);