5htp-core 0.2.7-5 → 0.2.7-6

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,7 +1,7 @@
1
1
  {
2
2
  "name": "5htp-core",
3
3
  "description": "Convenient TypeScript framework designed for Performance and Productivity.",
4
- "version": "0.2.7-5",
4
+ "version": "0.2.7-6",
5
5
  "author": "Gaetan Le Gac (https://github.com/gaetanlegac)",
6
6
  "repository": "git://github.com/gaetanlegac/5htp-core.git",
7
7
  "license": "MIT",
@@ -228,16 +228,19 @@ export default () => {
228
228
 
229
229
  const app = useContext();
230
230
 
231
- const [rendered, setRendered] = React.useState<ComponentChild[]>([]);
231
+ const [modals, setModals] = React.useState<ComponentChild[]>([]);
232
+ const [toasts, setToasts] = React.useState<ComponentChild[]>([]);
232
233
 
233
- if (app.side === 'client')
234
- app.modal.setToasts = app.toast.setToasts = setRendered;
234
+ if (app.side === 'client') {
235
+ app.modal.setModals = setModals;
236
+ app.toast.setToasts = setToasts;
237
+ }
235
238
 
236
239
  React.useEffect(() => {
237
240
 
238
241
  console.log('Updated toast list');
239
242
 
240
- const modals = document.querySelectorAll("#dialog > .modal");
243
+ const modals = document.querySelectorAll("#modals > .modal");
241
244
  if (modals.length === 0)
242
245
  return;
243
246
 
@@ -259,10 +262,18 @@ export default () => {
259
262
 
260
263
  });
261
264
 
262
- return rendered.length !== 0 ? (
263
- <div id="dialog">
264
- {rendered}
265
- </div>
266
- ) : null;
265
+ return <>
266
+ {modals.length !== 0 ? (
267
+ <div id="modals">
268
+ {modals}
269
+ </div>
270
+ ) : null}
271
+
272
+ {toasts.length !== 0 ? (
273
+ <div id="toasts">
274
+ {toasts}
275
+ </div>
276
+ ) : null}
277
+ </>
267
278
 
268
279
  }
@@ -1,6 +1,6 @@
1
1
  @toast-zindex: 999;
2
2
 
3
- #dialog {
3
+ #modals, #toasts {
4
4
 
5
5
  z-index: @toast-zindex;
6
6
 
@@ -10,11 +10,10 @@
10
10
  justify-content: flex-end;
11
11
  gap: @spacing;
12
12
  padding: @spacing;
13
-
13
+
14
14
  &,
15
15
  > .modal {
16
16
  position: fixed;
17
- top: 0px;
18
17
  left: 0px;
19
18
  right: 0px;
20
19
  bottom: 0px;
@@ -35,40 +34,13 @@
35
34
  margin-top: 0;
36
35
  }
37
36
  }
37
+ }
38
38
 
39
- // Toast
40
- > .card {
41
-
42
- text-align: left;
43
- max-width: 450px;
44
- z-index: 999;
45
- cursor: pointer;
46
- padding-right: @spacing * 1.5;
47
-
48
- animation: aff-toast 0.1s ease;
49
- @keyframes aff-toast {
50
- 0% {
51
- opacity: 0.5;
52
- transform: scale(0.5);
53
- }
54
- 100% {
55
- opacity: 1;
56
- transform: scale(1);
57
- }
58
- }
59
-
60
- > i {
61
- color: @c1;
62
- flex: 0 0 1em;
63
- }
64
-
65
- h2 {
66
- font-size: 1em;
67
- }
39
+ #modals {
68
40
 
69
- p {
70
- text-align: left;
71
- }
41
+ &,
42
+ > .modal {
43
+ top: 0px;
72
44
  }
73
45
 
74
46
  > .modal {
@@ -136,6 +108,43 @@
136
108
  }
137
109
  }
138
110
 
111
+ #toasts {
112
+ // Toast
113
+ > .card {
114
+
115
+ text-align: left;
116
+ max-width: 450px;
117
+ z-index: 999;
118
+ cursor: pointer;
119
+ padding-right: @spacing * 1.5;
120
+
121
+ animation: aff-toast 0.1s ease;
122
+ @keyframes aff-toast {
123
+ 0% {
124
+ opacity: 0.5;
125
+ transform: scale(0.5);
126
+ }
127
+ 100% {
128
+ opacity: 1;
129
+ transform: scale(1);
130
+ }
131
+ }
132
+
133
+ > i {
134
+ color: @c1;
135
+ flex: 0 0 1em;
136
+ }
137
+
138
+ h2 {
139
+ font-size: 1em;
140
+ }
141
+
142
+ p {
143
+ text-align: left;
144
+ }
145
+ }
146
+ }
147
+
139
148
  // Selecteur moins profond pour que les clases utilitaires (w-a-x) soient prioritaires
