@massimo-cassandro/minimo 0.6.7 → 0.7.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.
Files changed (34) hide show
  1. package/package.json +1 -1
  2. package/src/components/sf-macro/sf-macro.js +3 -2
  3. package/src/custom-properties-default.css +0 -7
  4. package/src/icons/caret-down-bold.svg +1 -0
  5. package/design-tokens-src/components/recaptcha.minimo.tokens.jsonc +0 -24
  6. package/design-tokens-src/components/toast.minimo.tokens.jsonc +0 -29
  7. package/src/components/alert-autoclose.js +0 -9
  8. package/src/components/auto-datatable/auto-datatable.css +0 -355
  9. package/src/components/auto-datatable/auto-datatable.js +0 -154
  10. package/src/components/create-blurhash-canvas.js +0 -47
  11. package/src/components/img-viewer-dom-builder.js +0 -196
  12. package/src/components/modal-alert/flash-alerts.js +0 -32
  13. package/src/components/modal-content/modal-content.js +0 -152
  14. package/src/components/modal-content/modal-content.module.css +0 -142
  15. package/src/components/popup-page/popup-page.css +0 -72
  16. package/src/components/popup-page/popup-page.js +0 -84
  17. package/src/components/print-icon.js +0 -51
  18. package/src/components/recaptcha/recaptcha.css +0 -73
  19. package/src/components/spinner/TODO spinner-circle.css +0 -54
  20. package/src/components/spinner/TODO spinner-three-dots.css +0 -14
  21. package/src/components/spinner/readme.md +0 -1
  22. package/src/components/spinner/spinner-trailing-dots.css +0 -51
  23. package/src/components/spinner/spinner-wrapper.css +0 -20
  24. package/src/components/spinner/spinner.js +0 -30
  25. package/src/components/toast/toast.js +0 -77
  26. package/src/components/toast/toast.module.css +0 -59
  27. package/src/components/vanilla-cookie-consent/cookie-consent.css +0 -20
  28. package/src/components/vanilla-cookie-consent/cookie-consent.js +0 -76
  29. package/src/components/vanilla-cookie-consent/render-cookie-list.js +0 -32
  30. package/src/components/vanilla-cookie-consent/src/cookie-list.js +0 -85
  31. package/src/components/vanilla-cookie-consent/src/it-translation.js +0 -38
  32. package/src/components/vanilla-cookie-consent/src/run-analytics.js +0 -54
  33. package/src/components/vanilla-cookie-consent/src/run-recaptcha.js +0 -71
  34. package/src/css/forms/select-indicator.svg +0 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@massimo-cassandro/minimo",
3
- "version": "0.6.7",
3
+ "version": "0.7.0",
4
4
  "description": "Light css framework",
5
5
  "type": "module",
6
6
  "homepage": "https://github.com/massimo-cassandro/minimo#readme",
