ywana-core8 0.0.887 → 0.0.888

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.887",
3
+ "version": "0.0.888",
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
@@ -78,6 +78,14 @@
78
78
  align-items: center;
79
79
  }
80
80
 
81
+ .site6>menu.min .site-menu-item {
82
+ justify-content: center;
83
+ }
84
+
85
+ .site6>menu.min .site-menu-item i {
86
+ width: 4.2rem !important;
87
+ }
88
+
81
89
  .site6>menu.max>main>.site-menu-item:not(.selected):hover {
82
90
  color: var(--text-color);
83
91
  background-color: rgba(200,200,200,.2);
package/src/site/site.js CHANGED
@@ -228,7 +228,7 @@ const SiteMenu = ({ iconSrc, title, children, min }) => {
228
228
  const titleTxt = context.translate(title)
229
229
  return (
230
230
  <div className={`site-menu-item ${styleItem}`} key={id} onClick={() => goto(id)}>
231
- <Tooltip text={title} top=".5rem" left="2rem">
231
+ <Tooltip text={title} top=".5rem" left="4.5rem">
232
232
  <Icon key={id} icon={icon} clickable action={() => goto(id)} />
233
233
  </Tooltip>
234
234
  {sideNav === 'max' ? <label>{titleTxt}</label> : null}
@@ -2,31 +2,30 @@
2
2
  width: 100%;
3
3
  height: 100%;
4
4
  display: grid;
5
- grid-template-areas:
6
- "header header"
7
- "main aside";
8
- grid-template-columns: 1fr auto;
5
+ grid-template-areas:
6
+ "menu nav"
7
+ "menu main";
8
+ grid-template-columns: auto 1fr;
9
9
  grid-template-rows: auto 1fr;
10
10
  padding: 2px;
11
11
  }
12
12
 
13
- .file-explorer>header {
14
- grid-area: header;
15
- }
16
-
17
13
  .file-explorer>nav {
18
14
  grid-area: nav;
15
+ display: flex;
19
16
  }
20
17
 
21
18
  .file-explorer>menu {
22
19
  grid-area: menu;
23
20
  padding: 0;
21
+ margin: 0;
22
+ width: 20rem;
23
+ background-color: var(--background-color);
24
24
  }
25
25
 
26
26
  .file-explorer>main {
27
27
  grid-area: main;
28
- border-left: solid 1px var(--divider-color);
29
- display: flex;
28
+ display: flex-wrap;
30
29
  flex-direction: column;
31
30
  overflow: hidden;
32
31
  }
@@ -39,7 +38,34 @@
39
38
  grid-area: footer;
40
39
  }
41
40
 
42
- .file-view {
41
+ .file-searchbox {
42
+ height: 3rem;
43
+ display: flex;
44
+ align-items: center;
45
+ justify-content: center;
46
+ padding: 0 1rem;
47
+ }
48
+
49
+ .folder-header {
50
+ flex: 1;
51
+ display: flex;
52
+ height: 3rem;
53
+ align-items: center;
54
+ padding: 0 1rem;
55
+ }
56
+
57
+ .folder-title {
58
+ font-size: 1.1rem;
59
+ font-weight: 500;
60
+ }
61
+
62
+ .folder-actions {
63
+ display: flex;
64
+ gap: .5rem;
65
+ color: var(--text-color-lighter);
66
+ }
67
+
68
+ .files-grid {
43
69
  flex: 1;
44
70
  overflow: auto;
45
71
  display: flex;
@@ -47,66 +73,51 @@
47
73
  gap: .5rem;
48
74
  }
49
75
 
50
- .file-icon {
76
+ .file-item {
51
77
  margin: .5rem;
52
- border: solid 1px var(--divider-color);
53
78
  width: 8rem;
54
- min-height: 10rem;
79
+ height: 10rem;
55
80
  position: relative;
56
81
  display: flex;
57
82
  flex-direction: column;
58
83
  }
59
84
 
60
- .file-icon--selected {
61
- background-color: var(--divider-color) !important;
85
+ .file-item--selected {
62
86
  box-shadow: var(--shadow1);
63
87
  }
64
88
 
65
- .file-icon:hover {
89
+ .file-item:hover {
66
90
  cursor: pointer;
67
- box-shadow: var(--shadow1);
68
- }
69
-
70
- .file-icon>header {
71
- position: absolute;
72
- top: 0px;
73
- left: 0px;
74
- width: 100%;
75
- height: 2rem;
76
- display: flex;
77
- justify-content: space-between;
78
- color: var(--text-color-lighter);
91
+ border: dotted 1px var(--divider-color);
79
92
  }
80
93
 
81
- .file-icon>picture {
94
+ .file-item>picture {
95
+ height: 7rem;
82
96
  flex: 1;
83
97
  padding: 0 1rem;
84
98
  }
85
99
 
86
- .file-icon>picture>img {
100
+ .file-item>picture>img {
87
101
  width: 100%;
88
102
  height: 100%;
89
103
  object-fit: contain;
90
104
  }
91
105
 
92
- .file-icon>main {
93
- height: 2rem;
106
+ .file-item>main {
107
+ height: 3rem;
94
108
  overflow: hidden;
95
109
  display: flex;
96
110
  flex-direction: column;
97
111
  align-items: center;
98
112
  }
99
113
 
100
- .file-icon>main>label {
101
- font-size: .8rem;
114
+ .file-item-title {
115
+ font-size: 1rem;
102
116
  color: var(--text-color);
117
+ font-weight: 500;
103
118
  }
104
119
 
105
- .file-icon>footer {
106
- width: 100%;
107
- flex: 1;
108
- overflow: hidden;
109
- border-top: solid 1px var(--divider-color);
110
- display: flex;
111
- align-items: center;
120
+ .file-item-subtitle {
121
+ font-size: .8rem;
122
+ color: var(--text-color-lighter);
112
123
  }
@@ -1,26 +1,112 @@
1
- import React, {useState} from 'react'
2
- import { Icon } from '../../html'
1
+ import React, { useState } from 'react'
2
+ import { TextField, Tree, TreeItem, Icon, DataTable } from '../../html'
3
3
  import './Explorer.css'
4
4
 
5
5
  /**
6
6
  * File Explorer
7
7
  */
8
- export const FileExplorer = (props) => {
9
-
10
- const { title, files = [] } = props
8
+ const FileExplorer = (props) => {
9
+
10
+ const [selectedFolder, setSelectedFolder] = useState("10002")
11
+ const [selectedFile, setSelectedFile] = useState()
12
+ const [search, setSearch] = useState()
11
13
 
14
+ function selectFolder(id) {
15
+ setSelectedFolder(id)
16
+ }
17
+
18
+ function selectFile(id) {
19
+ setSelectedFile(id)
20
+ }
21
+
22
+ function searchChanged(value) {
23
+ setSearch(value)
24
+ }
25
+
26
+ const filteredFiles = search ? files.filter(file => file.title.toLowerCase().includes(search.toLowerCase())) : files
27
+ const selectedFiles = filteredFiles.filter(file => file.folder === selectedFolder)
28
+
29
+ return (
30
+ <div style={{ padding: "1rem", flex: "1", height: "100%" }}>
31
+ <FileExplorerView
32
+ title="File Explorer Test"
33
+ folders={folders} selectedFolder={selectedFolder} onSelectFolder={selectFolder} 
34
+ files={selectedFiles} selectedFile={selectedFile} onSelectFile={selectFile}
35
+ search={search} onSearch={searchChanged}
36
+ />
37
+ </div>
38
+ )
39
+ }
40
+
41
+ /**
42
+ * File Explorer View
43
+ */
44
+ export const FileExplorerView = (props) => {
45
+
46
+ const { folders = [], selectedFolder, onSelectFolder, files = [], selectedFile, onSelectFile, search, onSearch } = props
47
+
48
+ const [view, setView] = useState('list')
49
+
50
+ const folder = folders.find(folder => folder.id === selectedFolder)
51
+ const folderTitle = folder ? folder.title : ''
52
+
53
+ function switchView() {
54
+ setView(view === 'grid' ? 'list' : 'grid')
55
+ }
56
+
57
+
12
58
  return (
13
59
  <div className="file-explorer">
14
- <header>
15
- {title}
16
- <nav>
17
- <Icon icon="info" />
18
- </nav>
19
- </header>
60
+ <nav>
61
+ <header className='folder-header'>
62
+ <div className="folder-title">{folderTitle}</div>
63
+ </header>
64
+ <div className="folder-actions">
65
+ <Icon icon='list' clickable action={switchView} checked={view==="list"} />
66
+ <Icon icon='grid_view' clickable action={switchView} checked={view==="grid"} />
67
+ </div>
68
+ <FilesSearchBox search={search} onSearch={onSearch} />
69
+ </nav>
70
+ <menu>
71
+ <FoldersTreeView folders={folders} selected={selectedFolder} onSelect={onSelectFolder} />
72
+ </menu>
20
73
  <main>
21
- <FilesGrid files={files} />
74
+ {view === 'grid' ? <FilesGridView files={files} selected={selectedFile} onSelect={onSelectFile} /> : null}
75
+ {view === 'list' ? <FilesTableView files={files} selected={selectedFile} onSelect={onSelectFile} /> : null}
22
76
  </main>
23
- <aside></aside>
77
+ </div>
78
+ )
79
+ }
80
+
81
+ export const FoldersTreeView = (props) => {
82
+
83
+ const { folders = [], selected, onSelect } = props
84
+
85
+ function isSelected(id) {
86
+ return selected === id
87
+ }
88
+
89
+ return (
90
+ <Tree>
91
+ {folders.map(folder => (
92
+ <TreeItem key={folder.id} icon={folder.icon} label={folder.title} onSelect={() => onSelect(folder.id)} selected={isSelected(folder.id)} />
93
+ ))}
94
+ </Tree>
95
+ )
96
+ }
97
+
98
+
99
+ export const FilesSearchBox = (props) => {
100
+
101
+ const { search, onSearch } = props
102
+
103
+ function searchChanged(id, value) {
104
+ onSearch(value)
105
+ }
106
+
107
+ return (
108
+ <div className="file-searchbox">
109
+ <TextField placeholder="Search..." onChange={searchChanged} outlined />
24
110
  </div>
25
111
  )
26
112
  }
@@ -28,49 +114,66 @@ export const FileExplorer = (props) => {
28
114
  /**
29
115
  * File Icons View
30
116
  */
31
- export const FilesGrid = (props) => {
32
- const { files = [], onSelect } = props
33
- const [selected, setSelected] = useState()
34
-
35
- function select(id) {
36
- setSelected(id)
37
- if (onSelect) onSelect(id)
38
- }
117
+ export const FilesGridView = (props) => {
118
+ const { files = [], selected, onSelect } = props
39
119
 
40
120
  function isSelected(id) {
41
121
  return selected === id
42
122
  }
43
123
 
44
124
  return (
45
- <div className="file-view file-view--icons">
46
- {files.map(file => <FileIcon file={file} onSelect={select} selected={isSelected(file.id)} />)}
125
+ <div className="files-grid">
126
+ {files.map(file => <FileGridItem key={file.id} file={file} onSelect={onSelect} selected={isSelected(file.id)} />)}
47
127
  </div>
48
128
  )
49
129
  }
50
130
 
51
131
  /**
52
- * File Icon
132
+ * File Grid Item
53
133
  */
54
- const FileIcon = (props) => {
134
+ const FileGridItem = (props) => {
55
135
 
56
136
  const { file = {}, selected = false, onSelect } = props
57
- const { id, icon, label, actions = [], src = "https://findicons.com/files/icons/2813/flat_jewels/256/file.png", footer } = file
137
+ const { id, icon, title, subtitle, actions = [], src = "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQkAPtY9GS4QgwAjRUSvLaa6TP4fSlQkVDqEg&usqp=CAU", footer } = file
58
138
 
59
139
  function select() {
60
140
  if (onSelect && !selected) onSelect(id)
61
141
  }
62
142
 
63
- const style = selected ? 'file-icon--selected' :''
143
+ const style = selected ? 'file-item--selected' : ''
64
144
  return (
65
- <div className={`file-icon ${style}`} onClick={select}>
145
+ <div className={`file-item ${style}`} onClick={select}>
66
146
  <picture>
67
147
  <img src={src}></img>
68
148
  </picture>
69
149
  <main>
70
- {icon? <Icon size="small" icon={icon} /> : null }
71
- <label>{label}</label>
150
+ <div className='file-item-title'>{title}</div>
151
+ <div className='file-item-subtitle'>{subtitle}</div>
72
152
  </main>
73
- { footer ? <footer>{footer}</footer> : null }
74
153
  </div>
75
154
  )
76
- }
155
+ }
156
+
157
+ const FilesTableView = (props) => {
158
+
159
+ const { files = [], selected, onSelect } = props
160
+
161
+ function isSelected(id) {
162
+ return selected === id
163
+ }
164
+
165
+ const table = {
166
+ columns: [
167
+ { id: "icon", type: "ICON"},
168
+ { id: "title", label: "Title" },
169
+ { id: "subtitle", label: "Subtitle" },
170
+ ],
171
+ rows: files
172
+ }
173
+
174
+ return (
175
+ <div className="files-table">
176
+ <DataTable {...table} />
177
+ </div>
178
+ )
179
+ }
@@ -1,26 +1,93 @@
1
- import React from 'react'
1
+ import React, { useState } from 'react'
2
2
  import { Button } from '../../html'
3
- import { FileExplorer, FileIconsView } from './explorer'
3
+ import { FileExplorerView, FileIconsView } from './explorer'
4
+
4
5
 
5
6
  const thumb1 = "https://findicons.com/files/icons/2813/flat_jewels/256/file.png"
6
7
 
7
8
  const files = [
8
- { id: "0001", icon: "star", label: "File 1", src:thumb1, actions: [ { icon:"info", label:"Action1", execute: () => alert("Action1")} ], footer: <span>ok</span> },
9
- { id: "0002", icon: "star", label: "File 2", src:thumb1 },
10
- { id: "0003", icon: "star", label: "File 3", src:thumb1 },
11
- { id: "0004", icon: "star", label: "File 4", src:thumb1 },
12
- { id: "0005", icon: "star", label: "File 5", src:thumb1 },
13
- { id: "0006", icon: "star", label: "File 6", src:thumb1 },
14
- { id: "0007", icon: "star", label: "File 7", src:thumb1 },
15
- { id: "0008", icon: "star", label: "File 8", src:thumb1 },
16
- { id: "0009", icon: "star", label: "File 9", src:thumb1 },
17
- { id: "0010", icon: "star", label: "File 10", src:thumb1 },
9
+ { folder: "10001", id: "0001", icon: "description", title: "File 1", subtitle: "16 kb", src:thumb1 },
10
+ { folder: "10001", id: "0002", icon: "description", title: "File 2", subtitle: "16 kb", src:thumb1 },
11
+ { folder: "10001", id: "0003", icon: "description", title: "File 3", subtitle: "16 kb", src:thumb1 },
12
+ { folder: "10001", id: "0004", icon: "description", title: "File 4", subtitle: "16 kb", src:thumb1 },
13
+ { folder: "10001", id: "0005", icon: "description", title: "File 5", subtitle: "16 kb", src:thumb1 },
14
+ { folder: "10001", id: "0006", icon: "description", title: "File 6", subtitle: "16 kb", src:thumb1 },
15
+ { folder: "10001", id: "0007", icon: "description", title: "File 7", subtitle: "16 kb", src:thumb1 },
16
+ { folder: "10001", id: "0008", icon: "description", title: "File 8", subtitle: "16 kb", src:thumb1 },
17
+ { folder: "10001", id: "0009", icon: "description", title: "File 9", subtitle: "16 kb", src:thumb1 },
18
+ { folder: "10001", id: "0010", icon: "description", title: "File 10", subtitle: "16 kb", src:thumb1 },
19
+ { folder: "10001", id: "0011", icon: "description", title: "File 11", subtitle: "16 kb", src:thumb1 },
20
+ { folder: "10002", id: "0012", icon: "description", title: "File 12", subtitle: "16 kb", src:thumb1 },
21
+ { folder: "10002", id: "0013", icon: "description", title: "File 13", subtitle: "16 kb", src:thumb1 },
22
+ { folder: "10002", id: "0014", icon: "description", title: "File 14", subtitle: "16 kb", src:thumb1 },
23
+ { folder: "10002", id: "0015", icon: "description", title: "File 15", subtitle: "16 kb", src:thumb1 },
24
+ { folder: "10002", id: "0016", icon: "description", title: "File 16", subtitle: "16 kb", src:thumb1 },
25
+ { folder: "10002", id: "0017", icon: "description", title: "File 17", subtitle: "16 kb", src:thumb1 },
26
+ { folder: "10002", id: "0018", icon: "description", title: "File 18", subtitle: "16 kb", src:thumb1 },
27
+ { folder: "10002", id: "0019", icon: "description", title: "File 19", subtitle: "16 kb", src:thumb1 },
28
+ { folder: "10002", id: "0020", icon: "description", title: "File 20", subtitle: "16 kb", src:thumb1 },
29
+ { folder: "10002", id: "0021", icon: "description", title: "File 21", subtitle: "16 kb", src:thumb1 },
30
+ { folder: "10002", id: "0022", icon: "description", title: "File 22", subtitle: "16 kb", src:thumb1 },
31
+ { folder: "10002", id: "0023", icon: "description", title: "File 23", subtitle: "16 kb", src:thumb1 },
32
+ { folder: "10002", id: "0024", icon: "description", title: "File 24", subtitle: "16 kb", src:thumb1 },
33
+ { folder: "10003", id: "0025", icon: "description", title: "File 25", subtitle: "16 kb", src:thumb1 },
34
+ { folder: "10003", id: "0026", icon: "description", title: "File 26", subtitle: "16 kb", src:thumb1 },
35
+ { folder: "10003", id: "0027", icon: "description", title: "File 27", subtitle: "16 kb", src:thumb1 },
36
+ { folder: "10003", id: "0028", icon: "description", title: "File 28", subtitle: "16 kb", src:thumb1 },
37
+ { folder: "10003", id: "0029", icon: "description", title: "File 29", subtitle: "16 kb", src:thumb1 },
38
+ { folder: "10003", id: "0030", icon: "description", title: "File 30", subtitle: "16 kb", src:thumb1 },
39
+ { folder: "10003", id: "0031", icon: "description", title: "File 31", subtitle: "16 kb", src:thumb1 },
40
+ { folder: "10003", id: "0032", icon: "description", title: "File 32", subtitle: "16 kb", src:thumb1 },
41
+ { folder: "10004", id: "0033", icon: "description", title: "File 33", subtitle: "16 kb", src:thumb1 },
42
+ { folder: "10004", id: "0034", icon: "description", title: "File 34", subtitle: "16 kb", src:thumb1 },
43
+ { folder: "10004", id: "0035", icon: "description", title: "File 35", subtitle: "16 kb", src:thumb1 },
44
+ { folder: "10004", id: "0036", icon: "description", title: "File 36", subtitle: "16 kb", src:thumb1 },
45
+ { folder: "10004", id: "0037", icon: "description", title: "File 37", subtitle: "16 kb", src:thumb1 },
46
+ { folder: "10005", id: "0033", icon: "description", title: "File 33", subtitle: "16 kb", src:thumb1 },
47
+ { folder: "10005", id: "0034", icon: "description", title: "File 34", subtitle: "16 kb", src:thumb1 },
48
+ { folder: "10005", id: "0035", icon: "description", title: "File 35", subtitle: "16 kb", src:thumb1 },
49
+ { folder: "10005", id: "0036", icon: "description", title: "File 36", subtitle: "16 kb", src:thumb1 },
50
+ { folder: "10005", id: "0037", icon: "description", title: "File 37", subtitle: "16 kb", src:thumb1 },
51
+ ]
52
+
53
+ const folders = [
54
+ { id: "10001", icon: "folder", title: "Folder 1", subtitle: "1 file" },
55
+ { id: "10002", icon: "folder", title: "Folder 2", subtitle: "1 file" },
56
+ { id: "10003", icon: "folder", title: "Folder 3", subtitle: "1 file" },
57
+ { id: "10004", icon: "folder", title: "Folder 4", subtitle: "1 file" },
58
+ { id: "10005", icon: "folder", title: "Folder 5", subtitle: "1 file" },
18
59
  ]
19
60
 
61
+
20
62
  const FileExplorerTest = (props) => {
63
+
64
+ const [selectedFolder, setSelectedFolder] = useState("10002")
65
+ const [selectedFile, setSelectedFile] = useState()
66
+ const [search, setSearch] = useState()
67
+
68
+ function selectFolder(id) {
69
+ setSelectedFolder(id)
70
+ }
71
+
72
+ function selectFile(id) {
73
+ setSelectedFile(id)
74
+ }
75
+
76
+ function searchChanged(value) {
77
+ setSearch(value)
78
+ }
79
+
80
+ const filteredFiles = search ? files.filter(file => file.title.toLowerCase().includes(search.toLowerCase())) : files
81
+ const selectedFiles = filteredFiles.filter(file => file.folder === selectedFolder)
82
+
21
83
  return (
22
84
  <div style={{ padding: "1rem", flex: "1", height: "100%" }}>
23
- <FileExplorer title="File Explorer Test" files={files} />
85
+ <FileExplorerView
86
+ title="File Explorer Test"
87
+ folders={folders} selectedFolder={selectedFolder} onSelectFolder={selectFolder} 
88
+ files={selectedFiles} selectedFile={selectedFile} onSelectFile={selectFile}
89
+ search={search} onSearch={searchChanged}
90
+ />
24
91
  </div>
25
92
  )
26
93
  }