@payfit/unity-illustrations 1.1.0 → 1.2.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 (199) hide show
  1. package/dist/esm/components/illustration/Illustration.js +40 -28
  2. package/dist/esm/docs/blocks/AnimationLibrary.d.ts +2 -0
  3. package/dist/esm/generated/AccountingAnimation.d.ts +20 -0
  4. package/dist/esm/generated/AccountingAnimation.js +12 -0
  5. package/dist/esm/generated/BinocularsAnimation.d.ts +20 -0
  6. package/dist/esm/generated/BinocularsAnimation.js +12 -0
  7. package/dist/esm/generated/BlankPayslip.d.ts +20 -0
  8. package/dist/esm/generated/BlankPayslip.js +10 -0
  9. package/dist/esm/generated/CardAnimation.d.ts +20 -0
  10. package/dist/esm/generated/CardAnimation.js +12 -0
  11. package/dist/esm/generated/ClockAnimation.d.ts +20 -0
  12. package/dist/esm/generated/ClockAnimation.js +12 -0
  13. package/dist/esm/generated/ConfettisAnimation.d.ts +20 -0
  14. package/dist/esm/generated/ConfettisAnimation.js +12 -0
  15. package/dist/esm/generated/DocumentAnimation.d.ts +20 -0
  16. package/dist/esm/generated/DocumentAnimation.js +12 -0
  17. package/dist/esm/generated/EmptyState.d.ts +20 -0
  18. package/dist/esm/generated/EmptyState.js +10 -0
  19. package/dist/esm/generated/ExceptionalCompensation.d.ts +20 -0
  20. package/dist/esm/generated/ExceptionalCompensation.js +10 -0
  21. package/dist/esm/generated/FreeShare.d.ts +20 -0
  22. package/dist/esm/generated/FreeShare.js +10 -0
  23. package/dist/esm/generated/FullCalendar.d.ts +20 -0
  24. package/dist/esm/generated/FullCalendar.js +10 -0
  25. package/dist/esm/generated/Gift.d.ts +20 -0
  26. package/dist/esm/generated/Gift.js +10 -0
  27. package/dist/esm/generated/HalfCalendar.d.ts +20 -0
  28. package/dist/esm/generated/HalfCalendar.js +10 -0
  29. package/dist/esm/generated/HandsAnimation.d.ts +20 -0
  30. package/dist/esm/generated/HandsAnimation.js +12 -0
  31. package/dist/esm/generated/HolidayVoucher.d.ts +20 -0
  32. package/dist/esm/generated/HolidayVoucher.js +10 -0
  33. package/dist/esm/generated/KpmgAnimation.d.ts +20 -0
  34. package/dist/esm/generated/KpmgAnimation.js +12 -0
  35. package/dist/esm/generated/MealPlate.d.ts +20 -0
  36. package/dist/esm/generated/MealPlate.js +10 -0
  37. package/dist/esm/generated/MoneyLending.d.ts +20 -0
  38. package/dist/esm/generated/MoneyLending.js +10 -0
  39. package/dist/esm/generated/OfficialLetter.d.ts +20 -0
  40. package/dist/esm/generated/OfficialLetter.js +10 -0
  41. package/dist/esm/generated/PanelAnimation.d.ts +20 -0
  42. package/dist/esm/generated/PanelAnimation.js +12 -0
  43. package/dist/esm/generated/PaperPlaneAnimation.d.ts +20 -0
  44. package/dist/esm/generated/PaperPlaneAnimation.js +12 -0
  45. package/dist/esm/generated/PartyAnimation.d.ts +20 -0
  46. package/dist/esm/generated/PartyAnimation.js +12 -0
  47. package/dist/esm/generated/PayslipCoins.d.ts +20 -0
  48. package/dist/esm/generated/PayslipCoins.js +10 -0
  49. package/dist/esm/generated/PayslipFlipAnimation.d.ts +20 -0
  50. package/dist/esm/generated/PayslipFlipAnimation.js +12 -0
  51. package/dist/esm/generated/PeopleAnimation.d.ts +20 -0
  52. package/dist/esm/generated/PeopleAnimation.js +12 -0
  53. package/dist/esm/generated/PiggyBankAnimation.d.ts +20 -0
  54. package/dist/esm/generated/PiggyBankAnimation.js +12 -0
  55. package/dist/esm/generated/PiggyBankCoins.d.ts +20 -0
  56. package/dist/esm/generated/PiggyBankCoins.js +10 -0
  57. package/dist/esm/generated/PlantAnimation.d.ts +20 -0
  58. package/dist/esm/generated/PlantAnimation.js +12 -0
  59. package/dist/esm/generated/Promotion.d.ts +20 -0
  60. package/dist/esm/generated/Promotion.js +10 -0
  61. package/dist/esm/generated/SalarySeizure.d.ts +20 -0
  62. package/dist/esm/generated/SalarySeizure.js +10 -0
  63. package/dist/esm/generated/ScheduleAnimation.d.ts +20 -0
  64. package/dist/esm/generated/ScheduleAnimation.js +12 -0
  65. package/dist/esm/generated/StockOptions.d.ts +20 -0
  66. package/dist/esm/generated/StockOptions.js +10 -0
  67. package/dist/esm/generated/ThumbsupAnimation.d.ts +20 -0
  68. package/dist/esm/generated/ThumbsupAnimation.js +12 -0
  69. package/dist/esm/generated/TokenCoin.d.ts +20 -0
  70. package/dist/esm/generated/TokenCoin.js +10 -0
  71. package/dist/esm/generated/WinterPartyAnimation.d.ts +20 -0
  72. package/dist/esm/generated/WinterPartyAnimation.js +12 -0
  73. package/dist/esm/generated/WorkExpense.d.ts +20 -0
  74. package/dist/esm/generated/WorkExpense.js +10 -0
  75. package/dist/esm/generated/assets/AccountingAnimation.webp.js +4 -0
  76. package/dist/esm/generated/assets/BinocularsAnimation.webp.js +4 -0
  77. package/dist/esm/generated/assets/BlankPayslip.svg.js +4 -0
  78. package/dist/esm/generated/assets/CardAnimation.webp.js +4 -0
  79. package/dist/esm/generated/assets/ClockAnimation.webp.js +4 -0
  80. package/dist/esm/generated/assets/ConfettisAnimation.webp.js +4 -0
  81. package/dist/esm/generated/assets/DocumentAnimation.webp.js +4 -0
  82. package/dist/esm/generated/assets/EmptyState.svg.js +4 -0
  83. package/dist/esm/generated/assets/ExceptionalCompensation.svg.js +4 -0
  84. package/dist/esm/generated/assets/FreeShare.svg.js +4 -0
  85. package/dist/esm/generated/assets/FullCalendar.svg.js +4 -0
  86. package/dist/esm/generated/assets/Gift.svg.js +4 -0
  87. package/dist/esm/generated/assets/HalfCalendar.svg.js +4 -0
  88. package/dist/esm/generated/assets/HandsAnimation.webp.js +4 -0
  89. package/dist/esm/generated/assets/HolidayVoucher.svg.js +4 -0
  90. package/dist/esm/generated/assets/KpmgAnimation.webp.js +4 -0
  91. package/dist/esm/generated/assets/MealPlate.svg.js +4 -0
  92. package/dist/esm/generated/assets/MoneyLending.svg.js +4 -0
  93. package/dist/esm/generated/assets/OfficialLetter.svg.js +4 -0
  94. package/dist/esm/generated/assets/PanelAnimation.webp.js +4 -0
  95. package/dist/esm/generated/assets/PaperPlaneAnimation.webp.js +4 -0
  96. package/dist/esm/generated/assets/PartyAnimation.webp.js +4 -0
  97. package/dist/esm/generated/assets/PayslipCoins.svg.js +4 -0
  98. package/dist/esm/generated/assets/PayslipFlipAnimation.webp.js +4 -0
  99. package/dist/esm/generated/assets/PeopleAnimation.webp.js +4 -0
  100. package/dist/esm/generated/assets/PiggyBankAnimation.webp.js +4 -0
  101. package/dist/esm/generated/assets/PiggyBankCoins.svg.js +4 -0
  102. package/dist/esm/generated/assets/PlantAnimation.webp.js +4 -0
  103. package/dist/esm/generated/assets/Promotion.svg.js +4 -0
  104. package/dist/esm/generated/assets/SalarySeizure.svg.js +4 -0
  105. package/dist/esm/generated/assets/ScheduleAnimation.webp.js +4 -0
  106. package/dist/esm/generated/assets/StockOptions.svg.js +4 -0
  107. package/dist/esm/generated/assets/ThumbsupAnimation.webp.js +4 -0
  108. package/dist/esm/generated/assets/TokenCoin.svg.js +4 -0
  109. package/dist/esm/generated/assets/WinterPartyAnimation.webp.js +4 -0
  110. package/dist/esm/generated/assets/WorkExpense.svg.js +4 -0
  111. package/dist/esm/generated/illustrationAssets.d.ts +111 -3
  112. package/dist/esm/generated/illustrationAssets.js +37 -1
  113. package/dist/esm/generated/types.d.ts +9 -1
  114. package/dist/esm/scripts/templates/assetTemplate.d.ts +5 -0
  115. package/package.json +14 -9
  116. package/src/components/illustration/Illustration.stories.tsx +66 -0
  117. package/src/components/illustration/Illustration.tsx +24 -2
  118. package/src/components/lazy-illustration/LazyIllustration.stories.tsx +19 -0
  119. package/src/docs/2-Reference/2-Find my animation.mdx +14 -0
  120. package/src/docs/blocks/AnimationLibrary.tsx +144 -0
  121. package/src/docs/blocks/IllustrationLibrary.tsx +3 -1
  122. package/src/generated/AccountingAnimation.ts +33 -0
  123. package/src/generated/BinocularsAnimation.ts +33 -0
  124. package/src/generated/BlankPayslip.ts +31 -0
  125. package/src/generated/CardAnimation.ts +33 -0
  126. package/src/generated/ClockAnimation.ts +33 -0
  127. package/src/generated/ConfettisAnimation.ts +33 -0
  128. package/src/generated/DocumentAnimation.ts +33 -0
  129. package/src/generated/EmptyState.ts +31 -0
  130. package/src/generated/ExceptionalCompensation.ts +31 -0
  131. package/src/generated/FreeShare.ts +31 -0
  132. package/src/generated/FullCalendar.ts +31 -0
  133. package/src/generated/Gift.ts +31 -0
  134. package/src/generated/HalfCalendar.ts +31 -0
  135. package/src/generated/HandsAnimation.ts +33 -0
  136. package/src/generated/HolidayVoucher.ts +31 -0
  137. package/src/generated/KpmgAnimation.ts +33 -0
  138. package/src/generated/MealPlate.ts +31 -0
  139. package/src/generated/MoneyLending.ts +31 -0
  140. package/src/generated/OfficialLetter.ts +31 -0
  141. package/src/generated/PanelAnimation.ts +33 -0
  142. package/src/generated/PaperPlaneAnimation.ts +33 -0
  143. package/src/generated/PartyAnimation.ts +33 -0
  144. package/src/generated/PayslipCoins.ts +31 -0
  145. package/src/generated/PayslipFlipAnimation.ts +33 -0
  146. package/src/generated/PeopleAnimation.ts +33 -0
  147. package/src/generated/PiggyBankAnimation.ts +33 -0
  148. package/src/generated/PiggyBankCoins.ts +31 -0
  149. package/src/generated/PlantAnimation.ts +33 -0
  150. package/src/generated/Promotion.ts +31 -0
  151. package/src/generated/SalarySeizure.ts +31 -0
  152. package/src/generated/ScheduleAnimation.ts +33 -0
  153. package/src/generated/StockOptions.ts +31 -0
  154. package/src/generated/ThumbsupAnimation.ts +33 -0
  155. package/src/generated/TokenCoin.ts +31 -0
  156. package/src/generated/WinterPartyAnimation.ts +33 -0
  157. package/src/generated/WorkExpense.ts +31 -0
  158. package/src/generated/assets/AccountingAnimation.webp +0 -0
  159. package/src/generated/assets/BinocularsAnimation.webp +0 -0
  160. package/src/generated/assets/BlankPayslip.svg +1 -0
  161. package/src/generated/assets/CardAnimation.webp +0 -0
  162. package/src/generated/assets/ClockAnimation.webp +0 -0
  163. package/src/generated/assets/ConfettisAnimation.webp +0 -0
  164. package/src/generated/assets/DocumentAnimation.webp +0 -0
  165. package/src/generated/assets/EmptyState.svg +1 -0
  166. package/src/generated/assets/ExceptionalCompensation.svg +1 -0
  167. package/src/generated/assets/FreeShare.svg +1 -0
  168. package/src/generated/assets/FullCalendar.svg +1 -0
  169. package/src/generated/assets/Gift.svg +1 -0
  170. package/src/generated/assets/HalfCalendar.svg +1 -0
  171. package/src/generated/assets/HandsAnimation.webp +0 -0
  172. package/src/generated/assets/HolidayVoucher.svg +1 -0
  173. package/src/generated/assets/KpmgAnimation.webp +0 -0
  174. package/src/generated/assets/MealPlate.svg +1 -0
  175. package/src/generated/assets/MoneyLending.svg +1 -0
  176. package/src/generated/assets/OfficialLetter.svg +1 -0
  177. package/src/generated/assets/PanelAnimation.webp +0 -0
  178. package/src/generated/assets/PaperPlaneAnimation.webp +0 -0
  179. package/src/generated/assets/PartyAnimation.webp +0 -0
  180. package/src/generated/assets/PayslipCoins.svg +1 -0
  181. package/src/generated/assets/PayslipFlipAnimation.webp +0 -0
  182. package/src/generated/assets/PeopleAnimation.webp +0 -0
  183. package/src/generated/assets/PiggyBankAnimation.webp +0 -0
  184. package/src/generated/assets/PiggyBankCoins.svg +1 -0
  185. package/src/generated/assets/PlantAnimation.webp +0 -0
  186. package/src/generated/assets/Promotion.svg +1 -0
  187. package/src/generated/assets/SalarySeizure.svg +1 -0
  188. package/src/generated/assets/ScheduleAnimation.webp +0 -0
  189. package/src/generated/assets/StockOptions.svg +1 -0
  190. package/src/generated/assets/ThumbsupAnimation.webp +0 -0
  191. package/src/generated/assets/TokenCoin.svg +1 -0
  192. package/src/generated/assets/WinterPartyAnimation.webp +0 -0
  193. package/src/generated/assets/WorkExpense.svg +1 -0
  194. package/src/generated/illustrationAssets.ts +119 -10
  195. package/src/generated/types.ts +10 -1
  196. package/src/scripts/generate-assets.ts +98 -14
  197. package/src/scripts/templates/assetTemplate.ts +55 -2
  198. package/src/scripts/templates/baseTypes.ts +10 -1
  199. package/src/scripts/templates/indexTemplate.ts +2 -1
