@silexlabs/silex 3.2.0 → 3.2.1-0

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": "@silexlabs/silex",
3
3
  "description": "Free and easy website builder for everyone.",
4
- "version": "3.2.0",
4
+ "version": "3.2.1-0",
5
5
  "version:backwardcompat": "3.0.0",
6
6
  "author": {
7
7
  "name": "Alex Hoyau",
@@ -9,4 +9,44 @@
9
9
  align-items: center;
10
10
  background-color: variables.$primaryColor;
11
11
  z-index: variables.$z-loader;
12
+ opacity: 1;
13
+ font-size: 1.25rem;
14
+ letter-spacing: 0.025em;
15
+ .silex-loader__text {
16
+ min-width: 0;
17
+ transition: min-width 0.3s ease;
18
+ progress.silex-loader__progress {
19
+ opacity: 0;
20
+ width: 0;
21
+ height: 0;
22
+ position: absolute;
23
+ background-color: variables.$secondaryColor;
24
+ border-radius: 0.125rem;
25
+ transform: translateY(-5px);
26
+ transition: all 0.3s 0.3s ease;
27
+ &::-webkit-progress-bar {
28
+ background-color: variables.$primaryColor;
29
+ border-radius: 0.125rem;
30
+ }
31
+ &::-webkit-progress-value {
32
+ background-color: variables.$secondaryColor;
33
+ border-radius: 0.125rem;
34
+ }
35
+ &::-moz-progress-bar {
36
+ background-color: variables.$primaryColor;
37
+ border-radius: 0.125rem;
38
+ }
39
+ }
40
+ }
41
+ &.silex-loader--active {
42
+ .silex-loader__text {
43
+ min-width: 250px;
44
+ .silex-loader__progress {
45
+ opacity: 1;
46
+ transform: translateY(10px);
47
+ width: 200px;
48
+ height: 0.25rem;
49
+ }
50
+ }
51
+ }
12
52
  }
@@ -15,14 +15,15 @@ html(lang="en", translate="no")
15
15
  font-family: "Ubuntu", "Helvetica Neue", Helvetica, Arial, sans-serif;
16
16
  }
17
17
  .silex-loader {
18
- display: none;
18
+ opacity: 0;
19
+ transition: opacity 0.25s 0.25s ease-in-out;
19
20
  }
20
21
 
21
22
  block head-end
22
23
 
23
24
  body.silex-loading
24
25
  .silex-loader.silex-dialog.
25
- Loading...
26
+ Loading
26
27
 
27
28
  block includes
28
29
  include ./templates/includes.pug
@@ -22,9 +22,30 @@ import { addTempDataToAssetUrl, addTempDataToStyles, removeTempDataFromAssetUrl,
22
22
  import { PublicationStatus, PublishableEditor } from './PublicationManager'
23
23
  import { ClientEvent } from '../events'
24
24
  import { ProjectData } from 'grapesjs'
25
+ import { html, render, TemplateResult } from 'lit-html'
26
+ import { unsafeHTML } from 'lit-html/directives/unsafe-html.js'
25
27
 
26
28
  export const cmdPauseAutoSave = 'pause-auto-save'
27
29
 
30
+ const loader = document.querySelector('.silex-loader') as HTMLDivElement
31
+ if (!loader) {
32
+ throw new Error('No loader found in the DOM')
33
+ }
34
+ loader.innerHTML = ''
35
+ render(getLoaderHtml('Loading', 0, 0), loader)
36
+ setTimeout(() => loader.classList.add('silex-loader--active'))
37
+
38
+ function getLoaderHtml(text: string, current: number, total: number): TemplateResult {
39
+ return html`
40
+ <div class="silex-loader__text">
41
+ <div>${ unsafeHTML(text) }</div>
42
+ <progress
43
+ class="silex-loader__progress"
44
+ max="${total}" value="${current}"></progress>
45
+ </div>
46
+ `
47
+ }
48
+
28
49
  // Wait for the next frame to avoid blocking the main thread
29
50
  function nextFrame(): Promise<void> {
30
51
  const fn = window.requestIdleCallback ?? window.requestAnimationFrame
@@ -199,9 +220,11 @@ export const storagePlugin = (editor: PublishableEditor) => {
199
220
 
200
221
  async function progressiveLoadPages(editor: PublishableEditor, data: ProjectData) {
201
222
  editor.Pages.getAll().forEach(page => editor.Pages.remove(page))
223
+ const max = data.pages.length + 2
202
224
  let i = 0
203
225
  for (const page of data.pages) {
204
- document.querySelector('.silex-loader').innerHTML = `Loading page ${++i} / ${data.pages.length}`
226
+ render(getLoaderHtml(`Loading page <strong>${++i}</strong> / ${data.pages.length}`, i, max), loader)
227
+ //await new Promise(resolve => setTimeout(resolve, 1000 * 60 * 1000))
205
228
  await nextFrame()
206
229
  const newPage = editor.Pages.add({
207
230
  ...page,
@@ -209,7 +232,7 @@ async function progressiveLoadPages(editor: PublishableEditor, data: ProjectData
209
232
  }
210
233
 
211
234
  // Charger les styles, assets, etc. après les pages
212
- document.querySelector('.silex-loader').innerHTML = 'Loading styles and assets'
235
+ render(getLoaderHtml('Loading styles and assets', data.pages.length + 1, max), loader)
213
236
  if (data.styles) editor.setStyle(data.styles)
214
237
  if (data.assets) editor.AssetManager.add(data.assets)
215
238