@@ -4,7 +4,8 @@ export function sf_macro({
4
4
  wrapper_selector = '.sf-macro-wrapper',
5
5
  row_selector = '.sf-macro-riga',
6
6
  add_callback = null,
7
- del_callback = null
7
+ del_callback = null,
8
+ insertAtTop = false
8
9
  }={}) {
9
10
 
10
11
  document.querySelectorAll(wrapper_selector).forEach(fset => {
@@ -19,7 +20,7 @@ export function sf_macro({
19
20
 
20
21
  const righe_macro = macro_container.querySelectorAll(row_selector).length;
21
22
 
22
- macro_container.insertAdjacentHTML('beforeend',
23
+ macro_container.insertAdjacentHTML(insertAtTop? 'afterbegin' : 'beforeend',
23
24
  macro_template.replace(/__indice\d?__/g, righe_macro + 1)
24
25
  );
25
26
 
@@ -182,9 +182,6 @@
182
182
  --radius-xl: var(--size-xl);
183
183
  --radius-xs: var(--size-xs);
184
184
  --radius-xxs: var(--size-xxs);
185
- --recaptcha-alert-background-color: #000;
186
- --recaptcha-alert-fg: #fff;
187
- --recaptcha-alert-overlay-color: rgb(0 0 0 / .5);
188
185
  --sdt-hover-background-color: var(--btn-primary-background-color);
189
186
  --sdt-hover-color: var(--btn-primary-color);
190
187
  --sdt-pagination-border: var(--btn-border-width) var(--neutral-100);
@@ -248,9 +245,5 @@
248
245
  --text-negative: #fff;
249
246
  --text-selected-background-color: #ddd;
250
247
  --text-selected-text: var(--body-text);
251
- --toast-border-radius: var(--radius-sm);
252
- --toast-duration: 5s;
253
- --toast-font-size: var(--font-size-sm);
254
- --toast-text-color: var(--text-color);
255
248
  --z-index-overlay: 99;
256
249
  }
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" fill="#000000" viewBox="0 0 256 256"><path d="M216.49,104.49l-80,80a12,12,0,0,1-17,0l-80-80a12,12,0,0,1,17-17L128,159l71.51-71.52a12,12,0,0,1,17,17Z"></path></svg>
@@ -1,24 +0,0 @@
1
- {
2
- "recaptcha": {
3
- "alert": {
4
-
5
- "overlay": {
6
- "color": {
7
- "$type": "color",
8
- "$value": "rgb(0 0 0 / .5)"
9
- },
10
- },
11
-
12
- "background": {
13
- "color": {
14
- "$type": "color",
15
- "$value": "#000"
16
- }
17
- },
18
- "fg": {
19
- "$type": "color",
20
- "$value": "#fff"
21
- },
22
- }
23
- }
24
- }
@@ -1,29 +0,0 @@
1
- {
2
- "toast": {
3
-
4
- "font": {
5
- "size": {
6
- "$value": "{font.size.sm}",
7
- "$type": "dimension"
8
- },
9
- },
10
-
11
- "border": {
12
- "radius": {
13
- "$value": "{radius.sm}",
14
- "$type": "color"
15
- }
16
- },
17
- "text": {
18
- "color": {
19
- "$value": "{text.color}",
20
- "$type": "color"
21
- }
22
- },
23
- "duration": {
24
- "$value": "5s",
25
- "$type": "duration"
26
- }
27
- }
28
-
29
- }
@@ -1,9 +0,0 @@
1
- // alert autoclose
2
- let flash_alert = document.querySelector('.alert-success.autoclose');
3
- if (flash_alert) {
4
- window.setTimeout(function () {
5
- slideUp(flash_alert, 500, () => {
6
- flash_alert.remove();
7
- });
8
- }, 4000);
9
- }
@@ -1,355 +0,0 @@
1
- /* stylelint-disable selector-class-pattern */
2
- /* @import '@massimo-cassandro/auto-datatables-bs5/css/index.css'; */
3
-
4
- @import '@massimo-cassandro/auto-datatables-bs5/css/crea-datatable.css';
5
- @import '@massimo-cassandro/auto-datatables-bs5/css/datatable-processing.css';
6
- @import '@massimo-cassandro/auto-datatables-bs5/css/datatable-controls-bs.css';
7
- @import '@massimo-cassandro/auto-datatables-bs5/css/datatable-table-bs.css';
8
- /* @import '@massimo-cassandro/auto-datatables-bs5/css/datatable-sorting.css'; */
9
- /* @import '@massimo-cassandro/auto-datatables-bs5/css/datatable-pagination-bs.css'; */
10
- @import '@massimo-cassandro/auto-datatables-bs5/css/datatables-classes.css';
11
- /* @import '@massimo-cassandro/auto-datatables-bs5/css/datatable-responsive.css'; */
12
-
13
-
14
- /*
15
- <div class="dt-container m-datatable" data-cdt-options="..." data-cdt_options="..." data-dt-columns="...">
16
- <div class="datatable-wrapper no-footer">
17
- <div class="dt-controls">
18
- <div class="datatable-length">
19
- <label>
20
- <di class=="dt-control-label">Mostra</di>
21
- <div class="dt-control">
22
- <select name="cdt-dom-2_length" class="form-control form-control-sm">
23
- <option value="...">...</option>
24
- </select>
25
- </div>
26
- <div>record per pagina</div>
27
- </label>
28
- </div>
29
- <div class="datatable-filter"><label>
30
- <div class=="dt-control-label">>Filtra risultati:</div>
31
- <div class="dt-control">
32
- <input type="search" class="form-control form-control-sm" placeholder=""></div>
33
- </label></div>
34
- </div>
35
- <div class="dt-table-wrapper">
36
- <table class="table table-striped table-bordered table-hover dataTable no-footer" >
37
- ...
38
- </table>
39
- </div>
40
- <div class="dataTables_processing">...</div>
41
-
42
- <div class="dt-footer">
43
- <div class="dataTables_info" role="status" aria-live="polite">Stai visualizzando...</div>
44
-
45
- <div class="dataTables_paginate paging_simple_numbers">
46
- ...
47
- </div>
48
-
49
- </div>
50
-
51
- </div>
52
- </div>
53
- */
54
-
55
-
56
-
57
- .m-datatable {
58
-
59
-
60
- /* --datatable-responsive-border-color: #ccc; */
61
- /* --datatable-processing-padding: 0; */
62
- /* --datatable-processing-bg: linear-gradient(to right, rgba(#fff, 0) 0%, rgba(#fff, .9) 25%, rgba(#fff, .9) 75%, rgba(#fff, 0) 100%); */
63
-
64
- /* --sorting-cell-base-padding: .5em; */
65
-
66
- /* --datatable-active-sorting-color: currentColor; */
67
- /* --datatable-active-sorting-bg: inherit; */
68
- /* --datatable-active-sorting-border-bottom: none; */
69
-
70
- /* --sorting-arrow-size: 4px; */
71
- /* --datatable-sorting-arrows-color: currentColor; */
72
- /* --sorting-cell-arrow-padding: var(--sorting-cell-base-padding) 1.5em var(--sorting-cell-base-padding) var(--sorting-cell-base-padding); */
73
- /* --sorting-arrow-bottom: 50%; */
74
-
75
- /* --pagination-padding-x: .5rem; */
76
- --pagination-padding-y: .4rem;
77
- /* --pagination-font-size: .875rem; */
78
-
79
- --pagination-color: var(--text-color);
80
- /* --pagination-bg: #fff; */
81
- /* --pagination-border-width: 1px; */
82
- --pagination-border-color: var(--stone-5);
83
-
84
- /* --pagination-border-radius: .25rem; */
85
- --pagination-hover-color: var(--accent-3-fg);
86
- --pagination-hover-bg: var(--accent-3);
87
- /* --pagination-hover-border-color: var(--pagination-border-color); */
88
- /* --pagination-focus-color: var(--pagination-hover-color); */
89
- /* --pagination-focus-bg: var(--pagination-hover-bg); */
90
- /* --pagination-focus-box-shadow: 0 0 0 .25rem #06407a40; */
91
- --pagination-active-color: var(--secondary-fg);
92
- --pagination-active-bg: var(--secondary);
93
- /* --pagination-active-border-color: #007e8a; */
94
- /* --pagination-disabled-color: #ababab; */
95
- /* --pagination-disabled-bg: var(--pagination-hover-bg); */
96
- /* --pagination-disabled-border-color: var(--pagination-border-color); */
97
-
98
-
99
- --sorting-border-size: 6px;
100
- --sorting-border-color: var(--secondary);
101
-
102
- position: relative;
103
-
104
- .dt-controls {
105
- display: flex;
106
- flex-flow: row wrap;
107
- gap: 1rem;
108
- align-items: center;
109
- justify-content: space-between;
110
-
111
- > div {
112
- max-width: 100%;
113
- }
114
- }
115
-
116
- .icon {
117
- width: 1.1em;
118
- }
119
-
120
-
121
- @media (--desktop-down) {
122
- /* .dt-control-label {} */
123
- .dt-controls {
124
- flex-direction: column;
125
- justify-content: center;
126
- }
127
- }
128
- }
129
-
130
- @media print {
131
- .m-datatable {
132
- .dt-controls, .dt-footer {
133
- display: none;
134
- }
135
- }
136
- }
137
-
138
-
139
- /* https://css-tip.com/overflow-detection/ */
140
- /* https://csscade.com/can-you-detect-overflow-with-css/ */
141
- .dt-table-wrapper {
142
- max-width: 100%;
143
- overflow-x: auto;
144
-
145
- /* animation-timeline: scroll(self);
146
- animation: detect-scroll linear;
147
- --_bg-if-can-scroll: var(--_can-scroll) lime;
148
- --_bg-if-cant-scroll: red;
149
- background: var(--_bg-if-can-scroll, var(--_bg-if-cant-scroll)); */
150
-
151
-
152
- .table thead th {
153
- vertical-align: middle;
154
- }
155
-
156
- .sorting_disabled,
157
- .sorting_asc_disabled,
158
- .sorting_desc_disabled {
159
- cursor: default;
160
- }
161
-
162
- .sorting {
163
- position: relative;
164
- cursor: pointer;
165
-
166
-
167
- @media (--mouse) {
168
- &:hover {
169
- /* --datatable_active_sorting_color */
170
-
171
- --datatable-active-sorting-bg: color-mix(in srgb, var(--accent-1) 10%, transparent);
172
- /* stylelint-disable-next-line declaration-block-no-duplicate-custom-properties */
173
- --datatable-active-sorting-bg: light-dark(color-mix(in srgb, var(--accent-1) 10%, transparent), color-mix(in srgb, var(--accent-1) 30%, transparent));
174
-
175
- /* --datatable-active-sorting-border-bottom */
176
- }
177
- }
178
- }
179
-
180
-
181
- .sorting_asc, .sorting_desc{
182
- &::after {
183
- position: absolute;
184
- right: 0;
185
- left: 0;
186
- display: block;
187
- height: var(--sorting-border-size);
188
- content: '';
189
- background-color: var(--sorting-border-color);
190
-
191
- }
192
- /* border-bottom: var(--sorting-border-size) solid var(--sorting-border-color); */
193
- }
194
- .sorting_asc{
195
- &::after {
196
- top: calc(-1 * var(--sorting-border-size) / 2);
197
-
198
- }
199
- }
200
- .sorting_desc{
201
- &::after {
202
- bottom: calc(-1 * var(--sorting-border-size) / 2);
203
- }
204
- }
205
- }
206
-
207
- /*
208
- @keyframes detect-scroll {
209
- from, to {
210
- --_can-scroll:;
211
- }
212
- } */
213
-
214
-
215
- .dt-footer {
216
- display: flex;
217
- flex-flow: column wrap;
218
- gap: .5rem;
219
- align-items: center;
220
- justify-content: center;
221
- margin-block: 1rem;
222
-
223
- @media (--desktop-up) {
224
- flex-direction: row;
225
- gap: 2rem;
226
- justify-content: space-between;
227
- }
228
- }
229
-
230
- .dataTables_info {
231
- font-size: var(--font-size-xs);
232
- /* color: var(--text-muted-color); */
233
- }
234
-
235
- /*
236
- <div class="dataTables_paginate paging_simple_numbers">
237
- <a class="paginate_button previous disabled" aria-disabled="true" role="link" data-dt-idx="previous" tabindex="-1"></a>
238
-
239
- <span>
240
- <a class="paginate_button current" role="link" aria-current="page" data-dt-idx="0" tabindex="0">1</a>
241
- <a class="paginate_button " role="link" data-dt-idx="1" tabindex="0">2</a>
242
- <span class="ellipsis">…</span>
243
- <a class="paginate_button " role="link" data-dt-idx="9" tabindex="0">10</a>
244
- </span>
245
-
246
- <a class="paginate_button next" role="link" data-dt-idx="next" tabindex="0"></a>
247
- </div>
248
- */
249
-
250
- .dataTables_paginate {
251
- display: flex;
252
- flex-flow: row nowrap;
253
- gap: 0;
254
- align-items: center;
255
- justify-content: flex-end;
256
-
257
- > span {
258
-
259
- display: flex;
260
- flex-flow: row nowrap;
261
- gap: 0;
262
- align-items: center;
263
- justify-content: flex-end;
264
- }
265
-
266
- .paginate_button, .ellipsis {
267
- display: flex;
268
- justify-content: center;
269
- padding: var(--pagination-padding-y) var(--pagination-padding-x);
270
- font-size: var(--pagination-font-size);
271
- font-weight: var(--font-weight-semibold);
272
- line-height: 1;
273
- color: var(--pagination-color);
274
- border: var(--pagination-border-width) var(--pagination-border-color);
275
- border-style: solid solid solid none;
276
- }
277
-
278
- .ellipsis {
279
- justify-content: flex-end;
280
- }
281
-
282
- .paginate_button {
283
- align-items: center;
284
- text-decoration: none;
285
- cursor: pointer;
286
- background-color: var(--pagination-bg);
287
- transition: color .15s ease-in-out, background-color .15s ease-in-out, border-color .15s ease-in-out, box-shadow .15s ease-in-out;
288
-
289
- &.previous, &.next {
290
- display: none;
291
- }
292
-
293
- &:first-child {
294
- border-style: solid;
295
- border-top-left-radius: var(--pagination-border-radius);
296
- border-bottom-left-radius: var(--pagination-border-radius);
297
- }
298
- &:last-child {
299
- border-top-right-radius: var(--pagination-border-radius);
300
- border-bottom-right-radius: var(--pagination-border-radius);
301
- }
302
-
303
- &:hover {
304
- z-index: 2;
305
- color: var(--pagination-hover-color);
306
- text-decoration: none;
307
- background-color: var(--pagination-hover-bg);
308
- border-color: var(--pagination-hover-border-color);
309
- }
310
-
311
- &:focus {
312
- z-index: 3;
313
- color: var(--pagination-focus-color);
314
- background-color: var(--pagination-focus-bg);
315
- outline: 0;
316
- box-shadow: var(--pagination-focus-box-shadow);
317
- }
318
-
319
- &.current {
320
- z-index: 3;
321
- color: var(--pagination-active-color);
322
- background-color: var(--pagination-active-bg);
323
- border-color: var(--pagination-active-border-color);
324
- }
325
-
326
- &.disabled,
327
- .disabled > & {
328
- color: var(--pagination-disabled-color);
329
- pointer-events: none;
330
- background-color: var(--pagination-disabled-bg);
331
- border-color: var(--pagination-disabled-border-color);
332
- }
333
- }
334
-
335
- .page-item {
336
- &:not(:first-child) .page-link {
337
- margin-left: calc(-1 * var(--pagination-border-width));
338
- }
339
-
340
- &:first-child {
341
- .page-link {
342
- border-radius: var(--pagination-border-radius) 0 0 var(--pagination-border-radius);
343
- }
344
- }
345
-
346
- &:last-child {
347
- .page-link {
348
- border-radius: 0 var(--pagination-border-radius) var(--pagination-border-radius) 0;
349
- }
350
- }
351
-
352
- }
353
-
354
-
355
- }
@@ -1,154 +0,0 @@
1
- /* global process */
2
-
3
- import 'jquery?as_asset';
4
- import 'datatables.net/js/jquery.dataTables.js?as_asset';
5
-
6
- import { spinner } from '@minimo/spinner.js';
7
- import svg_icons from '@imgs/icone.svg';
8
-
9
- import { creaDT } from '@massimo-cassandro/auto-datatables-bs5';
10
- import './auto-datatable.css?inline';
11
- /*
12
- per personalizzazioni datatable
13
- da usare insieme alle opzioni globali
14
-
15
- import {default_dt_options} from 'path/to/datatable.js';
16
- import { dt_default_options, dt_classes } from '@massimo-cassandro/auto-datatables-bs5';
17
-
18
- $.extend( $.fn.dataTable.ext.classes, dt_classes );
19
- $(__table__).DataTable($.extend(true, {}, dt_default_options, ada_default_dt_options,
20
-
21
- // opzioni specifiche, se necessarie, ad esempio per tabelle non ajax:
22
- {
23
- processing : false,
24
- serverSide : false,
25
- pageLength : 25,
26
- order : [[ 1, 'asc' ]],
27
- columns : null
28
- }
29
- ));
30
-
31
- */
32
-
33
- export const default_dt_options = {
34
-
35
- dom:
36
- // controlli
37
- '<\'dt-controls\'lf>' +
38
- // table + processing
39
- //"<'position-relative'tr>" +
40
- // table + processing
41
- '<\'dt-table-wrapper\'t>r' +
42
- // info + paginazione
43
- '<\'dt-footer\'ip>',
44
-
45
- // renderer: 'bootstrap',
46
-
47
- // serverSide : true,
48
- // paging : true,
49
- // pageLength : 25,
50
- language: {
51
- processing: spinner(),
52
-
53
- lengthMenu:
54
- '<di class"dt-control-label">Mostra</di>' +
55
- '<div class="dt-control">_MENU_</div>' +
56
- '<div>record per pagina</div>',
57
- search:
58
- '<div class="dt-control-label">Filtra risultati:</div>' +
59
- '<div class="dt-control">_INPUT_</div>',
60
- },
61
-
62
- responsive : true,
63
- stateSave : process.env.NODE_ENV === 'development',
64
- stateDuration : -1, //sessionStorage
65
- // columnDefs : [{
66
- // orderable : true,
67
- // targets : ['_all']
68
- // }],
69
- // ajax : null,
70
- // order : [],
71
- // columns : []
72
- }, // end dt_options
73
-
74
- default_cdt_options = {
75
-
76
- icone: {
77
- ok : `<svg class="icon text-success"><use href="${svg_icons}#check-circle-bold"></use></svg>`,
78
- off : `<svg class="icon text-danger"><use href="${svg_icons}#x-circle-bold"></use></svg>`,
79
- },
80
-
81
- id_visible_default: true,
82
-
83
- formats: {
84
- decimals_class: 'data-dec',
85
- euro_class: 'data-euro',
86
-
87
- date: {
88
- year: '2-digit',
89
- month: 'short',
90
- day: 'numeric'
91
- },
92
- time: {
93
- hour12: false,
94
- hour: '2-digit',
95
- minute: '2-digit'
96
- },
97
- datetime: {
98
- date: {
99
- year: 'numeric',
100
- month: 'short',
101
- day: 'numeric'
102
- },
103
- time: {
104
- hour12: false,
105
- hour: '2-digit',
106
- minute: '2-digit'
107
- },
108
- separator: ' ', // date-time separator
109
- date_wrapper: '<span class="text-nowrap"></span>', // HTML string or null or ''
110
- time_wrapper: '<small></small>' // HTML string or null or ''
111
- }
112
- },
113
-
114
- use_sorting_arrow: false, // se true viene aggiunta al container la classe `w-arrow` che attiva la visualizzazione delle frecce dell'ordinamento
115
-
116
- // container_header: '', //'Risultato della ricerca', // se presente aggiunge un header prima della tabella
117
-
118
- // container_class: 'dt-container', // classe che viene assegnata al div che contiene la tabella
119
- //container_header_level: 2, // livello gerarchico dell'header (h2, h3, ecc...)
120
- // table_id: 'table_result',
121
- table_class: 'table table-bordered'
122
- //table_caption: '',
123
- //table_footer: false, // se true aggiunge una riga tfoot alla tabella, da popolare con un callback
124
- //extra_info:''
125
- }
126
- ;
127
-
128
- /**
129
- * _datatable
130
- * crea e renderizza un datatable da un flusso json
131
- *
132
- */
133
-
134
- export function _datatable(container, options = {}) {
135
-
136
- options.dt_options = {...default_dt_options, ...(options.dt_options?? {}) };
137
- options.cdt_options = {...default_cdt_options, ...(options.cdt_options?? {}) };
138
-
139
- container.innerHTML = '<div class="datatable-spinner-wrapper">' +
140
- spinner() +
141
- '</div>';
142
-
143
- creaDT(container, options.cdt_options, options.dt_options, options.dt_columns?? []);
144
- }
145
-
146
-
147
- // utilizza _datatable per generare in modo automatico i datatable
148
- // negli elementi con classe 'dt-container'
149
- // i parametri datatable sono ricavati dagli attributi data di '.dt-container'
150
-
151
- document.querySelectorAll('.dt-container').forEach(container => {
152
- _datatable(container);
153
- });
154
-
@@ -1,47 +0,0 @@
1
- import { decodeBlurHash } from 'fast-blurhash';
2
-
3
- // https://github.com/mad-gooze/fast-blurhash
4
- // https://github.com/woltapp/blurhash/tree/master/TypeScript
5
- // https://blurha.sh/
6
-
7
- /**
8
- * restituisce un elemento canvas della stringa blurhash indicata
9
- *
10
- * @param {string} str - blurhash string
11
- * @param {number} width
12
- * @param {number} height
13
- * @returns HTMLElement
14
- */
15
-
16
- export function createBlurhashCanvas({str, width, height, className = null}) {
17
-
18
- try {
19
-
20
- if(str && width && height) {
21
- // decode blurHash image
22
- const pixels = decodeBlurHash(str, width, height),
23
-
24
- // draw it on canvas
25
- canvas = document.createElement('canvas'),
26
- ctx = canvas.getContext('2d'),
27
- imageData = ctx.createImageData(width, height);
28
-
29
- if(className) {
30
- canvas.className = className;
31
- }
32
-
33
- canvas.width = width;
34
- canvas.height = height;
35
- imageData.data.set(pixels);
36
- ctx.putImageData(imageData, 0, 0);
37
-
38
- return canvas;
39
- }
40
-
41
- } catch(e) {
42
- /* eslint-disable no-console */
43
- console.error( e );
44
- /* eslint-enable no-console */
45
- }
46
-
47
- }