4
4
* @demo demo/index.html
5
5
* @element hax-cloud
6
6
*/
7
- import { LitElement , html } from "lit" ;
7
+ import { html } from "lit" ;
8
+ import { DDD } from "@lrnwebcomponents/d-d-d/d-d-d.js" ;
8
9
import { FileSystemBrokerSingleton } from "@lrnwebcomponents/file-system-broker/file-system-broker.js" ;
9
10
import "@lrnwebcomponents/simple-icon/lib/simple-icons.js" ;
10
11
import "@lrnwebcomponents/hax-iconset/lib/simple-hax-iconset.js" ;
11
12
import "@lrnwebcomponents/simple-icon/lib/simple-icon-button-lite.js" ;
12
13
import "@lrnwebcomponents/haxcms-elements/lib/core/haxcms-site-builder.js" ;
13
- class HaxCloud extends LitElement {
14
+ class HaxCloud extends DDD {
14
15
createRenderRoot ( ) {
15
16
return this ;
16
17
}
@@ -20,16 +21,10 @@ class HaxCloud extends LitElement {
20
21
static get tag ( ) {
21
22
return "hax-cloud" ;
22
23
}
23
- static get properties ( ) {
24
- return {
25
- step : { type : Number } ,
26
- } ;
27
- }
28
24
29
25
constructor ( ) {
30
26
super ( ) ;
31
27
this . windowControllers = new AbortController ( ) ;
32
- this . step = 1 ;
33
28
this . fileRoot = "" ;
34
29
this . fileObjects = [ ] ;
35
30
if ( ! window . __haxLogoFontLoaded ) {
@@ -64,8 +59,8 @@ class HaxCloud extends LitElement {
64
59
padding : 16px ;
65
60
margin : 0 ;
66
61
--simple-icon-button-border-radius : 0 ;
67
- --simple-icon-width : 200 px ;
68
- --simple-icon-height : 200 px ;
62
+ --simple-icon-width : 100 px ;
63
+ --simple-icon-height : 100 px ;
69
64
}
70
65
simple-icon-button-lite ::part (button ) {
71
66
font-size : 20px ;
@@ -116,8 +111,8 @@ class HaxCloud extends LitElement {
116
111
margin : 16px ;
117
112
}
118
113
.name-icon {
119
- --simple-icon-width : 64 px ;
120
- --simple-icon-height : 64 px ;
114
+ --simple-icon-width : 100 px ;
115
+ --simple-icon-height : 100 px ;
121
116
display : inline-flex;
122
117
padding : 16px ;
123
118
}
@@ -148,7 +143,8 @@ class HaxCloud extends LitElement {
148
143
< li > Click Download HAX site (if needed)</ li >
149
144
< li > Unzip folder where you manage files on your computer</ li >
150
145
< li > Click Select HAX site</ li >
151
- < li > Select a HAX site (what you just unzipped)</ li >
146
+ < li > Select The HAX site that you just unzipped in Step 2</ li >
147
+ < li > Start editing HAX pages on your local machine!!</ li >
152
148
</ ol >
153
149
</ details >
154
150
< div class ="step ">
@@ -160,9 +156,8 @@ class HaxCloud extends LitElement {
160
156
>
161
157
</ div >
162
158
< div class ="step ">
163
- < h2 > Step 2 </ h2 >
159
+ < h2 > Step 3 </ h2 >
164
160
< simple-icon-button-lite
165
- ?disabled ="${ this . step < 1 } "
166
161
icon ="folder-open "
167
162
@click ="${ this . findLocalHaxCopy } "
168
163
> Select HAX site</ simple-icon-button-lite
@@ -174,7 +169,6 @@ class HaxCloud extends LitElement {
174
169
}
175
170
176
171
async downloadHAXLatest ( ) {
177
- this . step = 1 ;
178
172
let a = document . createElement ( "a" ) ;
179
173
a . href =
180
174
"https://github.com/elmsln/hax-single-site/archive/refs/heads/main.zip" ;
@@ -183,27 +177,20 @@ class HaxCloud extends LitElement {
183
177
}
184
178
185
179
async findLocalHaxCopy ( ) {
186
- if ( this . step > 0 ) {
187
- const broker = FileSystemBrokerSingleton ;
188
- // this allows confirmation that all file objects in this directory are open for read and write
189
- this . fileObjects = await broker . openDir ( true , { mode : "readwrite" } ) ;
190
- await this . fileObjects . forEach ( async ( fileRecord ) => {
191
- if ( fileRecord . kind === "file" && fileRecord . name === "site.json" ) {
192
- let file = await fileRecord . handle . getFile ( ) ;
193
- let manifest = JSON . parse ( await file . text ( ) ) ;
194
- this . fileRoot = fileRecord . folder ;
195
- console . log ( manifest ) ;
196
- if ( manifest && manifest . items . length > 0 ) {
197
- document . querySelector ( "haxcms-site-builder" ) . manifest = manifest ;
198
- }
199
- }
200
- } ) ;
201
- setTimeout ( ( ) => {
202
- if ( this . step === 1 ) {
203
- alert ( "You must select a valid HAXcms site folder" ) ;
180
+ const broker = FileSystemBrokerSingleton ;
181
+ // this allows confirmation that all file objects in this directory are open for read and write
182
+ this . fileObjects = await broker . openDir ( true , { mode : "readwrite" } ) ;
183
+ await this . fileObjects . forEach ( async ( fileRecord ) => {
184
+ if ( fileRecord . kind === "file" && fileRecord . name === "site.json" ) {
185
+ let file = await fileRecord . handle . getFile ( ) ;
186
+ let manifest = JSON . parse ( await file . text ( ) ) ;
187
+ this . fileRoot = fileRecord . folder ;
188
+ console . log ( manifest ) ;
189
+ if ( manifest && manifest . items . length > 0 ) {
190
+ document . querySelector ( "haxcms-site-builder" ) . manifest = manifest ;
204
191
}
205
- } , 10 ) ;
206
- }
192
+ }
193
+ } ) ;
207
194
}
208
195
209
196
loadLocalHax ( ) {
@@ -234,7 +221,6 @@ class HaxCloud extends LitElement {
234
221
} ,
235
222
} ,
236
223
} ;
237
- this . step = 2 ;
238
224
// inject the file object / directory root into the user file system backend handler
239
225
// this way we can intercept failed page requests and redirect them to the local file system
240
226
// and keep all logic inside the userfs handler and remove this element
0 commit comments