140
149
  .modal > .card {
141
150
  max-width: 500px;
@@ -49,6 +49,7 @@
49
49
 
50
50
  height: @labelH;
51
51
  font-size: 0.8em;
52
+ line-height: 0.8em;
52
53
  color: var(--cTxtDesc);
53
54
  transition: all .1s ease-out;
54
55
  }
@@ -0,0 +1,77 @@
1
+ /*----------------------------------
2
+ - DEPS
3
+ ----------------------------------*/
4
+
5
+ // Core
6
+ import Application, { Service } from '@server/app';
7
+
8
+ /*----------------------------------
9
+ - CONFIG
10
+ ----------------------------------*/
11
+
12
+ export type THooks = {
13
+
14
+ }
15
+
16
+ /*----------------------------------
17
+ - TYPE
18
+ ----------------------------------*/
19
+
20
+ export type TDrivercnfig = {
21
+
22
+ debug: boolean,
23
+
24
+ rootDir: string,
25
+ buckets: {
26
+ [id: string]: string
27
+ }
28
+ }
29
+
30
+ export type SourceFile = {
31
+ name: string,
32
+ path: string,
33
+ modified: number,
34
+ parentFolder: string,
35
+ source: string
36
+ }
37
+
38
+ export type TOutputFileOptions = {
39
+ encoding: string
40
+ }
41
+
42
+ /*----------------------------------
43
+ - CLASS
44
+ ----------------------------------*/
45
+
46
+ export default abstract class FsDriver<
47
+ Config extends TDrivercnfig = TDrivercnfig,
48
+ TBucketName = keyof Config["buckets"]
49
+ > {
50
+
51
+ public constructor( public app: Application, public config: Config ) {
52
+
53
+ }
54
+
55
+ public abstract mount(): Promise<void>;
56
+
57
+ public abstract readDir( bucketName: TBucketName, dirname?: string ): Promise<SourceFile[]>;
58
+
59
+ public abstract readFile( bucketName: TBucketName, filename: string ): Promise<string>;
60
+
61
+ public abstract createReadStream( bucketName: TBucketName, filename: string );
62
+
63
+ public abstract exists( bucketName: TBucketName, filename: string ): Promise<boolean>;
64
+
65
+ public abstract move( bucketName: TBucketName, source: string, destination: string, options: { overwrite?: boolean }): Promise<void>;
66
+
67
+ public abstract outputFile( bucketName: TBucketName, filename: string, content: string, encoding: TOutputFileOptions ): Promise<{
68
+ path: string
69
+ }>;
70
+
71
+ public abstract readJSON( bucketName: TBucketName, filename: string ): Promise<any>;
72
+
73
+ public abstract delete( bucketName: TBucketName, filename: string ): Promise<boolean>;
74
+
75
+ public abstract unmount(): Promise<void>;
76
+
77
+ }
@@ -0,0 +1,63 @@
1
+ /*----------------------------------
2
+ - DEPS
3
+ ----------------------------------*/
4
+
5
+ // Core
6
+ import Application, { Service } from '@server/app';
7
+
8
+ // Specific
9
+ import type Driver from './driver';
10
+
11
+ /*----------------------------------
12
+ - TYPES
13
+ ----------------------------------*/
14
+
15
+ type TMountpointList = { [name: string]: Driver }
16
+
17
+ type Config<MountpointList extends TMountpointList> = {
18
+ default: keyof MountpointList,
19
+ }
20
+
21
+ export type Hooks = {
22
+
23
+ }
24
+
25
+ /*----------------------------------
26
+ - SERVICE
27
+ ----------------------------------*/
28
+ export default class DisksManager<
29
+ MountpointList extends TMountpointList = {},
30
+ TConfig extends Config<MountpointList> = Config<MountpointList>,
31
+ TApplication extends Application = Application
32
+ > extends Service<TConfig, Hooks, TApplication> {
33
+
34
+ public default: Driver;
35
+
36
+ public constructor(
37
+ public app: TApplication,
38
+ public config: TConfig,
39
+ public mounted: MountpointList
40
+ ) {
41
+
42
+ super(app, config);
43
+
44
+ if (Object.keys( mounted ).length === 0)
45
+ throw new Error("At least one disk should be mounted.");
46
+
47
+ const defaultDisk = mounted[ config.default ];
48
+ if (defaultDisk === undefined)
49
+ console.log(`Default disk "${config.default as string}" not mounted.`);
50
+
51
+ this.default = defaultDisk;
52
+
53
+ }
54
+
55
+ public async register() {
56
+
57
+ }
58
+
59
+ public async start() {
60
+
61
+ }
62
+
63
+ }