@simple-reporting/base 1.0.22 → 1.0.24

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 (57) hide show
  1. package/dev/index.html +1 -1
  2. package/dev/livingdocs.config.json +6 -6
  3. package/dev/package.json +1 -1
  4. package/dev/src/Dialog.vue +3 -0
  5. package/dev/src/assets/scss/general.scss +1 -0
  6. package/dev/src/assets/scss/pdf.scss +13 -0
  7. package/dev/src/entries/pdf.ts +14 -1
  8. package/dev/srl.config.json +21 -0
  9. package/livingdocs/040.Media/010.table/scss/pdf.scss +20 -0
  10. package/livingdocs/080.CV/010.cv/cv.html +34 -32
  11. package/livingdocs/100.Misc/010.anchor/anchor.html +1 -1
  12. package/livingdocs/100.Misc/020.accordion/accordion.html +7 -5
  13. package/livingdocs/110.PDF/100.pdf-toc-item/scss/general.scss +1 -1
  14. package/package.json +2 -1
  15. package/scripts/beaver.js +14 -18
  16. package/scripts/build/variables.d.ts +6 -0
  17. package/scripts/build/variables.js +6 -0
  18. package/scripts/build.js +56 -16
  19. package/scripts/dotenv.d.ts +1 -0
  20. package/scripts/dotenv.js +8 -0
  21. package/scripts/init.js +1 -1
  22. package/scripts/ldd/mapLdd.js +2 -2
  23. package/scripts/utils.d.ts +1 -0
  24. package/scripts/utils.js +22 -0
  25. package/scss/colors/functions.scss +2 -10
  26. package/scss/colors/mixins.scss +0 -18
  27. package/scss/colors/root.scss +10 -0
  28. package/scss/core-styles.scss +4 -1
  29. package/scss/fonts/root.scss +4 -0
  30. package/scss/grid/functions.scss +8 -6
  31. package/scss/grid/mixins.scss +0 -77
  32. package/scss/grid/root.scss +80 -0
  33. package/scss/helpers/root.scss +4 -0
  34. package/scss/init-root.scss +12 -0
  35. package/scss/meta/root.scss +4 -0
  36. package/scss/spacer/functions.scss +2 -1
  37. package/scss/spacer/mixins.scss +0 -52
  38. package/scss/spacer/root.scss +55 -0
  39. package/scss/system/functions.scss +70 -5
  40. package/scss/system/root.scss +0 -3
  41. package/scss/system/variables.scss +1 -0
  42. package/scss/typography/functions.scss +12 -12
  43. package/scss/typography/mixins.scss +0 -221
  44. package/scss/typography/root.scss +226 -0
  45. package/srl/.srl/App.vue +9 -5
  46. package/srl/.srl/components/Srl/Article/Accordion.vue +106 -0
  47. package/srl/.srl/components/Srl/Article/Dialog/Button.vue +39 -18
  48. package/srl/.srl/components/Srl/Category/Accordion.vue +32 -4
  49. package/srl/.srl/components/Srl/Page/Dialog.vue +17 -19
  50. package/srl/.srl/plugins/initProject.ts +12 -7
  51. package/srl/.srl/utils/html.ts +71 -62
  52. package/srl/.srl/utils/index.ts +28 -1
  53. package/srl/.srl/utils/pageState.ts +61 -0
  54. package/srl/srl/pdf/PDFNotes.ts +71 -0
  55. package/srl/srl/pdf/PDFSetPageNumbers.ts +25 -0
  56. package/srl/srl/pdf.scss +0 -2
  57. /package/srl/srl/{Awesomizr.js → pdf/Awesomizr.js} +0 -0
@@ -44,223 +44,6 @@
44
44
  }
45
45
  }
46
46
 
