@d0rich/esprit-design 0.2.1 → 0.2.3

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 (85) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/dist/components/DChip.vue.d.ts +2 -0
  3. package/dist/components/DPagination.vue.d.ts +30 -0
  4. package/dist/components/DStats.vue.d.ts +27 -0
  5. package/dist/components/animations/DAnimationAccordion.vue.d.ts +23 -0
  6. package/dist/components/animations/DAnimationDefLetterD.vue.d.ts +2 -0
  7. package/dist/components/animations/DAnimationFloatingLetter.vue.d.ts +23 -0
  8. package/dist/components/animations/DAnimationHypnosis.vue.d.ts +23 -0
  9. package/dist/components/animations/DAnimationSpinner.vue.d.ts +23 -0
  10. package/dist/components/animations/index.d.ts +5 -0
  11. package/dist/components/buttons/DBigBangButton.vue.d.ts +35 -0
  12. package/dist/components/buttons/DBigBangButtonAnimation.vue.d.ts +2 -0
  13. package/dist/components/buttons/DBtn.vue.d.ts +97 -0
  14. package/dist/components/buttons/index.d.ts +4 -0
  15. package/dist/components/cards/DCard.vue.d.ts +24 -0
  16. package/dist/components/cards/DCardTitle.vue.d.ts +2 -0
  17. package/dist/components/cards/index.d.ts +3 -0
  18. package/dist/components/content/DAlert.vue.d.ts +21 -0
  19. package/dist/components/content/DQuote.vue.d.ts +21 -0
  20. package/dist/components/content/index.d.ts +3 -0
  21. package/dist/components/index.d.ts +10 -0
  22. package/dist/components/lists/DActionsFan.vue.d.ts +55 -0
  23. package/dist/components/lists/DActionsList.vue.d.ts +50 -0
  24. package/dist/components/lists/index.d.ts +3 -0
  25. package/dist/components/utils/DWrapBackground.vue.d.ts +68 -0
  26. package/dist/components/utils/DWrapFocusHighlight.vue.d.ts +67 -0
  27. package/dist/components/utils/DWrapShape.vue.d.ts +33 -0
  28. package/dist/components/utils/index.d.ts +4 -0
  29. package/dist/composables/big-bang-button-utils.d.ts +3 -0
  30. package/dist/composables/index.d.ts +2 -0
  31. package/dist/composables/router.d.ts +17 -0
  32. package/dist/composables/utils.d.ts +4 -0
  33. package/dist/esprit-design.js +4595 -0
  34. package/dist/esprit-design.umd.cjs +17 -0
  35. package/dist/index.d.ts +3 -0
  36. package/dist/style.css +1 -0
  37. package/dist/utils/boundings.d.ts +16 -0
  38. package/dist/utils/index.d.ts +3 -0
  39. package/dist/utils/pagination.d.ts +1 -0
  40. package/dist/utils/polygon-animation.d.ts +53 -0
  41. package/index.html +13 -0
  42. package/package.json +1 -4
  43. package/plugins/shadows.js +87 -0
  44. package/src/components/DChip.vue +32 -0
  45. package/src/components/DPagination.vue +91 -0
  46. package/src/components/DStats.vue +502 -0
  47. package/src/components/animations/DAnimationAccordion.vue +103 -0
  48. package/src/components/animations/DAnimationDefLetterD.vue +11 -0
  49. package/src/components/animations/DAnimationFloatingLetter.vue +58 -0
  50. package/src/components/animations/DAnimationHypnosis.vue +102 -0
  51. package/src/components/animations/DAnimationSpinner.vue +114 -0
  52. package/src/components/animations/index.ts +11 -0
  53. package/src/components/buttons/DBigBangButton.vue +70 -0
  54. package/src/components/buttons/DBigBangButtonAnimation.vue +117 -0
  55. package/src/components/buttons/DBtn.vue +106 -0
  56. package/src/components/buttons/index.ts +5 -0
  57. package/src/components/cards/DCard.vue +98 -0
  58. package/src/components/cards/DCardTitle.vue +67 -0
  59. package/src/components/cards/index.ts +4 -0
  60. package/src/components/content/DAlert.vue +112 -0
  61. package/src/components/content/DQuote.vue +71 -0
  62. package/src/components/content/index.ts +4 -0
  63. package/src/components/index.ts +12 -0
  64. package/src/components/lists/DActionsFan.vue +153 -0
  65. package/src/components/lists/DActionsList.vue +100 -0
  66. package/src/components/lists/index.ts +4 -0
  67. package/src/components/utils/DWrapBackground.vue +76 -0
  68. package/src/components/utils/DWrapFocusHighlight.vue +241 -0
  69. package/src/components/utils/DWrapShape.vue +170 -0
  70. package/src/components/utils/index.ts +7 -0
  71. package/src/composables/big-bang-button-utils.ts +7 -0
  72. package/src/composables/index.ts +2 -0
  73. package/src/composables/router.ts +66 -0
  74. package/src/composables/utils.ts +5 -0
  75. package/src/index.ts +3 -0
  76. package/src/style.css +3 -0
  77. package/src/utils/boundings.ts +35 -0
  78. package/src/utils/index.ts +3 -0
  79. package/src/utils/pagination.ts +4 -0
  80. package/src/utils/polygon-animation.ts +139 -0
  81. package/src/vite-env.d.ts +1 -0
  82. package/tailwind.config.js +22 -0
  83. package/tsconfig.json +25 -0
  84. package/tsconfig.node.json +10 -0
  85. package/vite.config.ts +35 -0
