ywana-core8 0.0.906 → 0.0.907

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.906",
3
+ "version": "0.0.907",
4
4
  "description": "ywana-core8",
5
5
  "homepage": "https://ywana.github.io/workspace",
6
6
  "author": "Ernesto Roldan Garcia",
package/src/site/site.css CHANGED
@@ -162,14 +162,13 @@
162
162
  z-index: 10;
163
163
  width: 100vw;
164
164
  height: 100vh;
165
- background-color: rgba(0, 0, 0, 0.32);
165
+ background-color: var(--site-preview-background, rgba(0, 0, 0, 0.32));
166
166
  display: flex;
167
167
  flex-direction: column;
168
168
  align-items: center;
169
169
  justify-content: center;
170
170
  }
171
171
 
172
-
173
172
  .site-error-fallback {
174
173
  display: flex;
175
174
  flex-direction: column;
@@ -1,12 +1,79 @@
1
1
  .kanban {
2
- display: flex;
3
- min-height: 30rem;
4
2
  background-color: var(--background-color);
5
3
  overflow-x: auto;
6
4
  max-height: 90vh;
7
5
  border-top: solid 1px var(--divider-color);
8
6
  border-left: solid 1px var(--divider-color);
9
7
  border-bottom: solid 1px var(--divider-color);
8
+ display: flex;
9
+
10
+ &.with-swimlanes {
11
+ flex-wrap: wrap;
12
+ }
13
+ }
14
+
15
+ .kanban-header {
16
+ flex: 1;
17
+ height: 5rem;
18
+ display: flex;
19
+ align-items: center;
20
+
21
+ position: sticky;
22
+ top: 0;
23
+ background-color: var(--paper-color);
24
+ z-index: 10;
25
+ }
26
+
27
+ .kanban-swimlane {
28
+ flex: 1;
29
+ display: flex;
30
+ flex-direction: column;
31
+ background-color: var(--background-color);
32
+ border-bottom: solid 1px var(--divider-color);
33
+
34
+ &>header {
35
+ display: flex;
36
+ align-items: center;
37
+ justify-content: flex-start;
38
+ padding: 0 .5rem;
39
+ border-right: solid 1px var(--divider-color);
40
+ border-left: solid 1px var(--divider-color);
41
+
42
+ position: sticky;
43
+ top: 5rem;
44
+ z-index: 9;
45
+ background-color: var(--paper-color);
46
+
47
+ &>.title {
48
+ flex: 1;
49
+ padding: 0 1rem;
50
+ display: flex;
51
+
52
+ &>.secondary-text {
53
+ padding-left: .5rem;
54
+ color: rgba(100, 100, 100, .8);
55
+ }
56
+ }
57
+ }
58
+
59
+ &>main {
60
+ flex: 1;
61
+ display: flex;
62
+ overflow: auto;
63
+ transition: all .5s ease-in-out;
64
+ border-top: solid 1px var(--divider-color);
65
+
66
+ &.fold {
67
+ max-height: 0;
68
+ overflow: hidden;
69
+ }
70
+
71
+ &.unfold {
72
+ max-height: fit-content;
73
+ overflow: auto;
74
+ }
75
+ }
76
+
10
77
  }
11
78
 
12
79
  .kanban-column {
@@ -23,7 +90,7 @@
23
90
  }
24
91
 
25
92
  .kanban-column.dragOver {
26
- background-color: rgba(100,100,100,.1);
93
+ background-color: rgba(100, 100, 100, .1);
27
94
  }
28
95
 
29
96
  .kanban-column.min {
@@ -37,6 +104,7 @@
37
104
  display: flex;
38
105
  align-items: flex-start;
39
106
  padding: 1rem;
107
+ background-color: var(--paper-color);
40
108
  }
41
109
 
42
110
  .kanban-column>header>.title {
@@ -46,7 +114,8 @@
46
114
  flex-direction: column;
47
115
  }
48
116
 
49
- .kanban-column>header>i, .kanban-column>footer>button {
117
+ .kanban-column>header>i,
118
+ .kanban-column>footer>button {
50
119
  color: rgba(100, 100, 100, .6);
51
120
  }
52
121
 
@@ -1,22 +1,104 @@
1
- import React, { useState } from 'react'
2
- import { Icon, MenuIcon, Text } from '../../html'
1
+ import React, { useMemo, useState } from 'react'
2
+ import { Icon, Text } from '../../html'
3
3
  import './Kanban.css'
4
4
 
5
5
  /**
6
6
  * Kanban
7
7
  */
8
8
  export const Kanban = ({ children }) => {
9
+
10
+ const hasSwimlanes = useMemo(() => {
11
+ const found = React.Children.map(children, child => {
12
+ if (child.type.name === KanbanSwimlane.name) {
13
+ return child
14
+ }
15
+ })
16
+ return found.length > 0
17
+ })
18
+
19
+ const style = hasSwimlanes ? "with-swimlanes" : ""
9
20
  return (
10
- <div className="kanban">
21
+ <div className="kanban with-swimlanes">
11
22
  {children}
12
23
  </div>
13
24
  )
14
25
  }
15
26
 
27
+
28
+
29
+ export const KanbanHeader = (props) => {
30
+
31
+ const { columns } = props
32
+
33
+ return (
34
+ <div className="kanban-header">
35
+ {columns.map((column, index) => {
36
+ const { icon, title, subtitle, badge } = column
37
+ return (
38
+ <div className="kanban-column" key={index}>
39
+ <header>
40
+ <Icon icon={icon} />
41
+ <div className="title">
42
+ <Text use="headline6">{title}</Text>
43
+ <Text className="secondary-text" use="body2">{subtitle}</Text>
44
+ </div>
45
+ <div className="badge" >{badge}</div>
46
+ </header>
47
+ </div>
48
+ )
49
+ })}
50
+ </div>
51
+ )
52
+ }
53
+
54
+ export const KanbanSwimlane = ({ icon, title, subtitle, badge, children }) => {
55
+
56
+ const [unfold, setUnfold] = useState(true)
57
+
58
+ // cahnge all children headless prop to true
59
+ // if there is only one child
60
+ if (children.length === 1) {
61
+ children = React.cloneElement(children, { headless: true })
62
+ } else {
63
+ children = React.Children.map(children, child => {
64
+ return React.cloneElement(child, { headless: true })
65
+ })
66
+ }
67
+
68
+ // log al children headless prop
69
+ children.forEach(child => {
70
+ console.log(child.props.headless)
71
+ })
72
+
73
+ function toggle() {
74
+ setUnfold(!unfold)
75
+ }
76
+
77
+ const toggleIcon = unfold ? "unfold_less" : "unfold_more"
78
+ const toggleStyle = unfold ? "unfold" : "fold"
79
+
80
+ return (
81
+ <div className="kanban-swimlane">
82
+ <header>
83
+ <Icon icon={icon} size="small" />
84
+ <div className="title">
85
+ <Text use="headline6">{title}:</Text>
86
+ <Text className="secondary-text" use="body2">{subtitle}</Text>
87
+ </div>
88
+ <div className="badge" >{badge}</div>
89
+ <Icon icon={toggleIcon} clickable action={toggle} />
90
+ </header>
91
+ <main className={toggleStyle}>
92
+ {children}
93
+ </main>
94
+ </div>
95
+ )
96
+ }
97
+
16
98
  /**
17
99
  * Kanban Column
18
100
  */
19
- export const KanbanColumn = ({ id, actions, icon, title, subtitle, badge, children, minified = false, disabled = false }) => {
101
+ export const KanbanColumn = ({ id, actions, headless = false, icon, title, subtitle, badge, children, minified = false, disabled = false }) => {
20
102
 
21
103
  const [min, setMin] = useState(minified)
22
104
 
@@ -35,14 +117,16 @@ export const KanbanColumn = ({ id, actions, icon, title, subtitle, badge, childr
35
117
  </div>
36
118
  ) : (
37
119
  <div className={`kanban-column ${id} ${disabled ? 'disabled' : ''}`}>
38
- <header>
39
- <Icon icon={icon} />
40
- <div className="title">
41
- <Text use="headline6">{title}</Text>
42
- <Text className="secondary-text" use="body2">{subtitle}</Text>
43
- </div>
44
- <div className="badge" >{badge}</div>
45
- </header>
120
+ {headless ? "" : (
121
+ <header>
122
+ <Icon icon={icon} />
123
+ <div className="title">
124
+ <Text use="headline6">{title}</Text>
125
+ <Text className="secondary-text" use="body2">{subtitle}</Text>
126
+ </div>
127
+ <div className="badge" >{badge}</div>
128
+ </header>
129
+ )}
46
130
  <main>
47
131
  {children}
48
132
  </main>
@@ -50,7 +134,7 @@ export const KanbanColumn = ({ id, actions, icon, title, subtitle, badge, childr
50
134
  <Icon icon="toggle_off" onIcon="toggle_on" clickable action={toggle} />
51
135
  {actions}
52
136
  </footer>
53
- </div>
137
+ </div >
54
138
  )
55
139
  }
56
140
 
@@ -1,5 +1,5 @@
1
1
  import React from 'react'
2
- import { Kanban, KanbanCard, KanbanColumn } from './Kanban'
2
+ import { Kanban, KanbanCard, KanbanColumn, KanbanHeader, KanbanSwimlane } from './Kanban'
3
3
  import { Button } from '../../html'
4
4
 
5
5
  const KanbanTest = (prop) => {
@@ -17,4 +17,62 @@ const KanbanTest = (prop) => {
17
17
  </KanbanColumn>
18
18
  </Kanban>
19
19
  )
20
+ }
21
+
22
+ const KanbanTest2 = (prop) => {
23
+ return (
24
+ <Kanban>
25
+ <KanbanHeader columns={[
26
+ { icon: "inbox", title: "TODO", badge: "1" },
27
+ { icon: "inbox", title: "IN PROGRESS", badge: "0" },
28
+ { icon: "inbox", title: "IN PROGRESS", badge: "0" },
29
+ { icon: "inbox", title: "IN PROGRESS", badge: "0" },
30
+ { icon: "inbox", title: "DONE", badge: "2" }
31
+ ]} />
32
+
33
+ <KanbanSwimlane icon="people" title="Users" subtitle="Application users" badge={100} headless={false} >
34
+ <KanbanColumn badge="1">
35
+ <KanbanCard />
36
+ </KanbanColumn>
37
+ <KanbanColumn badge="0">
38
+ <KanbanCard />
39
+ <KanbanCard />
40
+ </KanbanColumn>
41
+ <KanbanColumn badge="0">
42
+ <KanbanCard />
43
+ <KanbanCard />
44
+ </KanbanColumn>
45
+ <KanbanColumn badge="0">
46
+ <KanbanCard />
47
+ <KanbanCard />
48
+ </KanbanColumn>
49
+ <KanbanColumn badge="2" actions={<Button label="Archive" raised />}>
50
+ <KanbanCard />
51
+ <KanbanCard />
52
+ </KanbanColumn>
53
+ </KanbanSwimlane>
54
+ <KanbanSwimlane icon="email" title="Messages" subtitle="All Messages">
55
+ <KanbanColumn badge="1">
56
+ <KanbanCard />
57
+ </KanbanColumn>
58
+ <KanbanColumn badge="0">
59
+ <KanbanCard />
60
+ <KanbanCard />
61
+ <KanbanCard />
62
+ </KanbanColumn>
63
+ <KanbanColumn badge="0">
64
+ <KanbanCard />
65
+ <KanbanCard />
66
+ </KanbanColumn>
67
+ <KanbanColumn badge="0">
68
+ <KanbanCard />
69
+ <KanbanCard />
70
+ </KanbanColumn>
71
+ <KanbanColumn badge="2" actions={<Button label="Archive" raised />}>
72
+ <KanbanCard />
73
+ <KanbanCard />
74
+ </KanbanColumn>
75
+ </KanbanSwimlane>
76
+ </Kanban>
77
+ )
20
78
  }