47
- @mixin _register-typo-variables(
48
- $typo,
49
- $map,
50
- $media: false,
51
- $mediaBehavior: false
52
- ) {
53
- @if not $media {
54
- $defaults: map.merge(
55
- (
56
- font-family: unset,
57
- font-size: unset,
58
- line-height: unset,
59
- font-style: normal,
60
- font-weight: unset,
61
- letter-spacing: unset,
62
- margin-top: 0,
63
- margin-bottom: 0,
64
- ),
65
- $map
66
- );
67
-
68
- @if (map.has-key($map, font-family)) {
69
- @include system.add-root-style(
70
- #{variables.$variable-prefix}typo-#{$typo}-font-family,
71
- string.unquote(map.get($defaults, font-family))
72
- );
73
- }
74
-
75
- @include system.add-root-style(
76
- #{variables.$variable-prefix}typo-#{$typo}-font-size,
77
- system.size-unit(map.get($defaults, font-size))
78
- );
79
-
80
- @include system.add-root-style(
81
- #{variables.$variable-prefix}typo-#{$typo}-line-height,
82
- system.size-unit(map.get($defaults, line-height), em)
83
- );
84
-
85
- @include system.add-root-style(
86
- #{variables.$variable-prefix}typo-#{$typo}-font-style,
87
- string.unquote(map.get($defaults, font-style))
88
- );
89
-
90
- @include system.add-root-style(
91
- #{variables.$variable-prefix}typo-#{$typo}-font-weight,
92
- map.get($defaults, font-weight)
93
- );
94
-
95
- @if (map.has-key($map, color)) {
96
- @include system.add-root-style(
97
- #{variables.$variable-prefix}typo-#{$typo}-font-color,
98
- colors.get(map.get($defaults, color))
99
- );
100
- }
101
-
102
- @if (map.has-key($map, letter-spacing)) {
103
- @include system.add-root-style(
104
- #{variables.$variable-prefix}typo-#{$typo}-letter-spacing,
105
- system.size-unit(map.get($defaults, letter-spacing))
106
- );
107
- }
108
-
109
- @if (map.has-key($map, text-transform)) {
110
- @include system.add-root-style(
111
- #{variables.$variable-prefix}typo-#{$typo}-text-transform,
112
- map.get($defaults, text-transform)
113
- );
114
- }
115
-
116
- @include system.add-root-style(
117
- #{variables.$variable-prefix}typo-#{$typo}-margin-top,
118
- system.size-unit(map.get($defaults, margin-top))
119
- );
120
-
121
- @include system.add-root-style(
122
- #{variables.$variable-prefix}typo-#{$typo}-margin-bottom,
123
- system.size-unit(map.get($defaults, margin-bottom))
124
- );
125
-
126
- @if map.has-key($map, media) {
127
- @each $breakpoint, $breakpointValue in map.get($map, media) {
128
- @if $breakpoint == up {
129
- @each $upBreakpoint, $upBreakpointValue in $breakpointValue {
130
- @include _register-typo-variables(
131
- $typo,
132
- $upBreakpointValue,
133
- $upBreakpoint,
134
- up
135
- );
136
- }
137
- } @else if $breakpoint == down {
138
- @each $downBreakpoint, $downBreakpointValue in $breakpointValue {
139
- @include _register-typo-variables(
140
- $typo,
141
- $downBreakpointValue,
142
- $downBreakpoint,
143
- down
144
- );
145
- }
146
- } @else {
147
- @include _register-typo-variables(
148
- $typo,
149
- $breakpointValue,
150
- $breakpoint
151
- );
152
- }
153
- }
154
- }
155
- } @else {
156
- @if (map.has-key($map, font-family)) {
157
- @include system.add-root-style(
158
- #{variables.$variable-prefix}typo-#{$typo}-font-family,
159
- string.unquote(map.get($map, font-family)),
160
- $media,
161
- $mediaBehavior
162
- );
163
- }
164
-
165
- @if (map.has-key($map, font-size)) {
166
- @include system.add-root-style(
167
- #{variables.$variable-prefix}typo-#{$typo}-font-size,
168
- system.size-unit(map.get($map, font-size)),
169
- $media,
170
- $mediaBehavior
171
- );
172
- }
173
-
174
- @if map.has-key($map, line-height) {
175
- @include system.add-root-style(
176
- #{variables.$variable-prefix}typo-#{$typo}-line-height,
177
- system.size-unit(map.get($map, line-height), em),
178
- $media,
179
- $mediaBehavior
180
- );
181
- }
182
-
183
- @if map.has-key($map, font-style) {
184
- @include system.add-root-style(
185
- #{variables.$variable-prefix}typo-#{$typo}-font-style,
186
- string.unquote(map.get($map, font-style)),
187
- $media,
188
- $mediaBehavior
189
- );
190
- }
191
-
192
- @if map.has-key($map, font-weight) {
193
- @include system.add-root-style(
194
- #{variables.$variable-prefix}typo-#{$typo}-font-weight,
195
- map.get($map, font-weight),
196
- $media,
197
- $mediaBehavior
198
- );
199
- }
200
-
201
- @if (map.has-key($map, color)) {
202
- @include system.add-root-style(
203
- #{variables.$variable-prefix}typo-#{$typo}-font-color,
204
- colors.get(map.get($defaults, color))
205
- );
206
- }
207
-
208
- @if (map.has-key($map, letter-spacing)) {
209
- @include system.add-root-style(
210
- #{variables.$variable-prefix}typo-#{$typo}-letter-spacing,
211
- system.size-unit(map.get($defaults, letter-spacing)),
212
- $media,
213
- $mediaBehavior
214
- );
215
- }
216
-
217
- @if (map.has-key($map, text-transform)) {
218
- @include system.add-root-style(
219
- #{variables.$variable-prefix}typo-#{$typo}-text-transform,
220
- map.get($defaults, text-transform),
221
- $media,
222
- $mediaBehavior
223
- );
224
- }
225
-
226
- @if map.has-key($map, margin-top) {
227
- @if $media == print {
228
- @include system.add-root-style(
229
- #{variables.$variable-prefix}typo-#{$typo}-margin-top,
230
- system.size-unit(map.get($map, margin-top), in),
231
- $media,
232
- $mediaBehavior
233
- );
234
- } @else {
235
- @include system.add-root-style(
236
- #{variables.$variable-prefix}typo-#{$typo}-margin-top,
237
- system.size-unit(map.get($map, margin-top)),
238
- $media,
239
- $mediaBehavior
240
- );
241
- }
242
- }
243
-
244
- @if map.has-key($map, margin-bottom) {
245
- @if $media == print {
246
- @include system.add-root-style(
247
- #{variables.$variable-prefix}typo-#{$typo}-margin-bottom,
248
- system.size-unit(map.get($map, margin-bottom), in),
249
- $media,
250
- $mediaBehavior
251
- );
252
- } @else {
253
- @include system.add-root-style(
254
- #{variables.$variable-prefix}typo-#{$typo}-margin-bottom,
255
- system.size-unit(map.get($map, margin-bottom)),
256
- $media,
257
- $mediaBehavior
258
- );
259
- }
260
- }
261
- }
262
- }
263
-
264
47
  @mixin set-font-family($typo, $value) {
265
48
  --#{variables.$variable-prefix}typo-#{$typo}-font-family: #{string.unquote(
266
49
  $value
@@ -312,10 +95,6 @@
312
95
  )};