@@ -0,0 +1,241 @@
1
+ <script lang="ts">
2
+ import { computed } from 'vue'
3
+ import DWrapShape from './DWrapShape.vue'
4
+
5
+ export default {
6
+ name: 'DWrapFocusHighlight',
7
+ components: {
8
+ DWrapShape
9
+ }
10
+ }
11
+ </script>
12
+
13
+ <script setup lang="ts">
14
+ export type HighlightVariant =
15
+ | 'negative-tile'
16
+ | 'list-item'
17
+ | 'negative-list-item'
18
+ | 'composite-list-item'
19
+
20
+ const props = defineProps({
21
+ /**
22
+ * If true, the highlight will be shown only if the link is exact string a URL.
23
+ */
24
+ linkExact: Boolean,
25
+ /**
26
+ * Turn off the highlight for active links.
27
+ */
28
+ noPassiveLink: Boolean,
29
+ /**
30
+ * Turn on the highlight even if the link is not active.
31
+ */
32
+ active: Boolean,
33
+ variant: {
34
+ type: String as () => HighlightVariant,
35
+ default: 'negative-tile'
36
+ },
37
+ tag: {
38
+ type: String,
39
+ default: 'div'
40
+ },
41
+ colorClass: {
42
+ type: [String, Object as () => Record<string, boolean>],
43
+ default: 'd-focus-hl--default-color'
44
+ }
45
+ })
46
+
47
+ const currentComponent = computed(() => {
48
+ // @ts-ignore
49
+ if (props.to || props.href) return resolveComponent('NuxtLink')
50
+ return props.tag
51
+ })
52
+ </script>
53
+
54
+ <template>
55
+ <DWrapShape>
56
+ <Component
57
+ v-bind="props"
58
+ :is="currentComponent"
59
+ class="d-focus-hl"
60
+ :class="{
61
+ 'd-focus-hl--exact': linkExact,
62
+ 'd-focus-hl--not-exact': !linkExact,
63
+ 'd-focus-hl--no-passive-link': noPassiveLink,
64
+ 'd-focus-hl--active': active
65
+ }"
66
+ >
67
+ <div
68
+ v-if="variant === 'negative-tile'"
69
+ class="d-focus-hl__hl--negative-tile"
70
+ />
71
+ <div
72
+ v-else-if="variant === 'list-item'"
73
+ class="d-focus-hl__hl--list-item"
74
+ :class="colorClass"
75
+ />
76
+ <div
77
+ v-else-if="variant === 'negative-list-item'"
78
+ class="d-focus-hl__hl--negative-list-item"
79
+ />
80
+ <template v-else-if="variant === 'composite-list-item'">
81
+ <div class="d-focus-hl__hl--list-item" :class="colorClass" />
82
+ <div class="d-focus-hl__hl--negative-list-item" />
83
+ </template>
84
+ <slot />
85
+ </Component>
86
+ </DWrapShape>
87
+ </template>
88
+
89
+ <!-- common -->
90
+ <style>
91
+ .d-focus-hl {
92
+ @apply relative;
93
+ }
94
+ .d-focus-hl--default-color {
95
+ @apply bg-red-600;
96
+ }
97
+ </style>
98
+
99
+ <!-- negative-tile -->
100
+ <style>
101
+ .d-focus-hl:has(.d-focus-hl__hl--negative-tile) {
102
+ @apply w-fit;
103
+ }
104
+
105
+ .d-focus-hl > .d-focus-hl__hl--negative-tile {
106
+ width: 0%;
107
+ height: 0%;
108
+ top: 50%;
109
+ left: 50%;
110
+ content: '';
111
+ opacity: 0;
112
+ pointer-events: none;
113
+ @apply absolute backdrop-invert transition-all;
114
+ }
115
+
116
+ .d-focus-hl:hover > .d-focus-hl__hl--negative-tile,
117
+ *:focus .d-focus-hl__hl--negative-tile {
118
+ opacity: 1;
119
+ animation: hl--negative-tile-animation linear 1s infinite;
120
+ }
121
+
122
+ .d-focus-hl:hover > .d-focus-hl__hl--negative-tile {
123
+ width: 110%;
124
+ height: 130%;
125
+ top: -15%;
126
+ left: -5%;
127
+ }
128
+
129
+ *:focus .d-focus-hl__hl--negative-tile {
130
+ width: 140% !important;
131
+ height: 200% !important;
132
+ top: -50% !important;
133
+ left: -20% !important;
134
+ }
135
+
136
+ :is(
137
+ :is(
138
+ .router-link-active
139
+ .d-focus-hl--not-exact:not(.d-focus-hl--no-passive-link),
140
+ .router-link-exact-active
141
+ .d-focus-hl--exact:not(.d-focus-hl--no-passive-link)
142
+ ),
143
+ .d-focus-hl--active
144
+ )
145
+ :is(.d-focus-hl__hl--negative-tile) {
146
+ opacity: 1;
147
+ width: 120% !important;
148
+ height: 120% !important;
149
+ top: -10% !important;
150
+ left: -10% !important;
151
+ }
152
+
153
+ @keyframes hl--negative-tile-animation {
154
+ 0%,
155
+ 100% {
156
+ transform: skew(0deg) rotate(6deg);
157
+ }
158
+ 50% {
159
+ transform: skew(-40deg) rotate(-6deg) scaleX(0.8);
160
+ }
161
+ }
162
+ </style>
163
+
164
+ <!-- list-item -->
165
+ <style>
166
+ .d-focus-hl:has(
167
+ .d-focus-hl__hl--list-item,
168
+ .d-focus-hl__hl--negative-list-item
169
+ ) {
170
+ @apply w-full;
171
+ }
172
+
173
+ .d-focus-hl
174
+ > :is(.d-focus-hl__hl--list-item, .d-focus-hl__hl--negative-list-item) {
175
+ width: 0%;
176
+ height: 200%;
177
+ top: -50%;
178
+ left: 0;
179
+ content: '';
180
+ margin-left: -1.2em;
181
+ pointer-events: none;
182
+ clip-path: polygon(1rem 0, 0% 100%, 90% 50%);
183
+ @apply absolute transition-all;
184
+ }
185
+
186
+ .d-focus-hl > .d-focus-hl__hl--negative-list-item {
187
+ @apply backdrop-invert;
188
+ }
189
+
190
+ .d-focus-hl > .d-focus-hl__hl--list-item {
191
+ @apply -z-10;
192
+ }
193
+
194
+ :is(.d-focus-hl:hover, *:focus)
195
+ :is(.d-focus-hl__hl--list-item, .d-focus-hl__hl--negative-list-item) {
196
+ opacity: 1;
197
+ animation: hl--list-item-animation 0.3s infinite;
198
+ }
199
+
200
+ .d-focus-hl:hover
201
+ > :is(.d-focus-hl__hl--list-item, .d-focus-hl__hl--negative-list-item) {
202
+ width: 200%;
203
+ height: 130%;
204
+ top: -15%;
205
+ left: -5%;
206
+ }
207
+
208
+ *:focus :is(.d-focus-hl__hl--list-item, .d-focus-hl__hl--negative-list-item) {
209
+ width: 220% !important;
210
+ height: 200% !important;
211
+ top: -50% !important;
212
+ left: -5% !important;
213
+ }
214
+
215
+ :is(
216
+ :is(
217
+ .router-link-active
218
+ .d-focus-hl--not-exact:not(.d-focus-hl--no-passive-link),
219
+ .router-link-exact-active
220
+ .d-focus-hl--exact:not(.d-focus-hl--no-passive-link)
221
+ ),
222
+ .d-focus-hl--active
223
+ )
224
+ :is(.d-focus-hl__hl--list-item, .d-focus-hl__hl--negative-list-item) {
225
+ opacity: 1;
226
+ width: 220% !important;
227
+ height: 130% !important;
228
+ top: -15% !important;
229
+ left: -5% !important;
230
+ }
231
+
232
+ @keyframes hl--list-item-animation {
233
+ 0%,
234
+ 100% {
235
+ clip-path: polygon(1em 0, 0% 100%, 100% 50%);
236
+ }
237
+ 50% {
238
+ clip-path: polygon(1em 10%, 0% 90%, 100% 50%);
239
+ }
240
+ }
241
+ </style>
@@ -0,0 +1,170 @@
1
+ <script lang="ts">
2
+ import { type StyleValue } from 'vue'
3
+
4
+ export default {
5
+ name: 'DWrapShape'
6
+ }
7
+ </script>
8
+
9
+ <script setup lang="ts">
10
+ defineProps<{
11
+ shapeClass?: string | Record<string, boolean>
12
+ shapeStyle?: StyleValue
13
+ filterClass?: string | Record<string, boolean>
14
+ filterStyle?: StyleValue
15
+ tag?: string
16
+ }>()
17
+ </script>
18
+
19
+ <template>
20
+ <Component :is="tag ?? 'div'">
21
+ <div class="d-shape">
22
+ <div class="d-shape__bg-filter" :class="filterClass" :style="filterStyle">
23
+ <div class="d-shape__bg-wrapper">
24
+ <div class="d-shape__bg" :class="shapeClass" :style="shapeStyle">
25
+ <slot name="shape-content" />
26
+ </div>
27
+ <slot name="bg-overlay" />
28
+ </div>
29
+ </div>
30
+ <slot />
31
+ </div>
32
+ </Component>
33
+ </template>
34
+
35
+ <style>
36
+ .d-shape,
37
+ .d-shape > * {
38
+ @apply relative;
39
+ }
40
+
41
+ .d-shape__bg-filter {
42
+ @apply absolute top-0 left-0 w-full h-full;
43
+ }
44
+
45
+ .d-shape__bg-wrapper {
46
+ @apply relative w-full h-full;
47
+ }
48
+
49
+ .d-shape__bg {
50
+ @apply absolute w-full h-full;
51
+ }
52
+ </style>
53
+
54
+ <!-- Global shapes -->
55
+ <style>
56
+ :root {
57
+ --shape-bubble--right: polygon(
58
+ 0 calc(100% - 20px),
59
+ 20px calc(100% - 10px),
60
+ 25px calc(100% - 15px),
61
+ 45px calc(100% - 5px),
62
+ 70px calc(100% - 10px),
63
+ 100% 100%,
64
+ calc(100% - 40px) 0,
65
+ 45px 30px,
66
+ 40px calc(100% - 30px),
67
+ 20px calc(100% - 45px),
68
+ 18px calc(100% - 25px)
69
+ );
70
+ --shape-bubble--right__outline: polygon(
71
+ 0 calc(100% - 20px),
72
+ 5px calc(100% - 20px),
73
+ 20px calc(100% - 10px),
74
+ 25px calc(100% - 15px),
75
+ 45px calc(100% - 5px),
76
+ 70px calc(100% - 10px),
77
+ calc(100% - 20px) calc(100% - 10px),
78
+ calc(100% - 50px) 7px,
79
+ 45px 30px,
80
+ 40px calc(100% - 30px),
81
+ 20px calc(100% - 45px),
82
+ 18px calc(100% - 25px),
83
+ 5px calc(100% - 20px),
84
+ 0 calc(100% - 20px),
85
+ 16px calc(100% - 28px),
86
+ 17px calc(100% - 53px),
87
+ 39px calc(100% - 40px),
88
+ 38px 23px,
89
+ calc(100% - 40px) 0,
90
+ 100% 100%,
91
+ 70px calc(100% - 7px),
92
+ 45px 100%,
93
+ 25px calc(100% - 11px),
94
+ 19px calc(100% - 7px),
95
+ 0 calc(100% - 20px)
96
+ );
97
+ --shape-bubble--right__padding: 35px 45px 15px 50px;
98
+ }
99
+
100
+ :root {
101
+ --shape-bubble--left: polygon(
102
+ 100% calc(100% - 20px),
103
+ calc(100% - 20px) calc(100% - 10px),
104
+ calc(100% - 25px) calc(100% - 15px),
105
+ calc(100% - 45px) calc(100% - 5px),
106
+ calc(100% - 70px) calc(100% - 10px),
107
+ 0 100%,
108
+ 40px 0,
109
+ calc(100% - 45px) 30px,
110
+ calc(100% - 40px) calc(100% - 30px),
111
+ calc(100% - 20px) calc(100% - 45px),
112
+ calc(100% - 18px) calc(100% - 25px)
113
+ );
114
+ --shape-bubble--left__outline: polygon(
115
+ 100% calc(100% - 20px),
116
+ calc(100% - 5px) calc(100% - 20px),
117
+ calc(100% - 20px) calc(100% - 10px),
118
+ calc(100% - 25px) calc(100% - 15px),
119
+ calc(100% - 45px) calc(100% - 5px),
120
+ calc(100% - 70px) calc(100% - 10px),
121
+ 20px calc(100% - 10px),
122
+ 50px 7px,
123
+ calc(100% - 45px) 30px,
124
+ calc(100% - 40px) calc(100% - 30px),
125
+ calc(100% - 20px) calc(100% - 45px),
126
+ calc(100% - 18px) calc(100% - 25px),
127
+ calc(100% - 5px) calc(100% - 20px),
128
+ 100% calc(100% - 20px),
129
+ calc(100% - 16px) calc(100% - 28px),
130
+ calc(100% - 17px) calc(100% - 53px),
131
+ calc(100% - 39px) calc(100% - 40px),
132
+ calc(100% - 38px) 23px,
133
+ 40px 0,
134
+ 0 100%,
135
+ calc(100% - 70px) calc(100% - 7px),
136
+ calc(100% - 45px) 100%,
137
+ calc(100% - 25px) calc(100% - 11px),
138
+ calc(100% - 19px) calc(100% - 7px),
139
+ 100% calc(100% - 20px)
140
+ );
141
+ --shape-bubble--left__padding: 35px 50px 15px 45px;
142
+ }
143
+
144
+ :root {
145
+ --shape-card: polygon(2em 0, 0% 100%, 100% calc(100% - 5em), 100% 4em);
146
+ --shape-card-padding: 4.5em 0.5em 5.5em 2.5em;
147
+ }
148
+
149
+ :root {
150
+ --shape-card--dense: polygon(
151
+ 0.5em 0,
152
+ 0% 100%,
153
+ 100% calc(100% - 2em),
154
+ 100% 1.5em
155
+ );
156
+ --shape-card--dense__outline: polygon(
157
+ 0.5em 0,
158
+ 0.8em 0.3em,
159
+ 0.4em calc(100% - 0.7em),
160
+ calc(100% - 0.3em) calc(100% - 2em),
161
+ calc(100% - 0.4em) 1.5em,
162
+ 0.8em 0.3em,
163
+ 0.5em 0,
164
+ 100% 1em,
165
+ 100% calc(100% - 1.8em),
166
+ 0% 100%
167
+ );
168
+ --shape-card--dense__padding: 2em 0.5em 2.5em 1em;
169
+ }
170
+ </style>
@@ -0,0 +1,7 @@
1
+ import DWrapFocusHighlight, {
2
+ type HighlightVariant
3
+ } from './DWrapFocusHighlight.vue'
4
+ import DWrapBackground from './DWrapBackground.vue'
5
+ import DWrapShape from './DWrapShape.vue'
6
+
7
+ export { DWrapFocusHighlight, HighlightVariant, DWrapBackground, DWrapShape }
@@ -0,0 +1,7 @@
1
+ import { ref } from 'vue'
2
+
3
+ const bigBangButtonAnimationText = ref('')
4
+
5
+ export const useDBigBangButtonUtils = () => ({
6
+ text: bigBangButtonAnimationText
7
+ })
@@ -0,0 +1,2 @@
1
+ export * from './big-bang-button-utils'
2
+ export * from './utils'
@@ -0,0 +1,66 @@
1
+ import { resolveDynamicComponent, computed } from 'vue'
2
+ import type { RouterLink as _RouterLink, RouteLocationRaw } from 'vue-router'
3
+
4
+ export interface LinkProps {
5
+ readonly href?: string
6
+ readonly replace?: boolean
7
+ readonly to?: RouteLocationRaw
8
+ readonly exact?: boolean
9
+ readonly tag?: string
10
+ }
11
+
12
+ export function useLink(props: LinkProps) {
13
+ const RouterLink = resolveDynamicComponent('RouterLink') as
14
+ | typeof _RouterLink
15
+ | string
16
+ const NuxtLink =
17
+ // @ts-ignore
18
+ typeof defineNuxtLink === 'function'
19
+ ? // @ts-ignore
20
+ (defineNuxtLink({
21
+ componentName: 'DNuxtLink'
22
+ }) as typeof _RouterLink)
23
+ : undefined
24
+
25
+ const isLink = computed(() => !!(props.href || props.to))
26
+ const isExternalLink = computed(() => {
27
+ if (!props.href) return false
28
+ const href = props.href
29
+ return (
30
+ href.startsWith('http') ||
31
+ href.startsWith('mailto:') ||
32
+ href.startsWith('tel:') ||
33
+ href.startsWith('#')
34
+ )
35
+ })
36
+
37
+ if (isLink.value) {
38
+ if (typeof NuxtLink !== 'undefined') {
39
+ return {
40
+ isLink,
41
+ isExternalLink,
42
+ linkComponent: NuxtLink
43
+ }
44
+ }
45
+
46
+ if (typeof RouterLink !== 'string') {
47
+ return {
48
+ isLink,
49
+ isExternalLink,
50
+ linkComponent: RouterLink
51
+ }
52
+ }
53
+
54
+ return {
55
+ isLink,
56
+ isExternalLink,
57
+ linkComponent: 'a'
58
+ }
59
+ }
60
+
61
+ return {
62
+ isLink,
63
+ isExternalLink,
64
+ linkComponent: props.tag || 'span'
65
+ }
66
+ }
@@ -0,0 +1,5 @@
1
+ import { getLinkToPaginatedPage } from '../utils/pagination'
2
+
3
+ export const useDPaginationUtils = () => ({
4
+ getLinkToPaginatedPage
5
+ })
package/src/index.ts ADDED
@@ -0,0 +1,3 @@
1
+ export * from './components'
2
+ export * from './composables'
3
+ export * from './utils'
package/src/style.css ADDED
@@ -0,0 +1,3 @@
1
+ @tailwind base;
2
+ @tailwind components;
3
+ @tailwind utilities;
@@ -0,0 +1,35 @@
1
+ import type { Ref } from 'vue'
2
+
3
+ export function getAbsoluteBoundingsGetters(
4
+ el: Ref<Element | null>,
5
+ correlations: { x?: () => number; y?: () => number } = {}
6
+ ) {
7
+ return {
8
+ top: () =>
9
+ (el.value?.getBoundingClientRect().top ?? 0) +
10
+ window.scrollY +
11
+ (correlations.y ? correlations.y() : 0),
12
+ bottom: () =>
13
+ (el.value?.getBoundingClientRect().bottom ?? 0) +
14
+ window.scrollY +
15
+ (correlations.y ? correlations.y() : 0),
16
+ right: () =>
17
+ (el.value?.getBoundingClientRect().right ?? 0) +
18
+ window.scrollX +
19
+ (correlations.x ? correlations.x() : 0),
20
+ left: () =>
21
+ (el.value?.getBoundingClientRect().left ?? 0) +
22
+ window.scrollX +
23
+ (correlations.x ? correlations.x() : 0)
24
+ }
25
+ }
26
+
27
+ export function getAbsoluteBoundings(el: Ref<Element | null>) {
28
+ const getters = getAbsoluteBoundingsGetters(el)
29
+ return {
30
+ top: getters.top(),
31
+ bottom: getters.bottom(),
32
+ right: getters.right(),
33
+ left: getters.left()
34
+ }
35
+ }
@@ -0,0 +1,3 @@
1
+ export * from './boundings'
2
+ export * from './pagination'
3
+ export * from './polygon-animation'
@@ -0,0 +1,4 @@
1
+ export function getLinkToPaginatedPage(baseLink: string, page: number) {
2
+ if (page === 1) return baseLink
3
+ return `${baseLink}/${page}`
4
+ }
@@ -0,0 +1,139 @@
1
+ /**
2
+ * Representation of point coordinates.
3
+ */
4
+ export type Coords = {
5
+ x: number
6
+ y: number
7
+ }
8
+
9
+ /**
10
+ * Representation of line edge, where right and left points
11
+ * are on the opposite sides of the same corner.
12
+ */
13
+ export type LineEdge = {
14
+ right: Coords
15
+ left: Coords
16
+ }
17
+
18
+ /**
19
+ *
20
+ * Generate sets of keyframes for each point on line polygon
21
+ *
22
+ * @param line
23
+ * @returns Sets of keyframes for each polygon point
24
+ */
25
+ export function generatePolygonLineKeyframes(line: LineEdge[]): Coords[][] {
26
+ return line.map((_, index, edges) => {
27
+ const leftPoints = edges.reduce((points, edge, currentIndex) => {
28
+ if (currentIndex > index) {
29
+ points.push(points.at(-1) as Coords)
30
+ } else {
31
+ points.push(edge.left)
32
+ }
33
+ return points
34
+ }, [] as Coords[])
35
+ const rightPoints = edges.reduce((points, edge, currentIndex) => {
36
+ if (currentIndex > index) {
37
+ points.push(points.at(-1) as Coords)
38
+ } else {
39
+ points.push(edge.right)
40
+ }
41
+ return points
42
+ }, [] as Coords[])
43
+ return [...rightPoints, ...leftPoints.reverse()]
44
+ })
45
+ }
46
+
47
+ /**
48
+ *
49
+ * Generate 1 set of keyframes for the whole line polygon.
50
+ *
51
+ * @param line
52
+ * @returns Set of keyframes for the whole line polygon
53
+ */
54
+ export function generatePolygonPointsKeyframes(line: LineEdge[]): Coords[][] {
55
+ const lineKfs = generatePolygonLineKeyframes(line)
56
+ const keyframesCount = lineKfs.length
57
+ const pointsCount = lineKfs[0].length
58
+ const result: Coords[][] = []
59
+ for (let i = 0; i < pointsCount; i++) {
60
+ const pointKfs: Coords[] = []
61
+ for (let k = 0; k < keyframesCount; k++) {
62
+ pointKfs.push(lineKfs[k][i])
63
+ }
64
+ result.push(pointKfs)
65
+ }
66
+ return result
67
+ }
68
+
69
+ /**
70
+ *
71
+ * Apply animation to each point of line.
72
+ *
73
+ * @param line Declarative line description
74
+ * @param svgContainer <svg> element which line all figures
75
+ * @param svgPolygon <polygon> element in svg image which will be animated line
76
+ * @param animationCallback apply keyframes to specific points inside callback
77
+ */
78
+ export function applyLinePerPointAnimation(
79
+ line: LineEdge[],
80
+ svgContainer: SVGSVGElement,
81
+ svgPolygon: SVGPolygonElement,
82
+ animationCallback: (point: DOMPoint, keyframes: Coords[]) => void
83
+ ) {
84
+ const allPointsKeyframes = generatePolygonPointsKeyframes(line)
85
+ for (const pointKeyframes of allPointsKeyframes) {
86
+ const point = svgContainer.createSVGPoint()
87
+ svgPolygon.points.appendItem(point)
88
+ animationCallback(point, pointKeyframes)
89
+ }
90
+ }
91
+
92
+ /**
93
+ *
94
+ * Apply last state to polygon.
95
+ *
96
+ * @param line Declarative line description
97
+ * @param svgContainer <svg> element which line all figures
98
+ * @param svgPolygon <polygon> element in svg image which will be line
99
+ */
100
+ export function applyStaticPoints(
101
+ line: LineEdge[],
102
+ svgContainer: SVGSVGElement,
103
+ svgPolygon: SVGPolygonElement
104
+ ) {
105
+ const finalLineState = generatePolygonLineKeyframes(line).at(-1)
106
+ if (!finalLineState) return
107
+ for (const pointCoords of finalLineState) {
108
+ const point = svgContainer.createSVGPoint()
109
+ point.x = pointCoords.x
110
+ point.y = pointCoords.y
111
+ svgPolygon.points.appendItem(point)
112
+ }
113
+ }
114
+
115
+ export function createCoordsFromArray(coordsAsArray: number[]): Coords {
116
+ if (coordsAsArray.length !== 2)
117
+ throw new Error(
118
+ 'Array should contain 2 numbers in order to be translated into coords'
119
+ )
120
+ return {
121
+ x: coordsAsArray[0],
122
+ y: coordsAsArray[1]
123
+ }
124
+ }
125
+
126
+ export function createLineEdgeFromArray(edgeAsArray: number[][]): LineEdge {
127
+ if (edgeAsArray.length !== 2)
128
+ throw new Error(
129
+ 'Array should contain 2 elements in order to be translated into LineEdge'
130
+ )
131
+ return {
132
+ left: createCoordsFromArray(edgeAsArray[0]),
133
+ right: createCoordsFromArray(edgeAsArray[1])
134
+ }
135
+ }
136
+
137
+ export function createLineFromArray(lineAsArray: number[][][]): LineEdge[] {
138
+ return lineAsArray.map(createLineEdgeFromArray)
139
+ }
@@ -0,0 +1 @@
1
+ /// <reference types="vite/client" />