ywana-core8 0.0.495 → 0.0.496

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.495",
3
+ "version": "0.0.496",
4
4
  "description": "ywana-core8",
5
5
  "homepage": "https://ywana.github.io/workspace",
6
6
  "author": "Ernesto Roldan Garcia",
@@ -1,12 +1,14 @@
1
+ import { publish } from "gh-pages"
2
+
1
3
  export class Console {
2
4
 
3
- constructor() {
5
+ constructor(publish) {
4
6
  this.lines = []
5
7
  }
6
8
 
7
9
  log(line) {
8
- console.log(line)
9
10
  this.lines.push(line)
11
+ publish(this.lines)
10
12
  }
11
13
 
12
14
  clear() {
package/src/site/site.css CHANGED
@@ -118,14 +118,22 @@
118
118
  color: #000;
119
119
  }
120
120
 
121
+ .site6>.site-console>nav {
122
+ display: flex;
123
+ align-items: center;
124
+ justify-content: flex-end;
125
+ }
126
+
121
127
  .site6>.site-console>main {
122
- border: solid 5px red;
123
128
  overflow: scroll;
124
129
  max-height: 40vh;
130
+ display: flex;
131
+ flex-direction: column-reverse;
125
132
  }
126
133
 
127
134
  .site6>.site-console>main>div {
128
135
  padding: 1rem;
136
+ border-bottom: dotted 1px var(--divider-color);
129
137
  }
130
138
 
131
139
  .site6>.site-preview {
package/src/site/site.js CHANGED
@@ -17,29 +17,30 @@ import { Console } from './console'
17
17
  * Site Provider
18
18
  */
19
19
  export const SiteProvider = ({ children, siteLang, siteDictionary }) => {
20
-
20
+
21
21
  const [lang, setLang] = useState(siteLang)
22
22
  const [dictionary, setDictionary] = useState(siteDictionary)
23
23
  const [sideNav, setSideNav] = useState('max')
24
24
  const [showNav, setShowNav] = useState(false)
25
25
  const [info, setInfo] = useState(null)
26
- const [showConsole, setShowConsole] = useState(false)
27
- const [console] = useState(new Console())
26
+ const [showConsole, setShowConsole] = useState(true)
27
+ const [consoleLines, setConsoleLines] = useState([])
28
28
  const [page, setPage] = useState()
29
29
  const [dialog, setDialog] = useState()
30
30
  const [promptDialog, setPromptDialog] = useState()
31
31
  const [preview, setPreview] = useState()
32
32
  const [breadcrumb, setBreadcrumb] = useState()
33
33
  const [focused, setFocused] = useState()
34
-
34
+
35
+
35
36
  const value = {
36
-
37
+
37
38
  lang,
38
39
  setLang,
39
-
40
+
40
41
  dictionary,
41
42
  setDictionary,
42
-
43
+
43
44
  focused,
44
45
  changeFocus: (next) => {
45
46
  if (focused) focused.lose()
@@ -49,21 +50,27 @@ export const SiteProvider = ({ children, siteLang, siteDictionary }) => {
49
50
  if (focused) focused.lose()
50
51
  setFocused(null)
51
52
  },
52
-
53
+
53
54
  sideNav,
54
55
  setSideNav,
55
56
 
56
57
  showNav,
57
58
  setShowNav,
58
-
59
+
59
60
  info,
60
61
  openInfo: (info) => { setInfo(info) },
61
62
  closeInfo: () => { setInfo(null) },
62
-
63
+
64
+ consoleLines,
63
65
  showConsole,
64
- console,
65
66
  toggleConsole: () => { setShowConsole(!showConsole) },
66
-
67
+ log: (line) => {
68
+ const next = consoleLines.concat(line)
69
+ setConsoleLines(next)
70
+ },
71
+ clearLog: () => {
72
+ setConsoleLines([])
73
+ },
67
74
 
68
75
  breadcrumb,
69
76
  setBreadcrumb,
@@ -306,7 +313,13 @@ const SitePreview = () => {
306
313
  * Site Console
307
314
  */
308
315
  const SiteConsole = () => {
316
+
309
317
  const context = useContext(SiteContext)
318
+
319
+ function clear() {
320
+ context.clearLog()
321
+ }
322
+
310
323
  return context.showConsole ? (
311
324
  <footer className="site-console" >
312
325
  <Header>
@@ -314,8 +327,11 @@ const SiteConsole = () => {
314
327
  <Tab label="Console" />
315
328
  </Tabs>
316
329
  </Header>
330
+ <nav>
331
+ <Icon icon="clear_all" size="small" clickable action={clear} />
332
+ </nav>
317
333
  <main>
318
- {context.console.lines.map(line => <div>{line}</div>)}
334
+ {context.consoleLines.map(line => <div>{line}</div>)}
319
335
  </main>
320
336
  </footer>
321
337
  ) : ''
@@ -98,8 +98,6 @@ const Page2 = (props) => {
98
98
  </Fragment>
99
99
  )
100
100
 
101
- site.console.log("open dialog")
102
-
103
101
  site.openDialog(
104
102
  <Dialog actions={actions}>
105
103
  <main>
@@ -108,12 +106,18 @@ const Page2 = (props) => {
108
106
  </Dialog>
109
107
  )
110
108
  }
111
-
109
+
110
+ function write() {
111
+ site.log("xxx"+new Date())
112
+ }
113
+
114
+
112
115
  return (
113
116
  <Fragment>
114
117
  <header>Page 2</header>
115
118
  <main>
116
119
  <Button label="open Dialog" action={openDialog} />
120
+ <Button label="Write inConsole" action={write} />
117
121
  </main>
118
122
  <footer>f2</footer>
119
123
  </Fragment>