313
96
  }
314
97
 
315
- @each $typo, $values in variables.$typography {
316
- @include _register-typo-variables($typo, $values);
317
- }
318
-
319
98
  @mixin core-styles {
320
99
  @each $typo, $values in variables.$typography {
321
100
  .#{variables.$class-prefix}typo-#{'' + $typo} {
@@ -0,0 +1,226 @@
1
+ @use "sass:map";
2
+ @use "sass:string";
3
+ @use "variables";
4
+ @use "../colors";
5
+ @use "../system";
6
+
7
+ @mixin _register-typo-variables(
8
+ $typo,
9
+ $map,
10
+ $media: false,
11
+ $mediaBehavior: false
12
+ ) {
13
+ @if not $media {
14
+ $defaults: map.merge(
15
+ (
16
+ font-family: unset,
17
+ font-size: unset,
18
+ line-height: unset,
19
+ font-style: normal,
20
+ font-weight: unset,
21
+ letter-spacing: unset,
22
+ margin-top: 0,
23
+ margin-bottom: 0,
24
+ ),
25
+ $map
26
+ );
27
+
28
+ @if (map.has-key($map, font-family)) {
29
+ @include system.add-root-style(
30
+ #{variables.$variable-prefix}typo-#{$typo}-font-family,
31
+ string.unquote(map.get($defaults, font-family))
32
+ );
33
+ }
34
+
35
+ @include system.add-root-style(
36
+ #{variables.$variable-prefix}typo-#{$typo}-font-size,
37
+ system.size-unit(map.get($defaults, font-size))
38
+ );
39
+
40
+ @include system.add-root-style(
41
+ #{variables.$variable-prefix}typo-#{$typo}-line-height,
42
+ system.size-unit(map.get($defaults, line-height), em)
43
+ );
44
+
45
+ @include system.add-root-style(
46
+ #{variables.$variable-prefix}typo-#{$typo}-font-style,
47
+ string.unquote(map.get($defaults, font-style))
48
+ );
49
+
50
+ @include system.add-root-style(
51
+ #{variables.$variable-prefix}typo-#{$typo}-font-weight,
52
+ map.get($defaults, font-weight)
53
+ );
54
+
55
+ @if (map.has-key($map, color)) {
56
+ @include system.add-root-style(
57
+ #{variables.$variable-prefix}typo-#{$typo}-font-color,
58
+ colors.get(map.get($defaults, color))
59
+ );
60
+ }
61
+
62
+ @if (map.has-key($map, letter-spacing)) {
63
+ @include system.add-root-style(
64
+ #{variables.$variable-prefix}typo-#{$typo}-letter-spacing,
65
+ system.size-unit(map.get($defaults, letter-spacing))
66
+ );
67
+ }
68
+
69
+ @if (map.has-key($map, text-transform)) {
70
+ @include system.add-root-style(
71
+ #{variables.$variable-prefix}typo-#{$typo}-text-transform,
72
+ map.get($defaults, text-transform)
73
+ );
74
+ }
75
+
76
+ @include system.add-root-style(
77
+ #{variables.$variable-prefix}typo-#{$typo}-margin-top,
78
+ system.size-unit(map.get($defaults, margin-top))
79
+ );
80
+
81
+ @include system.add-root-style(
82
+ #{variables.$variable-prefix}typo-#{$typo}-margin-bottom,
83
+ system.size-unit(map.get($defaults, margin-bottom))
84
+ );
85
+
86
+ @if map.has-key($map, media) {
87
+ @each $breakpoint, $breakpointValue in map.get($map, media) {
88
+ @if $breakpoint == up {
89
+ @each $upBreakpoint, $upBreakpointValue in $breakpointValue {
90
+ @include _register-typo-variables(
91
+ $typo,
92
+ $upBreakpointValue,
93
+ $upBreakpoint,
94
+ up
95
+ );
96
+ }
97
+ } @else if $breakpoint == down {
98
+ @each $downBreakpoint, $downBreakpointValue in $breakpointValue {
99
+ @include _register-typo-variables(
100
+ $typo,
101
+ $downBreakpointValue,
102
+ $downBreakpoint,
103
+ down
104
+ );
105
+ }
106
+ } @else {
107
+ @include _register-typo-variables(
108
+ $typo,
109
+ $breakpointValue,
110
+ $breakpoint
111
+ );
112
+ }
113
+ }
114
+ }
115
+ } @else {
116
+ @if (map.has-key($map, font-family)) {
117
+ @include system.add-root-style(
118
+ #{variables.$variable-prefix}typo-#{$typo}-font-family,
119
+ string.unquote(map.get($map, font-family)),
120
+ $media,
121
+ $mediaBehavior
122
+ );
123
+ }
124
+
125
+ @if (map.has-key($map, font-size)) {
126
+ @include system.add-root-style(
127
+ #{variables.$variable-prefix}typo-#{$typo}-font-size,
128
+ system.size-unit(map.get($map, font-size)),
129
+ $media,
130
+ $mediaBehavior
131
+ );
132
+ }
133
+
134
+ @if map.has-key($map, line-height) {
135
+ @include system.add-root-style(
136
+ #{variables.$variable-prefix}typo-#{$typo}-line-height,
137
+ system.size-unit(map.get($map, line-height), em),
138
+ $media,
139
+ $mediaBehavior
140
+ );
141
+ }
142
+
143
+ @if map.has-key($map, font-style) {
144
+ @include system.add-root-style(
145
+ #{variables.$variable-prefix}typo-#{$typo}-font-style,
146
+ string.unquote(map.get($map, font-style)),
147
+ $media,
148
+ $mediaBehavior
149
+ );
150
+ }
151
+
152
+ @if map.has-key($map, font-weight) {
153
+ @include system.add-root-style(
154
+ #{variables.$variable-prefix}typo-#{$typo}-font-weight,
155
+ map.get($map, font-weight),
156
+ $media,
157
+ $mediaBehavior
158
+ );
159
+ }
160
+
161
+ @if (map.has-key($map, color)) {
162
+ @include system.add-root-style(
163
+ #{variables.$variable-prefix}typo-#{$typo}-font-color,
164
+ colors.get(map.get($defaults, color))
165
+ );
166
+ }
167
+
168
+ @if (map.has-key($map, letter-spacing)) {
169
+ @include system.add-root-style(
170
+ #{variables.$variable-prefix}typo-#{$typo}-letter-spacing,
171
+ system.size-unit(map.get($defaults, letter-spacing)),
172
+ $media,
173
+ $mediaBehavior
174
+ );
175
+ }
176
+
177
+ @if (map.has-key($map, text-transform)) {
178
+ @include system.add-root-style(
179
+ #{variables.$variable-prefix}typo-#{$typo}-text-transform,
180
+ map.get($defaults, text-transform),
181
+ $media,
182
+ $mediaBehavior
183
+ );
184
+ }
185
+
186
+ @if map.has-key($map, margin-top) {
187
+ @if $media == print {
188
+ @include system.add-root-style(
189
+ #{variables.$variable-prefix}typo-#{$typo}-margin-top,
190
+ system.size-unit(map.get($map, margin-top), in),
191
+ $media,
192
+ $mediaBehavior
193
+ );
194
+ } @else {
195
+ @include system.add-root-style(
196
+ #{variables.$variable-prefix}typo-#{$typo}-margin-top,
197
+ system.size-unit(map.get($map, margin-top)),
198
+ $media,
199
+ $mediaBehavior
200
+ );
201
+ }
202
+ }
203
+
204
+ @if map.has-key($map, margin-bottom) {
205
+ @if $media == print {
206
+ @include system.add-root-style(
207
+ #{variables.$variable-prefix}typo-#{$typo}-margin-bottom,
208
+ system.size-unit(map.get($map, margin-bottom), in),
209
+ $media,
210
+ $mediaBehavior
211
+ );
212
+ } @else {
213
+ @include system.add-root-style(
214
+ #{variables.$variable-prefix}typo-#{$typo}-margin-bottom,
215
+ system.size-unit(map.get($map, margin-bottom)),
216
+ $media,
217
+ $mediaBehavior
218
+ );
219
+ }
220
+ }
221
+ }
222
+ }
223
+
224
+ @each $typo, $values in variables.$typography {
225
+ @include _register-typo-variables($typo, $values);
226
+ }
package/srl/.srl/App.vue CHANGED
@@ -36,20 +36,24 @@
36
36
  * to other components in the application.
37
37
  */
38
38
  import App from '@/App.vue';
39
- import { watch } from 'vue'
39
+ import { onMounted, watch } from 'vue'
40
40
  import { useCssStyles } from '#composables'
41
+ import { setMounted } from '#utils'
41
42
 
42
- const styleElement = document.createElement('style');
43
- document.head.appendChild(styleElement);
43
+ const styleElement = document.createElement('style')
44
+ document.head.appendChild(styleElement)
44
45
 
45
- const styleContent = useCssStyles();
46
+ const styleContent = useCssStyles()
46
47
  watch(
47
48
  styleContent.value,
48
49
  (newStyles) => {
49
- styleElement.innerHTML = newStyles.join('');
50
+ styleElement.innerHTML = newStyles.join('')
50
51
  },
51
52
  { immediate: true },
52
53
  );
54
+ onMounted(() => {
55
+ setMounted(true)
56
+ });
53
57
  </script>
54
58
 
55
59
  <template>
@@ -0,0 +1,106 @@
1
+ <script setup lang="ts">
2
+ import {computed, onMounted, ref, useId} from 'vue'
3
+ import { useRoute } from 'vue-router'
4
+ import { isAccordionAnchored, setAccordionAnchored } from '#utils'
5
+
6
+ const props = withDefaults(defineProps<{
7
+ toggleSelector?: string
8
+ contentSelector?: string
9
+ wrapperSelector?: string
10
+ openClass?: string
11
+ duration?: number
12
+ }>(), {
13
+ toggleSelector: '.srl-article-accordion__toggle',
14
+ contentSelector: '.srl-article-accordion__content',
15
+ wrapperSelector: '.srl-article-accordion__wrapper',
16
+ openClass: 'open',
17
+ duration: 300,
18
+ })
19
+
20
+ const route = useRoute()
21
+
22
+ const id = useId()
23
+ const rootEl = ref<HTMLDivElement>()
24
+ const toggle = ref<HTMLButtonElement>()
25
+ const content = ref<HTMLDivElement>()
26
+ const wrapper = ref<HTMLDivElement>()
27
+ const transition = computed<string>(() => {
28
+ return props.duration + 'ms'
29
+ })
30
+
31
+ function open() {
32
+ toggle.value?.setAttribute('aria-expanded', 'true')
33
+ wrapper.value?.removeAttribute('hidden')
34
+ content.value?.classList.add(props.openClass)
35
+ content.value.focus()
36
+ }
37
+
38
+ function close() {
39
+ toggle.value?.setAttribute('aria-expanded', 'false')
40
+ content.value?.classList.remove(props.openClass)
41
+ setTimeout(() => {
42
+ wrapper.value?.setAttribute('hidden', 'true')
43
+ }, props.duration)
44
+ }
45
+
46
+ onMounted(() => {
47
+ toggle.value = rootEl.value?.querySelector( props.toggleSelector ) || undefined
48
+ content.value = rootEl.value?.querySelector( props.contentSelector ) || undefined
49
+ wrapper.value = rootEl.value?.querySelector( props.wrapperSelector ) || undefined
50
+
51
+ if (toggle.value && content.value && wrapper.value) {
52
+ wrapper.value.setAttribute('hidden', 'true')
53
+ content.value.id = id
54
+ content.value.setAttribute('tabindex', '-1')
55
+ toggle.value.setAttribute('aria-controls', id)
56
+
57
+ toggle.value.addEventListener('click', () => {
58
+ toggle.value?.getAttribute('aria-expanded') === 'true' ? close() : open()
59
+ })
60
+
61
+ if (route.hash) {
62
+ if (rootEl.value.id && rootEl.value.id === route.hash) {
63
+ open()
64
+ isAccordionAnchored() || setAccordionAnchored(true)
65
+ } else {
66
+ const targetEl = rootEl.value?.querySelector<HTMLElement>(route.hash)
67
+ if (targetEl) {
68
+ open()
69
+ if (!isAccordionAnchored()) {
70
+ setAccordionAnchored(true)
71
+ setTimeout(() => {
72
+ rootEl.value?.scrollIntoView({
73
+ behavior: 'smooth',
74
+ block: 'start',
75
+ })
76
+ }, 200)
77
+ }
78
+ }
79
+ }
80
+ }
81
+ }
82
+ })
83
+ </script>
84
+
85
+ <template>
86
+ <div class="srl-article-accordion" ref="rootEl" tabindex="-1">
87
+ <slot/>
88
+ </div>
89
+ </template>
90
+
91
+ <style lang="scss">
92
+ .srl-article-accordion {
93
+ &__content {
94
+ display: grid;
95
+ grid-template-rows: 0fr;
96
+ transition: grid-template-rows v-bind(transition) ease-out;
97
+
98
+ &.open {
99
+ grid-template-rows: 1fr;
100
+ }
101
+ }
102
+ &__wrapper {
103
+ overflow: hidden;
104
+ }
105
+ }
106
+ </style>
@@ -1,17 +1,32 @@
1
1
  <script setup lang="ts">
2
- import { ref, useId } from 'vue';
2
+ import { computed, ref } from 'vue'
3
3
  import { useArticles, useConfig } from '#composables';
4
- import { prepareHtmlContent } from '#utils';
4
+ import { prepareHtmlContent, isDialogStored, addDialogToStorage, getDialogFromStorage } from '#utils';
5
5
 
6
6
  const props = defineProps<{
7
7
  uuid: string;
8
+ anchor?: string;
8
9
  }>();
9
10
 
10
11
  const config = useConfig();
11
12
  const articles = useArticles();
12
- const id = ref<string>(`srl-page__dialog-${useId()}`);
13
+ const id = ref<string>(`srl-page__dialog-${props.uuid.replaceAll(' ', '_')}`);
13
14
  const content = ref<string>('');
14
- const dialog = ref<SrlPageDialog | null>(null);
15
+
16
+ const dialog = isDialogStored(props.uuid)?
17
+ getDialogFromStorage(props.uuid):
18
+ ref<SrlPageDialog | null>(null);
19
+
20
+ if (!isDialogStored(props.uuid)) {
21
+ addDialogToStorage(props.uuid, dialog);
22
+ loadContent();
23
+ }
24
+
25
+ const state = computed<boolean>(() => {
26
+ return dialog.value ?
27
+ dialog.value.dialogState : false
28
+ });
29
+
15
30
  async function loadContent() {
16
31
  const article = articles.value.find((article) => article.uuid === props.uuid);
17
32
  if (article) {
@@ -20,35 +35,41 @@ async function loadContent() {
20
35
  const req = await fetch(file);
21
36
  const text = await req.text();
22
37
  content.value = prepareHtmlContent(text);
38
+ // Do something with anchor if provided
39
+ /*
40
+ if (props.anchor) {
41
+ nextTick(() => {
42
+ // Do action
43
+ });
44
+ }
45
+ */
23
46
  } catch (error) {
24
47
  console.error(`Failed to load article content from ${file}:`, error);
25
48
  }
26
49
  }
27
50
  }
28
51
 
29
- loadContent();
30
52
  async function open() {
31
- dialog.value.open();
53
+ dialog.value?.open();
32
54
  }
33
55
  </script>
34
56
 
35
57
  <template>
36
58
  <button
37
- class="srl-dialog-button"
38
- type="button"
39
- :aria-controls="id"
40
- aria-haspopup="dialog"
41
- :aria-expanded="dialog?.dialogState ?? false"
42
- @click="open"
59
+ class="srl-dialog-button"
60
+ type="button"
61
+ :aria-controls="id"
62
+ aria-haspopup="dialog"
63
+ :aria-expanded="state"
64
+ @click="open"
43
65
  >
44
66
  <slot />
45
- <Teleport to="body">
67
+ <Teleport v-if="content" to="body">
46
68
  <SrlPageDialog
47
- v-if="content"
48
- :id="id"
49
- ref="dialog"
50
- :content="content"
51
- @close="expanded = false"
69
+ :id="id"
70
+ ref="dialog"
71
+ :content="content"
72
+ @close="expanded = false"
52
73
  />
53
74
  </Teleport>
54
75
  </button>