@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
@@ -12,7 +12,15 @@ export interface BaseImageAsset {
12
12
  readonly url: string;
13
13
  readonly animated: boolean;
14
14
  }
15
- export type IllustrationAsset<T extends (BaseSvgAsset | BaseImageAsset) & {
15
+ export interface BaseAnimatedImageAsset extends BaseImageAsset {
16
+ readonly animated: true;
17
+ readonly dimensions: {
18
+ readonly width: number;
19
+ readonly height: number;
20
+ };
21
+ readonly category: 'animation';
22
+ }
23
+ export type IllustrationAsset<T extends (BaseSvgAsset | BaseImageAsset | BaseAnimatedImageAsset) & {
16
24
  readonly name: string;
17
25
  }> = T & IllustrationAssetBrand;
18
26
  export {};
@@ -4,4 +4,9 @@
4
4
  export declare function generateAssetModule(componentName: string, optimizedAssetPath: string, assetType: {
5
5
  type: 'svg' | 'image';
6
6
  animated: boolean;
7
+ category?: string;
8
+ dimensions?: {
9
+ width: number;
10
+ height: number;
11
+ };
7
12
  }, originalFileName: string): string;
package/package.json CHANGED
@@ -1,9 +1,12 @@
1
1
  {
2
2
  "name": "@payfit/unity-illustrations",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "module": "./dist/esm/index.js",
5
5
  "type": "module",
6
6
  "sideEffects": false,
7
+ "storybook": {
8
+ "url": "https://unity-illustrations.payfit.io/"
9
+ },
7
10
  "exports": {
8
11
  ".": {
9
12
  "import": {
@@ -26,31 +29,33 @@
26
29
  "src"
27
30
  ],
28
31
  "dependencies": {
32
+ "image-size": "1.0.2",
29
33
  "svgo": "3.3.2"
30
34
  },
31
35
  "devDependencies": {
32
36
  "@payfit/code-pushup-tools": "0.0.0-use.local",
33
37
  "@payfit/hr-app-eslint": "0.0.0-use.local",
34
38
  "@payfit/hr-apps-tsconfigs": "0.0.0-use.local",
35
- "@payfit/unity-themes": "1.1.0",
39
+ "@payfit/unity-themes": "1.2.0",
36
40
  "@payfit/vite-configs": "0.0.0-use.local",
37
- "@storybook/addon-a11y": "9.1.5",
38
- "@storybook/addon-docs": "9.1.5",
39
- "@storybook/addon-links": "9.1.5",
40
- "@storybook/react-vite": "9.1.5",
41
+ "@storybook/addon-a11y": "9.1.7",
42
+ "@storybook/addon-docs": "9.1.7",
43
+ "@storybook/addon-links": "9.1.7",
44
+ "@storybook/react-vite": "9.1.7",
41
45
  "@storybook/test-runner": "0.23.0",
42
46
  "@types/react": "18.3.18",
43
47
  "@types/react-dom": "18.3.5",
48
+ "image-size": "1.0.2",
44
49
  "react": "18.3.1",
45
50
  "react-dom": "18.3.1",
46
- "storybook": "9.1.5",
51
+ "storybook": "9.1.7",
47
52
  "svgo": "3.3.2",
48
53
  "tailwindcss": "4.1.11",
49
54
  "tsx": "4.17.0",
50
- "vite": "6.3.5"
55
+ "vite": "7.1.6"
51
56
  },
52
57
  "peerDependencies": {
53
- "@payfit/unity-themes": "1.1.0",
58
+ "@payfit/unity-themes": "1.2.0",
54
59
  "react": "18.3.1",
55
60
  "react-dom": "18.3.1"
56
61
  }
@@ -1,6 +1,10 @@
1
1
  import type { Meta, StoryObj } from '@storybook/react-vite'
2
2
 
3
+ // Animated illustrations - import directly from individual files
4
+ import AccountingAnimation from '../../generated/AccountingAnimation'
3
5
  import Binoculars from '../../generated/Binoculars'
6
+ import BinocularsAnimation from '../../generated/BinocularsAnimation'
7
+ import CardAnimation from '../../generated/CardAnimation'
4
8
  import FAQ from '../../generated/FAQ'
5
9
  import FAQWithBackground from '../../generated/FAQWithBackground'
6
10
  import VisuallyImpaired from '../../generated/VisuallyImpaired'
@@ -259,3 +263,65 @@ export const Responsive: Story = {
259
263
  )
260
264
  },
261
265
  }
266
+
267
+ /**
268
+ * Unity illustrations supports animated illustrations in WEBP format. All the animated illustrations have the `Animation` suffix on their name
269
+ * Animated illustrations will grow fluidly depending on its container size but are capped at their original dimensions to prevent oversizing.
270
+ */
271
+ export const AnimatedIllustrations: Story = {
272
+ parameters: {
273
+ chromatic: { disableSnapshot: true },
274
+ },
275
+ render: () => {
276
+ return (
277
+ <div className="uy:space-y-300">
278
+ <div>
279
+ <h3 className="uy:typography-h3 uy:mb-200">
280
+ Large Animation (Fluid)
281
+ </h3>
282
+ <div className="uy:border uy:border-dashed uy:border-border-neutral uy:p-200 uy:rounded-100 uy:w-[50dvw]">
283
+ <Illustration
284
+ src={AccountingAnimation}
285
+ variant="picture"
286
+ alt="Accounting animation showing financial calculations"
287
+ />
288
+ </div>
289
+ <p className="uy:typography-caption uy:text-content-tertiary uy:mt-100">
290
+ Max dimensions: 969×852px • Scales down responsively
291
+ </p>
292
+ </div>
293
+
294
+ <div>
295
+ <h3 className="uy:typography-h3 uy:mb-200">
296
+ Medium Animation (Fluid)
297
+ </h3>
298
+ <div className="uy:border uy:border-dashed uy:border-border-neutral uy:p-200 uy:rounded-100 uy:w-[25dvw]">
299
+ <Illustration
300
+ src={BinocularsAnimation}
301
+ variant="picture"
302
+ alt="Binoculars animation for search or discovery"
303
+ />
304
+ </div>
305
+ <p className="uy:typography-caption uy:text-content-tertiary uy:mt-100">
306
+ Max dimensions: 750×750px • Scales down responsively
307
+ </p>
308
+ </div>
309
+ <div>
310
+ <h3 className="uy:typography-h3 uy:mb-200">
311
+ Small Animation (Fluid)
312
+ </h3>
313
+ <div className="uy:border uy:border-dashed uy:border-border-neutral uy:p-200 uy:rounded-100">
314
+ <Illustration
315
+ src={CardAnimation}
316
+ variant="picture"
317
+ alt="Card animation for payment or identification"
318
+ />
319
+ </div>
320
+ <p className="uy:typography-caption uy:text-content-tertiary uy:mt-100">
321
+ Max dimensions: 224×224px • Scales down responsively
322
+ </p>
323
+ </div>
324
+ </div>
325
+ )
326
+ },
327
+ }
@@ -1,4 +1,4 @@
1
- import { forwardRef } from 'react'
1
+ import { forwardRef, useMemo } from 'react'
2
2
 
3
3
  import type { VariantProps } from '@payfit/unity-themes'
4
4
  import type { ImgHTMLAttributes } from 'react'
@@ -110,6 +110,7 @@ export const Illustration = forwardRef<HTMLImageElement, IllustrationProps>(
110
110
  isDecorative: decorative = false,
111
111
  variant,
112
112
  className,
113
+ style,
113
114
  ...props
114
115
  },
115
116
  ref,
@@ -126,13 +127,34 @@ export const Illustration = forwardRef<HTMLImageElement, IllustrationProps>(
126
127
  ? (props as NonDecorativeIllustrationProps).description
127
128
  : undefined
128
129
 
130
+ // Apply max dimensions for animated assets and generate CSS custom properties
131
+ const { enhancedStyle, enhancedClassName } = useMemo(() => {
132
+ if ('category' in src && 'dimensions' in src) {
133
+ const animationClasses =
134
+ 'uy:max-w-[var(--uy-illustration-max-width)] uy:max-h-[var(--uy-illustration-max-height)] uy:w-full uy:h-auto'
135
+ return {
136
+ enhancedStyle: {
137
+ '--uy-illustration-max-width': `${src.dimensions.width}px`,
138
+ '--uy-illustration-max-height': `${src.dimensions.height}px`,
139
+ ...style,
140
+ },
141
+ enhancedClassName: `${clsx} ${animationClasses}`.trim(),
142
+ }
143
+ }
144
+ return {
145
+ enhancedStyle: style,
146
+ enhancedClassName: clsx,
147
+ }
148
+ }, [src, style, clsx])
149
+
129
150
  return (
130
151
  <img
131
152
  ref={ref}
132
153
  src={src.url}
133
154
  alt={decorative ? '' : alt}
134
155
  title={decorative ? undefined : alt}
135
- className={clsx}
156
+ className={enhancedClassName}
157
+ style={enhancedStyle}
136
158
  role={decorative ? 'presentation' : 'img'}
137
159
  aria-hidden={decorative}
138
160
  aria-description={description}
@@ -23,6 +23,9 @@ const meta = {
23
23
  'WriteBook',
24
24
  'VisuallyImpaired',
25
25
  'Library',
26
+ 'AccountingAnimation',
27
+ 'BinocularsAnimation',
28
+ 'CardAnimation',
26
29
  ],
27
30
  description:
28
31
  'The name of the illustration to load dynamically. This must be one of the valid illustration names from the Unity illustration library',
@@ -147,3 +150,19 @@ export const Responsive: Story = {
147
150
  alt: 'Write Book Illustration',
148
151
  },
149
152
  }
153
+
154
+ /**
155
+ * You can use animated illustrations with the LazyIllustration component. Animated illustrations
156
+ * have the `Animation` suffix and are automatically loaded with their fluid sizing behavior.
157
+ * The component detects animated assets and applies maximum dimension constraints to prevent oversizing.
158
+ */
159
+ export const AnimatedIllustrations: Story = {
160
+ parameters: {
161
+ chromatic: { disableSnapshot: true },
162
+ },
163
+ args: {
164
+ variant: 'picture',
165
+ name: 'AccountingAnimation',
166
+ alt: 'Accounting animation showing financial calculations',
167
+ },
168
+ }
@@ -0,0 +1,14 @@
1
+ import {Meta} from "@storybook/addon-docs/blocks";
2
+ import AnimationLibrary from "../blocks/AnimationLibrary"
3
+
4
+ <Meta title="Reference/Find my animation" />
5
+
6
+ # Find my animation
7
+
8
+ Unity Illustrations includes a collection of animated illustrations in WEBP format. Each animated illustration has the `Animation` suffix in its name and follows the same usage patterns as static illustrations. You can browse and search for the animation you need in the gallery below.
9
+
10
+ Animated illustrations are fluid and responsive, but capped at their original dimensions to prevent oversizing. They use CSS custom properties to maintain optimal aspect ratios across different screen sizes.
11
+
12
+ Refer to the [Usage](/?path=/docs/introduction-3-usage--docs) section to learn how to use animation names to render them in your application.
13
+
14
+ <AnimationLibrary />
@@ -0,0 +1,144 @@
1
+ import React, { memo, useCallback, useMemo, useState } from 'react'
2
+
3
+ import { LazyIllustration } from '../../components/lazy-illustration/LazyIllustration'
4
+ import { illustrationNames } from '../../generated/illustrationAssets'
5
+
6
+ const debounce = <P = unknown,>(
7
+ callback: (...args: P[]) => unknown,
8
+ wait: number,
9
+ ) => {
10
+ let timeoutId: number
11
+ return (...args: P[]) => {
12
+ if (timeoutId) {
13
+ window.clearTimeout(timeoutId)
14
+ }
15
+ timeoutId = window.setTimeout(() => {
16
+ callback(...args)
17
+ }, wait)
18
+ }
19
+ }
20
+
21
+ const AnimationItem = memo(
22
+ ({
23
+ children,
24
+ name,
25
+ copyText,
26
+ onClick,
27
+ }: React.PropsWithChildren<{
28
+ name: string
29
+ copyText: string
30
+ onClick: () => void
31
+ }>) => {
32
+ return (
33
+ <li>
34
+ <button
35
+ onClick={onClick}
36
+ className="uy:group uy:flex uy:flex-col uy:w-full uy:items-center uy:gap-125 uy:p-200 uy:transition-all uy:rounded-100 uy:bg-surface-neutral uy:hover:bg-surface-neutral-low-hover uy:shadow-raising uy:hover:shadow-floating uy:focus-visible:shadow-floating uy:focus-visible:outline-none uy:focus-visible:ring-2 uy:focus-visible:ring-ring uy:focus-visible:ring-offset-2 uy:focus-visible:ring-utility-focus-ring uy:focus-visible:border-border-form-hover uy:focus-visible:bg-surface-neutral-low-hover uy:border uy:border-solid uy:border-border-neutral"
37
+ >
38
+ <figure className="uy:flex uy:flex-col uy:items-center uy:w-full">
39
+ <div
40
+ className="uy:flex uy:justify-center uy:items-center uy:w-full uy:transition-all uy:group-hover:scale-105"
41
+ style={{ maxWidth: '200px' }}
42
+ >
43
+ {children}
44
+ </div>
45
+ <figcaption className="uy:flex uy:flex-col uy:items-center">
46
+ <span className="uy:typography-body-strong uy:text-content-neutral uy:cursor-pointer uy:truncate uy:w-full uy:block">
47
+ {name}
48
+ </span>
49
+ <span className="uy:typography-action-small uy:bg-transparent uy:text-content-primary">
50
+ {copyText}
51
+ </span>
52
+ </figcaption>
53
+ </figure>
54
+ </button>
55
+ </li>
56
+ )
57
+ },
58
+ )
59
+
60
+ const AnimationLibrary = () => {
61
+ const [query, setQuery] = useState<string>('')
62
+ const [copiedAnimation, setCopiedAnimation] = useState<string | null>(null)
63
+
64
+ // Filter only animation names (those ending with 'Animation')
65
+ const animationList = useMemo(() => {
66
+ return illustrationNames.filter(name => name.endsWith('Animation'))
67
+ }, [])
68
+
69
+ const copyToClipboard = useCallback((animationName: string) => {
70
+ const importStatement = `import ${animationName} from '@payfit/unity-illustrations/assets/${animationName}'`
71
+
72
+ navigator.clipboard
73
+ .writeText(importStatement)
74
+ .then(() => {
75
+ setCopiedAnimation(animationName)
76
+ setTimeout(() => {
77
+ setCopiedAnimation(null)
78
+ }, 5000)
79
+ })
80
+ .catch((error: unknown) => {
81
+ console.error('Failed to copy: ', error)
82
+ })
83
+ }, [])
84
+
85
+ const updateSearchQuery = debounce((animationName: string) => {
86
+ setQuery(animationName)
87
+ }, 150)
88
+
89
+ const animationListMatchingSearch = animationList.filter(animationName =>
90
+ animationName.toLowerCase().includes(query.toLowerCase()),
91
+ )
92
+
93
+ return (
94
+ <section className="uy:flex uy:flex-col uy:gap-300 uy:max-w-[80vmax] uy:mx-auto">
95
+ <header>
96
+ <h3>Animation Gallery</h3>
97
+ <p className="uy:m-0!">
98
+ Click on any animation to copy its import path to the clipboard. All animations are displayed with a maximum width of 600px to ensure optimal viewing.
99
+ </p>
100
+ </header>
101
+ <input
102
+ type="search"
103
+ placeholder="Search for an animation..."
104
+ className="uy:flex uy:h-500 uy:w-full uy:text-content-form-enabled uy:rounded-100 uy:border uy:border-solid uy:border-border-form-enabled uy:bg-background uy:px-150 uy:py-100 uy:typography-body uy:placeholder:text-content-neutral-lowest uy:hover:border-border-form-hover uy:focus-visible:outline-none uy:focus-visible:ring-2 uy:focus-visible:ring-ring uy:focus-visible:ring-offset-2 uy:focus-visible:ring-utility-focus-ring"
105
+ onChange={e => {
106
+ updateSearchQuery(e.target.value)
107
+ }}
108
+ />
109
+
110
+ {animationListMatchingSearch.length === 0 ? (
111
+ <div className="uy:text-center uy:py-800">
112
+ <p className="uy:typography-body uy:text-content-tertiary">
113
+ {query ? `No animations found matching "${query}"` : 'No animations available'}
114
+ </p>
115
+ </div>
116
+ ) : (
117
+ <ul className="sb-unstyled uy:list-none uy:grid uy:grid-cols-[repeat(auto-fill,minmax(200px,_1fr))] uy:gap-200">
118
+ {animationListMatchingSearch.map(name => {
119
+ return (
120
+ <AnimationItem
121
+ name={name}
122
+ copyText={
123
+ copiedAnimation === name ? 'Copied!' : 'Click to Copy'
124
+ }
125
+ key={name}
126
+ onClick={() => {
127
+ copyToClipboard(name)
128
+ }}
129
+ >
130
+ <LazyIllustration
131
+ variant="picture"
132
+ alt={`${name} animation`}
133
+ name={name}
134
+ />
135
+ </AnimationItem>
136
+ )
137
+ })}
138
+ </ul>
139
+ )}
140
+ </section>
141
+ )
142
+ }
143
+
144
+ export default AnimationLibrary
@@ -69,7 +69,9 @@ const IllustrationLibrary = ({
69
69
  filter !== undefined
70
70
  ? (name: string) => name.toLowerCase().includes(filter)
71
71
  : () => true
72
- return illustrationNames.filter(name => predicate(name))
72
+ return illustrationNames
73
+ .filter(name => !name.endsWith('Animation'))
74
+ .filter(name => predicate(name))
73
75
  }, [filter])
74
76
 
75
77
  const copyToClipboard = useCallback((illustrationName: string) => {
@@ -0,0 +1,33 @@
1
+ // AUTO-GENERATED FILE. DO NOT EDIT.
2
+ // Source: Type=Animation,Name=accounting.webp (Animated WEBP - 969x852)
3
+ import assetUrl from './assets/AccountingAnimation.webp'
4
+ import type { IllustrationAsset, BaseAnimatedImageAsset } from './types'
5
+
6
+ export type AccountingAnimationAsset = IllustrationAsset<BaseAnimatedImageAsset & {
7
+ readonly name: 'AccountingAnimation'
8
+ }>
9
+
10
+ /**
11
+ * AccountingAnimation animated illustration asset (969x852)
12
+ * @example
13
+ * ```tsx
14
+ * import { Illustration } from '@payfit/unity-illustrations'
15
+ * import AccountingAnimation from '@payfit/unity-illustrations/AccountingAnimation'
16
+ *
17
+ * <Illustration
18
+ * variant="picture"
19
+ * src={AccountingAnimation}
20
+ * alt="Accounting animation"
21
+ * />
22
+ * ```
23
+ */
24
+ const AccountingAnimation: AccountingAnimationAsset = {
25
+ type: 'image',
26
+ url: assetUrl,
27
+ animated: true,
28
+ dimensions: { width: 969, height: 852 },
29
+ category: 'animation',
30
+ name: 'AccountingAnimation',
31
+ } as AccountingAnimationAsset
32
+
33
+ export default AccountingAnimation
@@ -0,0 +1,33 @@
1
+ // AUTO-GENERATED FILE. DO NOT EDIT.
2
+ // Source: Type=Animation,Name=binoculars.webp (Animated WEBP - 750x750)
3
+ import assetUrl from './assets/BinocularsAnimation.webp'
4
+ import type { IllustrationAsset, BaseAnimatedImageAsset } from './types'
5
+
6
+ export type BinocularsAnimationAsset = IllustrationAsset<BaseAnimatedImageAsset & {
7
+ readonly name: 'BinocularsAnimation'
8
+ }>
9
+
10
+ /**
11
+ * BinocularsAnimation animated illustration asset (750x750)
12
+ * @example
13
+ * ```tsx
14
+ * import { Illustration } from '@payfit/unity-illustrations'
15
+ * import BinocularsAnimation from '@payfit/unity-illustrations/BinocularsAnimation'
16
+ *
17
+ * <Illustration
18
+ * variant="picture"
19
+ * src={BinocularsAnimation}
20
+ * alt="Binoculars animation"
21
+ * />
22
+ * ```
23
+ */
24
+ const BinocularsAnimation: BinocularsAnimationAsset = {
25
+ type: 'image',
26
+ url: assetUrl,
27
+ animated: true,
28
+ dimensions: { width: 750, height: 750 },
29
+ category: 'animation',
30
+ name: 'BinocularsAnimation',
31
+ } as BinocularsAnimationAsset
32
+
33
+ export default BinocularsAnimation
@@ -0,0 +1,31 @@
1
+ // AUTO-GENERATED FILE. DO NOT EDIT.
2
+ // Source: Size=large, Type=generic, Name=blank_payslip, With background=no.svg
3
+ import svgUrl from './assets/BlankPayslip.svg'
4
+ import type { IllustrationAsset, BaseSvgAsset } from './types'
5
+
6
+ export type BlankPayslipAsset = IllustrationAsset<BaseSvgAsset & {
7
+ readonly name: 'BlankPayslip'
8
+ }>
9
+
10
+ /**
11
+ * BlankPayslip illustration asset
12
+ * @example
13
+ * ```tsx
14
+ * import { Illustration } from '@payfit/unity-illustrations'
15
+ * import BlankPayslip from '@payfit/unity-illustrations/BlankPayslip'
16
+ *
17
+ * <Illustration
18
+ * illustration={BlankPayslip}
19
+ * alt="BlankPayslip illustration"
20
+ * size="md"
21
+ * />
22
+ * ```
23
+ */
24
+ const BlankPayslip: BlankPayslipAsset = {
25
+ type: 'svg',
26
+ url: svgUrl,
27
+ animated: false,
28
+ name: 'BlankPayslip',
29
+ } as BlankPayslipAsset
30
+
31
+ export default BlankPayslip
@@ -0,0 +1,33 @@
1
+ // AUTO-GENERATED FILE. DO NOT EDIT.
2
+ // Source: Type=Animation,Name=card.webp (Animated WEBP - 224x224)
3
+ import assetUrl from './assets/CardAnimation.webp'
4
+ import type { IllustrationAsset, BaseAnimatedImageAsset } from './types'
5
+
6
+ export type CardAnimationAsset = IllustrationAsset<BaseAnimatedImageAsset & {
7
+ readonly name: 'CardAnimation'
8
+ }>
9
+
10
+ /**
11
+ * CardAnimation animated illustration asset (224x224)
12
+ * @example
13
+ * ```tsx
14
+ * import { Illustration } from '@payfit/unity-illustrations'
15
+ * import CardAnimation from '@payfit/unity-illustrations/CardAnimation'
16
+ *
17
+ * <Illustration
18
+ * variant="picture"
19
+ * src={CardAnimation}
20
+ * alt="Card animation"
21
+ * />
22
+ * ```
23
+ */
24
+ const CardAnimation: CardAnimationAsset = {
25
+ type: 'image',
26
+ url: assetUrl,
27
+ animated: true,
28
+ dimensions: { width: 224, height: 224 },
29
+ category: 'animation',
30
+ name: 'CardAnimation',
31
+ } as CardAnimationAsset
32
+
33
+ export default CardAnimation
@@ -0,0 +1,33 @@
1
+ // AUTO-GENERATED FILE. DO NOT EDIT.
2
+ // Source: Type=Animation,Name=clock.webp (Animated WEBP - 224x224)
3
+ import assetUrl from './assets/ClockAnimation.webp'
4
+ import type { IllustrationAsset, BaseAnimatedImageAsset } from './types'
5
+
6
+ export type ClockAnimationAsset = IllustrationAsset<BaseAnimatedImageAsset & {
7
+ readonly name: 'ClockAnimation'
8
+ }>
9
+
10
+ /**
11
+ * ClockAnimation animated illustration asset (224x224)
12
+ * @example
13
+ * ```tsx
14
+ * import { Illustration } from '@payfit/unity-illustrations'
15
+ * import ClockAnimation from '@payfit/unity-illustrations/ClockAnimation'
16
+ *
17
+ * <Illustration
18
+ * variant="picture"
19
+ * src={ClockAnimation}
20
+ * alt="Clock animation"
21
+ * />
22
+ * ```
23
+ */
24
+ const ClockAnimation: ClockAnimationAsset = {
25
+ type: 'image',
26
+ url: assetUrl,
27
+ animated: true,
28
+ dimensions: { width: 224, height: 224 },
29
+ category: 'animation',
30
+ name: 'ClockAnimation',
31
+ } as ClockAnimationAsset
32
+
33
+ export default ClockAnimation
@@ -0,0 +1,33 @@
1
+ // AUTO-GENERATED FILE. DO NOT EDIT.
2
+ // Source: Type=Animation,Name=confettis.webp (Animated WEBP - 224x224)
3
+ import assetUrl from './assets/ConfettisAnimation.webp'
4
+ import type { IllustrationAsset, BaseAnimatedImageAsset } from './types'
5
+
6
+ export type ConfettisAnimationAsset = IllustrationAsset<BaseAnimatedImageAsset & {
7
+ readonly name: 'ConfettisAnimation'
8
+ }>
9
+
10
+ /**
11
+ * ConfettisAnimation animated illustration asset (224x224)
12
+ * @example
13
+ * ```tsx
14
+ * import { Illustration } from '@payfit/unity-illustrations'
15
+ * import ConfettisAnimation from '@payfit/unity-illustrations/ConfettisAnimation'
16
+ *
17
+ * <Illustration
18
+ * variant="picture"
19
+ * src={ConfettisAnimation}
20
+ * alt="Confettis animation"
21
+ * />
22
+ * ```
23
+ */
24
+ const ConfettisAnimation: ConfettisAnimationAsset = {
25
+ type: 'image',
26
+ url: assetUrl,
27
+ animated: true,
28
+ dimensions: { width: 224, height: 224 },
29
+ category: 'animation',
30
+ name: 'ConfettisAnimation',
31
+ } as ConfettisAnimationAsset
32
+
33
+ export default ConfettisAnimation
@@ -0,0 +1,33 @@
1
+ // AUTO-GENERATED FILE. DO NOT EDIT.
2
+ // Source: Type=Animation,Name=document.webp (Animated WEBP - 224x224)
3
+ import assetUrl from './assets/DocumentAnimation.webp'
4
+ import type { IllustrationAsset, BaseAnimatedImageAsset } from './types'
5
+
6
+ export type DocumentAnimationAsset = IllustrationAsset<BaseAnimatedImageAsset & {
7
+ readonly name: 'DocumentAnimation'
8
+ }>
9
+
10
+ /**
11
+ * DocumentAnimation animated illustration asset (224x224)
12
+ * @example
13
+ * ```tsx
14
+ * import { Illustration } from '@payfit/unity-illustrations'
15
+ * import DocumentAnimation from '@payfit/unity-illustrations/DocumentAnimation'
16
+ *
17
+ * <Illustration
18
+ * variant="picture"
19
+ * src={DocumentAnimation}
20
+ * alt="Document animation"
21
+ * />
22
+ * ```
23
+ */
24
+ const DocumentAnimation: DocumentAnimationAsset = {
25
+ type: 'image',
26
+ url: assetUrl,
27
+ animated: true,
28
+ dimensions: { width: 224, height: 224 },
29
+ category: 'animation',
30
+ name: 'DocumentAnimation',
31
+ } as DocumentAnimationAsset
32
+
33
+ export default DocumentAnimation