@@ -3,6 +3,7 @@ import path from 'path'
3
3
 
4
4
  import type { Config } from 'svgo'
5
5
 
6
+ import imageSize from 'image-size'
6
7
  import { loadConfig, optimize } from 'svgo'
7
8
 
8
9
  import { generateAssetModule } from './templates/assetTemplate'
@@ -25,7 +26,8 @@ function toPascalCase(str: string) {
25
26
  .join('')
26
27
  }
27
28
 
28
- function getComponentName(filename: string) {
29
+ function getComponentName(filePath: string) {
30
+ const filename = path.basename(filePath)
29
31
  const typeMatch = /Type=([^,.]+)/.exec(filename)
30
32
  const nameMatch = /Name=([^,.]+)/.exec(filename)
31
33
  const bgMatch = /With background=yes/.exec(filename)
@@ -39,6 +41,14 @@ function getComponentName(filename: string) {
39
41
  if (bgMatch) {
40
42
  base += 'WithBackground'
41
43
  }
44
+
45
+ // Add Animation suffix for animated illustrations
46
+ const relativePath = path.relative(illustrationsSvgDir, filePath)
47
+ const folder = relativePath.split(path.sep)[0]
48
+ if (folder === 'animated-illustrations') {
49
+ base += 'Animation'
50
+ }
51
+
42
52
  return base
43
53
  }
44
54
 
@@ -56,16 +66,45 @@ async function getAllAssetFiles(dir: string) {
56
66
  return results
57
67
  }
58
68
 
59
- function getAssetType(filePath: string) {
69
+ function getAssetTypeFromPath(filePath: string) {
70
+ const relativePath = path.relative(illustrationsSvgDir, filePath)
71
+ const folder = relativePath.split(path.sep)[0]
60
72
  const ext = path.extname(filePath).toLowerCase()
73
+
74
+ if (folder === 'animated-illustrations') {
75
+ if (ext !== '.webp') {
76
+ throw new Error(
77
+ `Animated illustrations must be WEBP format. Found: ${ext} in ${filePath}`,
78
+ )
79
+ }
80
+ return {
81
+ type: 'image' as const,
82
+ animated: true,
83
+ category: 'animation' as const,
84
+ }
85
+ }
86
+
87
+ if (folder === 'illustrated-icons') {
88
+ return { type: 'svg' as const, animated: false, category: 'icon' as const }
89
+ }
90
+
91
+ if (folder === 'illustrated-pictures') {
92
+ return {
93
+ type: 'svg' as const,
94
+ animated: false,
95
+ category: 'picture' as const,
96
+ }
97
+ }
98
+
99
+ // Fallback to extension-based detection for backward compatibility
61
100
  const animatedFormats = ['.gif', '.webp']
62
101
 
63
102
  if (ext === '.svg') {
64
- return { type: 'svg', animated: false }
103
+ return { type: 'svg' as const, animated: false }
65
104
  }
66
105
 
67
106
  return {
68
- type: 'image',
107
+ type: 'image' as const,
69
108
  animated: animatedFormats.includes(ext),
70
109
  }
71
110
  }
@@ -88,10 +127,29 @@ function optimizeSvg(svgContent: string, filePath: string, svgoConfig: Config) {
88
127
  }
89
128
  }
90
129
 
130
+ async function getImageDimensions(
131
+ imagePath: string,
132
+ ): Promise<{ width: number; height: number }> {
133
+ try {
134
+ const buffer = await fs.readFile(imagePath)
135
+ const dimensions = imageSize(buffer)
136
+
137
+ if (!dimensions.width || !dimensions.height) {
138
+ throw new Error(`Could not determine dimensions for ${imagePath}`)
139
+ }
140
+
141
+ return { width: dimensions.width, height: dimensions.height }
142
+ } catch (error) {
143
+ throw new Error(
144
+ `Failed to get dimensions for ${imagePath}: ${(error as Error).message}`,
145
+ )
146
+ }
147
+ }
148
+
91
149
  async function processAsset(assetPath: string) {
92
150
  const assetFile = path.basename(assetPath)
93
- const componentName = getComponentName(assetFile)
94
- const assetType = getAssetType(assetPath)
151
+ const componentName = getComponentName(assetPath)
152
+ const assetType = getAssetTypeFromPath(assetPath)
95
153
  const svgoConfig = (await loadConfig()) ?? {}
96
154
 
97
155
  // Generate output path in the generated/assets folder
@@ -101,6 +159,7 @@ async function processAsset(assetPath: string) {
101
159
 
102
160
  let sizeBefore = 0
103
161
  let sizeAfter = 0
162
+ let dimensions: { width: number; height: number } | undefined
104
163
 
105
164
  if (assetType.type === 'svg') {
106
165
  // Optimize SVG and save to generated/assets folder
@@ -121,17 +180,30 @@ async function processAsset(assetPath: string) {
121
180
  await fs.copyFile(assetPath, optimizedAssetPath)
122
181
  const stats = await fs.stat(assetPath)
123
182
  sizeBefore = sizeAfter = stats.size
124
- console.log(
125
- `📦 ${assetFile}: ${(sizeBefore / 1024).toFixed(2)}KB (${
126
- assetType.animated ? 'animated ' : ''
127
- }${assetType.type})`,
128
- )
183
+
184
+ // Extract dimensions for animated illustrations
185
+ if (assetType.category === 'animation') {
186
+ dimensions = await getImageDimensions(assetPath)
187
+ console.log(
188
+ `🎬 ${assetFile}: ${(sizeBefore / 1024).toFixed(2)}KB (animation ${
189
+ dimensions.width
190
+ }x${dimensions.height})`,
191
+ )
192
+ } else {
193
+ console.log(
194
+ `📦 ${assetFile}: ${(sizeBefore / 1024).toFixed(2)}KB (${
195
+ assetType.animated ? 'animated ' : ''
196
+ }${assetType.type})`,
197
+ )
198
+ }
129
199
  }
130
200
 
131
201
  return {
132
202
  name: componentName,
133
203
  type: assetType.type,
134
204
  animated: assetType.animated,
205
+ category: assetType.category,
206
+ dimensions,
135
207
  sizeBefore,
136
208
  sizeAfter,
137
209
  originalPath: assetPath,
@@ -172,8 +244,10 @@ async function main() {
172
244
  component.name,
173
245
  component.optimizedPath,
174
246
  {
175
- type: component.type as 'svg' | 'image',
247
+ type: component.type,
176
248
  animated: component.animated,
249
+ category: component.category,
250
+ dimensions: component.dimensions,
177
251
  },
178
252
  component.originalFileName,
179
253
  )
@@ -226,9 +300,19 @@ async function main() {
226
300
  )
227
301
  console.log(` - SVGs: ${components.filter(c => c.type === 'svg').length}`)
228
302
  console.log(
229
- ` - Images: ${components.filter(c => c.type === 'image').length}`,
303
+ ` - Images: ${
304
+ components.filter(c => c.type === 'image' && c.category !== 'animation')
305
+ .length
306
+ }`,
307
+ )
308
+ console.log(
309
+ ` - Animations: ${
310
+ components.filter(c => c.category === 'animation').length
311
+ }`,
312
+ )
313
+ console.log(
314
+ ` - Total Animated: ${components.filter(c => c.animated).length}`,
230
315
  )
231
- console.log(` - Animated: ${components.filter(c => c.animated).length}`)
232
316
  }
233
317
 
234
318
  main().catch((err: unknown) => {
@@ -3,11 +3,19 @@ import path from 'path'
3
3
  /**
4
4
  * Generates a single asset module
5
5
  */
6
- export function generateAssetModule(componentName: string, optimizedAssetPath: string, assetType: { type: 'svg' | 'image', animated: boolean }, originalFileName: string) {
6
+ export function generateAssetModule(
7
+ componentName: string,
8
+ optimizedAssetPath: string,
9
+ assetType: { type: 'svg' | 'image', animated: boolean, category?: string, dimensions?: { width: number, height: number } },
10
+ originalFileName: string
11
+ ) {
7
12
  // Use relative path from the generated TypeScript file to the optimized asset
8
13
  const relativePath = `./assets/${path.basename(optimizedAssetPath)}`
9
14
 
10
- if (assetType.type === 'svg') {
15
+ if (assetType.category === 'animation') {
16
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
17
+ return generateAnimatedAsset(componentName, relativePath, originalFileName, assetType.dimensions!)
18
+ } else if (assetType.type === 'svg') {
11
19
  return generateSvgAsset(componentName, relativePath, originalFileName)
12
20
  } else {
13
21
  return generateImageAsset(componentName, relativePath, originalFileName, assetType.animated)
@@ -52,6 +60,51 @@ export default ${componentName}
52
60
  `
53
61
  }
54
62
 
63
+ /**
64
+ * Generates animated asset module
65
+ */
66
+ function generateAnimatedAsset(
67
+ componentName: string,
68
+ relativePath: string,
69
+ originalFileName: string,
70
+ dimensions: { width: number, height: number }
71
+ ) {
72
+ return `// AUTO-GENERATED FILE. DO NOT EDIT.
73
+ // Source: ${originalFileName} (Animated WEBP - ${dimensions.width}x${dimensions.height})
74
+ import assetUrl from '${relativePath}'
75
+ import type { IllustrationAsset, BaseAnimatedImageAsset } from './types'
76
+
77
+ export type ${componentName}Asset = IllustrationAsset<BaseAnimatedImageAsset & {
78
+ readonly name: '${componentName}'
79
+ }>
80
+
81
+ /**
82
+ * ${componentName} animated illustration asset (${dimensions.width}x${dimensions.height})
83
+ * @example
84
+ * \`\`\`tsx
85
+ * import { Illustration } from '@payfit/unity-illustrations'
86
+ * import ${componentName} from '@payfit/unity-illustrations/${componentName}'
87
+ *
88
+ * <Illustration
89
+ * variant="picture"
90
+ * src={${componentName}}
91
+ * alt="${componentName.replace('Animation', '')} animation"
92
+ * />
93
+ * \`\`\`
94
+ */
95
+ const ${componentName}: ${componentName}Asset = {
96
+ type: 'image',
97
+ url: assetUrl,
98
+ animated: true,
99
+ dimensions: { width: ${dimensions.width}, height: ${dimensions.height} },
100
+ category: 'animation',
101
+ name: '${componentName}',
102
+ } as ${componentName}Asset
103
+
104
+ export default ${componentName}
105
+ `
106
+ }
107
+
55
108
  /**
56
109
  * Generates image asset module
57
110
  */
@@ -24,8 +24,17 @@ export interface BaseImageAsset {
24
24
  readonly animated: boolean
25
25
  }
26
26
 
27
+ export interface BaseAnimatedImageAsset extends BaseImageAsset {
28
+ readonly animated: true
29
+ readonly dimensions: {
30
+ readonly width: number
31
+ readonly height: number
32
+ }
33
+ readonly category: 'animation'
34
+ }
35
+
27
36
  // Branded wrapper type
28
- export type IllustrationAsset<T extends (BaseSvgAsset | BaseImageAsset) & { readonly name: string }> =
37
+ export type IllustrationAsset<T extends (BaseSvgAsset | BaseImageAsset | BaseAnimatedImageAsset) & { readonly name: string }> =
29
38
  T & IllustrationAssetBrand
30
39
  `
31
40
  }
@@ -47,7 +47,8 @@ export type {
47
47
  IllustrationAsset,
48
48
  IllustrationAssetBrand,
49
49
  BaseSvgAsset,
50
- BaseImageAsset
50
+ BaseImageAsset,
51
+ BaseAnimatedImageAsset
51
52
  } from './types'
52
53
 
53
54
  // Import all assets for union type