@payfit/unity-illustrations 2.55.21 → 2.55.23
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.
- package/package.json +18 -11
- package/skills/unity-illustrations/SKILL.md +39 -0
- package/src/agent-references/illustrations-catalog.json +1996 -0
- package/src/agent-references/manifest.json +16 -0
- package/dist/esm/scripts/agent-references/illustration-reference.d.ts +0 -17
- package/src/agent-references/README.mdx +0 -17
- package/src/agent-references/illustrations.mdx +0 -74
- package/src/components/illustration/Illustration.stories.tsx +0 -362
- package/src/components/illustration/Illustration.tsx +0 -169
- package/src/components/illustration/figma/IllustrationLarge.figma.ts +0 -258
- package/src/components/illustration/figma/IllustrationMedium.figma.ts +0 -258
- package/src/components/illustration/figma/IllustrationSmall.figma.ts +0 -258
- package/src/components/lazy-illustration/LazyIllustration.stories.tsx +0 -204
- package/src/components/lazy-illustration/LazyIllustration.tsx +0 -125
- package/src/components/lazy-illustration/figma/LazyIllustrationLarge.figma.ts +0 -255
- package/src/components/lazy-illustration/figma/LazyIllustrationMedium.figma.ts +0 -255
- package/src/components/lazy-illustration/figma/LazyIllustrationSmall.figma.ts +0 -255
- package/src/docs/1-Introduction/1-Welcome.mdx +0 -111
- package/src/docs/1-Introduction/2-Getting Started.mdx +0 -25
- package/src/docs/1-Introduction/3-Usage.mdx +0 -114
- package/src/docs/1-Introduction/4-Changelog.mdx +0 -6
- package/src/docs/2-Reference/1-Find my illustration.mdx +0 -12
- package/src/docs/2-Reference/2-Find my animation.mdx +0 -14
- package/src/docs/2-Reference/3-Multi brand support.mdx +0 -146
- package/src/docs/blocks/AnimationLibrary.tsx +0 -181
- package/src/docs/blocks/BrandSupportBadge.tsx +0 -190
- package/src/docs/blocks/BrandSupportFilter.tsx +0 -72
- package/src/docs/blocks/Cards.tsx +0 -74
- package/src/docs/blocks/IllustrationLibrary.tsx +0 -179
- package/src/docs/blocks/useStorybookTheme.ts +0 -73
- package/src/index.ts +0 -4
- package/src/scripts/agent-references/illustration-reference.test.ts +0 -100
- package/src/scripts/agent-references/illustration-reference.ts +0 -140
- package/src/scripts/generate-assets.ts +0 -649
- package/src/scripts/templates/assetTemplate.ts +0 -224
- package/src/scripts/templates/baseTypes.ts +0 -45
- package/src/scripts/templates/indexTemplate.ts +0 -109
- package/src/unity.css +0 -5
|
@@ -1,258 +0,0 @@
|
|
|
1
|
-
// url=https://www.figma.com/design/NYcgOc3qMmcEDNqD6kD8J4?node-id=214-3597
|
|
2
|
-
// component=Illustration
|
|
3
|
-
// source=https://github.com/PayFit/hr-apps/blob/master/libs/shared/unity/illustrations/src/components/illustration/Illustration.tsx
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* AUTO-GENERATED - DO NOT EDIT
|
|
7
|
-
*
|
|
8
|
-
* Template file for Figma Code Connect - Illustration component (Small)
|
|
9
|
-
*
|
|
10
|
-
* Handles dynamic mapping of:
|
|
11
|
-
* - Name property -> PascalCase code name
|
|
12
|
-
* - Type property -> "EmptyState" prefix for empty-state type
|
|
13
|
-
* - With background property -> "WithBackground" suffix
|
|
14
|
-
*/
|
|
15
|
-
|
|
16
|
-
import figma from 'figma'
|
|
17
|
-
const instance = figma.selectedInstance
|
|
18
|
-
|
|
19
|
-
const nameValue = instance.getEnum('Name', {
|
|
20
|
-
accounting: 'Accounting',
|
|
21
|
-
activation_button: 'ActivationButton',
|
|
22
|
-
activation_toggle: 'ActivationToggle',
|
|
23
|
-
add_employee: 'AddEmployee',
|
|
24
|
-
administrative_document: 'AdministrativeDocument',
|
|
25
|
-
alphabet_cube: 'AlphabetCube',
|
|
26
|
-
analysis: 'Analysis',
|
|
27
|
-
annual_taxes: 'AnnualTaxes',
|
|
28
|
-
automation_in_progress: 'AutomationInProgress',
|
|
29
|
-
baby_bottle: 'BabyBottle',
|
|
30
|
-
bell: 'Bell',
|
|
31
|
-
bicycle: 'Bicycle',
|
|
32
|
-
big_idea: 'BigIdea',
|
|
33
|
-
binoculars: 'Binoculars',
|
|
34
|
-
biscuit: 'Biscuit',
|
|
35
|
-
biscuit_crumbs: 'BiscuitCrumbs',
|
|
36
|
-
blank_payslip: 'BlankPayslip',
|
|
37
|
-
book: 'Book',
|
|
38
|
-
box: 'Box',
|
|
39
|
-
brainstorming: 'Brainstorming',
|
|
40
|
-
buoy: 'Buoy',
|
|
41
|
-
calculator: 'Calculator',
|
|
42
|
-
calendar: 'Calendar',
|
|
43
|
-
card: 'Card',
|
|
44
|
-
character_headphone: 'CharacterHeadphone',
|
|
45
|
-
chat: 'Chat',
|
|
46
|
-
checkbox: 'Checkbox',
|
|
47
|
-
christmas_sock: 'ChristmasSock',
|
|
48
|
-
christmas_sock_and_confettis: 'ChristmasSockAndConfettis',
|
|
49
|
-
clock: 'Clock',
|
|
50
|
-
closed_lock: 'ClosedLock',
|
|
51
|
-
collaboration: 'Collaboration',
|
|
52
|
-
collective_research: 'CollectiveResearch',
|
|
53
|
-
computer_documentation: 'ComputerDocumentation',
|
|
54
|
-
computer_mail: 'ComputerMail',
|
|
55
|
-
confetti_cannon: 'ConfettiCannon',
|
|
56
|
-
confettis: 'Confettis',
|
|
57
|
-
contact: 'Contact',
|
|
58
|
-
contract_signature: 'ContractSignature',
|
|
59
|
-
conversation: 'Conversation',
|
|
60
|
-
cross_legged: 'CrossLegged',
|
|
61
|
-
cup_of_coffee: 'CupOfCoffee',
|
|
62
|
-
dancing: 'Dancing',
|
|
63
|
-
dancing_people: 'DancingPeople',
|
|
64
|
-
dancing_skier: 'DancingSkier',
|
|
65
|
-
data: 'Data',
|
|
66
|
-
desert: 'Desert',
|
|
67
|
-
dialogue: 'Dialogue',
|
|
68
|
-
discount: 'Discount',
|
|
69
|
-
discussion: 'Discussion',
|
|
70
|
-
doctor: 'Doctor',
|
|
71
|
-
document: 'Document',
|
|
72
|
-
document_creation: 'DocumentCreation',
|
|
73
|
-
document_error: 'DocumentError',
|
|
74
|
-
document_filing: 'DocumentFiling',
|
|
75
|
-
document_scan: 'DocumentScan',
|
|
76
|
-
document_scanning: 'DocumentScanning',
|
|
77
|
-
e_signature: 'ESignature',
|
|
78
|
-
email_login: 'EmailLogin',
|
|
79
|
-
email_notification: 'EmailNotification',
|
|
80
|
-
emergency_contact: 'EmergencyContact',
|
|
81
|
-
employment_contract: 'EmploymentContract',
|
|
82
|
-
empty_document: 'EmptyDocument',
|
|
83
|
-
empty_folder: 'EmptyFolder',
|
|
84
|
-
empty_state: 'EmptyState',
|
|
85
|
-
evaluation: 'Evaluation',
|
|
86
|
-
exceeding_threshold: 'ExceedingThreshold',
|
|
87
|
-
exceptional_compensation: 'ExceptionalCompensation',
|
|
88
|
-
expenses: 'Expenses',
|
|
89
|
-
FAQ: 'FAQ',
|
|
90
|
-
field_glasses: 'FieldGlasses',
|
|
91
|
-
filing_documents: 'FilingDocuments',
|
|
92
|
-
flowchart: 'Flowchart',
|
|
93
|
-
free_share: 'FreeShare',
|
|
94
|
-
full_calendar: 'FullCalendar',
|
|
95
|
-
gear: 'Gear',
|
|
96
|
-
gift: 'Gift',
|
|
97
|
-
golden_ribbon: 'GoldenRibbon',
|
|
98
|
-
graph: 'Graph',
|
|
99
|
-
graphic: 'Graphic',
|
|
100
|
-
half_calendar: 'HalfCalendar',
|
|
101
|
-
hammer: 'Hammer',
|
|
102
|
-
hand_hello: 'HandHello',
|
|
103
|
-
hands: 'Hands',
|
|
104
|
-
happy_character: 'HappyCharacter',
|
|
105
|
-
health: 'Health',
|
|
106
|
-
health_insurance: 'HealthInsurance',
|
|
107
|
-
high_five: 'HighFive',
|
|
108
|
-
highlight_books: 'HighlightBooks',
|
|
109
|
-
holiday_voucher: 'HolidayVoucher',
|
|
110
|
-
idea: 'Idea',
|
|
111
|
-
identity_card: 'IdentityCard',
|
|
112
|
-
incident_panel: 'IncidentPanel',
|
|
113
|
-
indicate_something: 'IndicateSomething',
|
|
114
|
-
information_update: 'InformationUpdate',
|
|
115
|
-
JEI_JEU_JEC: 'JeiJeuJec',
|
|
116
|
-
jetlang_calculator: 'JetlangCalculator',
|
|
117
|
-
kanoon: 'Kanoon',
|
|
118
|
-
kpmg: 'Kpmg',
|
|
119
|
-
legal_help: 'LegalHelp',
|
|
120
|
-
letter_box: 'LetterBox',
|
|
121
|
-
library: 'Library',
|
|
122
|
-
light_bulb: 'LightBulb',
|
|
123
|
-
little_rocket: 'LittleRocket',
|
|
124
|
-
lunch_voucher: 'LunchVoucher',
|
|
125
|
-
magnifying_glass: 'MagnifyingGlass',
|
|
126
|
-
maintenance: 'Maintenance',
|
|
127
|
-
marteler: 'Marteler',
|
|
128
|
-
meal_plate: 'MealPlate',
|
|
129
|
-
meal_voucher: 'MealVoucher',
|
|
130
|
-
meal_voucher_card: 'MealVoucherCard',
|
|
131
|
-
mobility: 'Mobility',
|
|
132
|
-
money_lending: 'MoneyLending',
|
|
133
|
-
moon: 'Moon',
|
|
134
|
-
mug: 'Mug',
|
|
135
|
-
notes: 'Notes',
|
|
136
|
-
official_letter: 'OfficialLetter',
|
|
137
|
-
open_lock: 'OpenLock',
|
|
138
|
-
organismes_payment: 'OrganismesPayment',
|
|
139
|
-
paid_leave: 'PaidLeave',
|
|
140
|
-
panel: 'Panel',
|
|
141
|
-
paper_plane: 'PaperPlane',
|
|
142
|
-
party: 'Party',
|
|
143
|
-
payfitters_with_badge: 'PayfittersWithBadge',
|
|
144
|
-
payment_information: 'PaymentInformation',
|
|
145
|
-
payroll_error: 'PayrollError',
|
|
146
|
-
payslip: 'Payslip',
|
|
147
|
-
payslip_coins: 'PayslipCoins',
|
|
148
|
-
pen: 'Pen',
|
|
149
|
-
people: 'People',
|
|
150
|
-
performance: 'Performance',
|
|
151
|
-
performance_discussion: 'PerformanceDiscussion',
|
|
152
|
-
person: 'Person',
|
|
153
|
-
person_headphone: 'PersonHeadphone',
|
|
154
|
-
personal_details: 'PersonalDetails',
|
|
155
|
-
phone_message: 'PhoneMessage',
|
|
156
|
-
piggy_bank: 'PiggyBank',
|
|
157
|
-
piggy_bank_coins: 'PiggyBankCoins',
|
|
158
|
-
planet: 'Planet',
|
|
159
|
-
plant: 'Plant',
|
|
160
|
-
post_it: 'PostIt',
|
|
161
|
-
progression: 'Progression',
|
|
162
|
-
promotion: 'Promotion',
|
|
163
|
-
provident_scheme: 'ProvidentScheme',
|
|
164
|
-
puzzle: 'Puzzle',
|
|
165
|
-
puzzle_piece: 'PuzzlePiece',
|
|
166
|
-
reading_a_book: 'ReadingABook',
|
|
167
|
-
receiving_pay: 'ReceivingPay',
|
|
168
|
-
rehire_employee: 'RehireEmployee',
|
|
169
|
-
remote: 'Remote',
|
|
170
|
-
remote_work: 'RemoteWork',
|
|
171
|
-
report: 'Report',
|
|
172
|
-
research: 'Research',
|
|
173
|
-
rocket: 'Rocket',
|
|
174
|
-
safe_deposit_box: 'SafeDepositBox',
|
|
175
|
-
salary: 'Salary',
|
|
176
|
-
salary_advance: 'SalaryAdvance',
|
|
177
|
-
salary_payment: 'SalaryPayment',
|
|
178
|
-
salary_seizure: 'SalarySeizure',
|
|
179
|
-
sale: 'Sale',
|
|
180
|
-
sand_castle: 'SandCastle',
|
|
181
|
-
schedule: 'Schedule',
|
|
182
|
-
security_fields: 'SecurityFields',
|
|
183
|
-
set_up_task: 'SetUpTask',
|
|
184
|
-
setting_slider: 'SettingSlider',
|
|
185
|
-
sick_leave: 'SickLeave',
|
|
186
|
-
signature: 'Signature',
|
|
187
|
-
sitting_on_the_sofa: 'SittingOnTheSofa',
|
|
188
|
-
small_puzzle: 'SmallPuzzle',
|
|
189
|
-
smiling_character: 'SmilingCharacter',
|
|
190
|
-
solve_problem: 'SolveProblem',
|
|
191
|
-
speaker_fingertips: 'SpeakerFingertips',
|
|
192
|
-
speaker_welcome: 'SpeakerWelcome',
|
|
193
|
-
speaker_with_microphone: 'SpeakerWithMicrophone',
|
|
194
|
-
spreadsheet: 'Spreadsheet',
|
|
195
|
-
stack_of_book_2: 'StackOfBook2',
|
|
196
|
-
stair_treads: 'StairTreads',
|
|
197
|
-
stethoscope: 'Stethoscope',
|
|
198
|
-
stock_options: 'StockOptions',
|
|
199
|
-
stopwatch: 'Stopwatch',
|
|
200
|
-
sunshade: 'Sunshade',
|
|
201
|
-
taking_note: 'TakingNote',
|
|
202
|
-
target: 'Target',
|
|
203
|
-
task_to_do: 'TaskToDo',
|
|
204
|
-
team_building: 'TeamBuilding',
|
|
205
|
-
telescope: 'Telescope',
|
|
206
|
-
template: 'Template',
|
|
207
|
-
template_form: 'TemplateForm',
|
|
208
|
-
thumbsup: 'Thumbsup',
|
|
209
|
-
thumbtack: 'Thumbtack',
|
|
210
|
-
time_tracking: 'TimeTracking',
|
|
211
|
-
timer: 'Timer',
|
|
212
|
-
tips_jar: 'TipsJar',
|
|
213
|
-
to_do: 'ToDo',
|
|
214
|
-
toggle_off: 'ToggleOff',
|
|
215
|
-
toggle_on: 'ToggleOn',
|
|
216
|
-
token_coin: 'TokenCoin',
|
|
217
|
-
trophy: 'Trophy',
|
|
218
|
-
trophy_won: 'TrophyWon',
|
|
219
|
-
validation_window: 'ValidationWindow',
|
|
220
|
-
visually_impaired: 'VisuallyImpaired',
|
|
221
|
-
visually_impaired_winter: 'VisuallyImpairedWinter',
|
|
222
|
-
walking_people: 'WalkingPeople',
|
|
223
|
-
winter_party: 'WinterParty',
|
|
224
|
-
work_at_office: 'WorkAtOffice',
|
|
225
|
-
work_expense: 'WorkExpense',
|
|
226
|
-
work_from_anywhere: 'WorkFromAnywhere',
|
|
227
|
-
working_time: 'WorkingTime',
|
|
228
|
-
wrench: 'Wrench',
|
|
229
|
-
write_book: 'WriteBook',
|
|
230
|
-
})
|
|
231
|
-
|
|
232
|
-
const typeValue = instance.getEnum('Type', {
|
|
233
|
-
generic: 'generic',
|
|
234
|
-
specific: 'specific',
|
|
235
|
-
'empty-state': 'empty-state',
|
|
236
|
-
})
|
|
237
|
-
|
|
238
|
-
const withBackgroundValue = instance.getBoolean('With background')
|
|
239
|
-
const nameWithType =
|
|
240
|
-
typeValue === 'empty-state' ? `EmptyState${nameValue ?? ''}` : nameValue
|
|
241
|
-
const finalSrc = withBackgroundValue
|
|
242
|
-
? `${nameWithType}WithBackground`
|
|
243
|
-
: nameWithType
|
|
244
|
-
|
|
245
|
-
const code = figma.tsx`<Illustration
|
|
246
|
-
src={${finalSrc}}
|
|
247
|
-
variant="picture"
|
|
248
|
-
alt="${finalSrc} illustration"
|
|
249
|
-
/>`
|
|
250
|
-
|
|
251
|
-
export default {
|
|
252
|
-
id: 'illustration-small',
|
|
253
|
-
example: code,
|
|
254
|
-
imports: [
|
|
255
|
-
"import { Illustration } from '@payfit/unity-illustrations'",
|
|
256
|
-
`import ${finalSrc} from '@payfit/unity-illustrations/assets/${finalSrc}'`,
|
|
257
|
-
],
|
|
258
|
-
}
|
|
@@ -1,204 +0,0 @@
|
|
|
1
|
-
import { UnityThemeProvider } from '@payfit/unity-themes'
|
|
2
|
-
|
|
3
|
-
import { LazyIllustration } from './LazyIllustration'
|
|
4
|
-
import preview from '../../../.storybook/preview'
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* The LazyIllustration component dynamically imports illustrations based on their name.
|
|
8
|
-
* It uses the lazyIllustrationsMap from the generated illustrationAssets file to load
|
|
9
|
-
* the corresponding illustration and pass it to the Illustration component.
|
|
10
|
-
*/
|
|
11
|
-
const meta = preview.meta({
|
|
12
|
-
title: 'Components/LazyIllustration',
|
|
13
|
-
component: LazyIllustration,
|
|
14
|
-
tags: ['autodocs'],
|
|
15
|
-
parameters: {
|
|
16
|
-
layout: 'centered',
|
|
17
|
-
},
|
|
18
|
-
argTypes: {
|
|
19
|
-
name: {
|
|
20
|
-
control: 'select',
|
|
21
|
-
options: [
|
|
22
|
-
'FAQ',
|
|
23
|
-
'Binoculars',
|
|
24
|
-
'WriteBook',
|
|
25
|
-
'VisuallyImpaired',
|
|
26
|
-
'Library',
|
|
27
|
-
'AccountingAnimation',
|
|
28
|
-
'BinocularsAnimation',
|
|
29
|
-
'CardAnimation',
|
|
30
|
-
],
|
|
31
|
-
description:
|
|
32
|
-
'The name of the illustration to load dynamically. This must be one of the valid illustration names from the Unity illustration library',
|
|
33
|
-
table: {
|
|
34
|
-
type: { summary: 'UnityIllustrationName' },
|
|
35
|
-
category: 'Required',
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
variant: {
|
|
39
|
-
control: 'select',
|
|
40
|
-
options: ['picture', 'icon'],
|
|
41
|
-
description:
|
|
42
|
-
'The illustration variant. It can be a regular picture or an illustrated icon',
|
|
43
|
-
table: {
|
|
44
|
-
type: { summary: "'picture' | 'icon'" },
|
|
45
|
-
category: 'Required',
|
|
46
|
-
},
|
|
47
|
-
},
|
|
48
|
-
alt: {
|
|
49
|
-
control: 'text',
|
|
50
|
-
description:
|
|
51
|
-
'Accessible name for the illustration. Required when isDecorative is `true`',
|
|
52
|
-
table: {
|
|
53
|
-
type: { summary: 'string' },
|
|
54
|
-
category: 'Accessibility',
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
// @ts-expect-error - Typescript can't handle the union type properly, but the prop exist
|
|
58
|
-
description: {
|
|
59
|
-
control: 'text',
|
|
60
|
-
description:
|
|
61
|
-
'Optional description for complex illustrations. Active only when isDecorative is `true`',
|
|
62
|
-
table: {
|
|
63
|
-
type: { summary: 'string' },
|
|
64
|
-
category: 'Accessibility',
|
|
65
|
-
},
|
|
66
|
-
},
|
|
67
|
-
isDecorative: {
|
|
68
|
-
control: 'boolean',
|
|
69
|
-
description:
|
|
70
|
-
'Whether the illustration is decorative (hidden from screen readers). When `true`, `alt` becomes optional',
|
|
71
|
-
table: {
|
|
72
|
-
type: { summary: 'boolean' },
|
|
73
|
-
defaultValue: { summary: 'false' },
|
|
74
|
-
category: 'Accessibility',
|
|
75
|
-
},
|
|
76
|
-
},
|
|
77
|
-
size: {
|
|
78
|
-
control: 'select',
|
|
79
|
-
options: ['sm', 'md', 'lg'],
|
|
80
|
-
description: 'The size of the illustration. Only applies to icon variant',
|
|
81
|
-
if: { arg: 'variant', eq: 'icon' },
|
|
82
|
-
table: {
|
|
83
|
-
type: { summary: "'sm' | 'md' | 'lg'" },
|
|
84
|
-
category: 'Icon Variant',
|
|
85
|
-
},
|
|
86
|
-
},
|
|
87
|
-
className: {
|
|
88
|
-
control: 'text',
|
|
89
|
-
description: 'Additional CSS classes for styling',
|
|
90
|
-
table: {
|
|
91
|
-
type: { summary: 'string' },
|
|
92
|
-
category: 'Styling',
|
|
93
|
-
},
|
|
94
|
-
},
|
|
95
|
-
},
|
|
96
|
-
})
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Basic usage of the LazyIllustration component with a picture variant.
|
|
100
|
-
* Simply provide the name of the illustration you want to load.
|
|
101
|
-
*/
|
|
102
|
-
export const Primary = meta.story({
|
|
103
|
-
args: {
|
|
104
|
-
variant: 'picture',
|
|
105
|
-
name: 'Binoculars',
|
|
106
|
-
className: 'uy:size-[150px]',
|
|
107
|
-
alt: 'Binoculars Illustration',
|
|
108
|
-
},
|
|
109
|
-
})
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* You can create responsive illustrations that adapt to different screen sizes by using responsive
|
|
113
|
-
* Tailwind classes in the `className` prop. Set the `alt` prop to provide accessible descriptions
|
|
114
|
-
* for screen readers when using the picture variant.
|
|
115
|
-
*/
|
|
116
|
-
export const IllustratedPicture = meta.story({
|
|
117
|
-
args: {
|
|
118
|
-
variant: 'picture',
|
|
119
|
-
name: 'VisuallyImpaired',
|
|
120
|
-
className: 'uy:size-[50vmin]',
|
|
121
|
-
alt: 'Visually impaired person illustration',
|
|
122
|
-
},
|
|
123
|
-
})
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* You can use the LazyIllustration component with the icon variant as well.
|
|
127
|
-
* Specify the size prop to control the dimensions of the icon.
|
|
128
|
-
*/
|
|
129
|
-
export const IconVariant = meta.story({
|
|
130
|
-
args: {
|
|
131
|
-
variant: 'icon',
|
|
132
|
-
name: 'Binoculars',
|
|
133
|
-
size: 'md',
|
|
134
|
-
alt: 'Binoculars Illustration',
|
|
135
|
-
},
|
|
136
|
-
})
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* LazyIllustration keeps the same logical name API while still resolving theme-aware illustration URLs.
|
|
140
|
-
* The loaded asset is delegated to Illustration, so switching the active Unity theme updates the rendered source when a themed variant exists.
|
|
141
|
-
*/
|
|
142
|
-
export const ThemeVariants = meta.story({
|
|
143
|
-
render: () => {
|
|
144
|
-
return (
|
|
145
|
-
<div className="uy:flex uy:flex-wrap uy:items-start uy:gap-400">
|
|
146
|
-
<UnityThemeProvider theme="legacy">
|
|
147
|
-
<div className="uy:flex uy:flex-col uy:items-center uy:gap-150">
|
|
148
|
-
<LazyIllustration
|
|
149
|
-
name="FAQ"
|
|
150
|
-
variant="icon"
|
|
151
|
-
size="lg"
|
|
152
|
-
alt="FAQ legacy icon"
|
|
153
|
-
/>
|
|
154
|
-
<span className="uy:typography-caption uy:text-content-secondary">
|
|
155
|
-
legacy
|
|
156
|
-
</span>
|
|
157
|
-
</div>
|
|
158
|
-
</UnityThemeProvider>
|
|
159
|
-
<UnityThemeProvider theme="rebrand">
|
|
160
|
-
<div className="uy:flex uy:flex-col uy:items-center uy:gap-150">
|
|
161
|
-
<LazyIllustration
|
|
162
|
-
name="FAQ"
|
|
163
|
-
variant="icon"
|
|
164
|
-
size="lg"
|
|
165
|
-
alt="FAQ rebrand icon"
|
|
166
|
-
/>
|
|
167
|
-
<span className="uy:typography-caption uy:text-content-secondary">
|
|
168
|
-
rebrand
|
|
169
|
-
</span>
|
|
170
|
-
</div>
|
|
171
|
-
</UnityThemeProvider>
|
|
172
|
-
</div>
|
|
173
|
-
)
|
|
174
|
-
},
|
|
175
|
-
})
|
|
176
|
-
|
|
177
|
-
/**
|
|
178
|
-
* You can create responsive illustrations that adapt to different screen sizes
|
|
179
|
-
* by using responsive Tailwind classes in the className prop.
|
|
180
|
-
*/
|
|
181
|
-
export const Responsive = meta.story({
|
|
182
|
-
args: {
|
|
183
|
-
variant: 'picture',
|
|
184
|
-
name: 'WriteBook',
|
|
185
|
-
className: 'uy:size-[50vmin]',
|
|
186
|
-
alt: 'Write Book Illustration',
|
|
187
|
-
},
|
|
188
|
-
})
|
|
189
|
-
|
|
190
|
-
/**
|
|
191
|
-
* You can use animated illustrations with the LazyIllustration component. Animated illustrations
|
|
192
|
-
* have the `Animation` suffix and are automatically loaded with their fluid sizing behavior.
|
|
193
|
-
* The component detects animated assets and applies maximum dimension constraints to prevent oversizing.
|
|
194
|
-
*/
|
|
195
|
-
export const AnimatedIllustrations = meta.story({
|
|
196
|
-
parameters: {
|
|
197
|
-
chromatic: { disableSnapshot: true },
|
|
198
|
-
},
|
|
199
|
-
args: {
|
|
200
|
-
variant: 'picture',
|
|
201
|
-
name: 'AccountingAnimation',
|
|
202
|
-
alt: 'Accounting animation showing financial calculations',
|
|
203
|
-
},
|
|
204
|
-
})
|
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import { forwardRef, useEffect, useState } from 'react'
|
|
2
|
-
|
|
3
|
-
import type {
|
|
4
|
-
UnityIllustrationAsset,
|
|
5
|
-
UnityIllustrationName,
|
|
6
|
-
} from '../../generated/illustrationAssets'
|
|
7
|
-
import type {
|
|
8
|
-
IllustratedIconProps,
|
|
9
|
-
IllustratedPictureProps,
|
|
10
|
-
} from '../illustration/Illustration'
|
|
11
|
-
|
|
12
|
-
import { lazyIllustrationsMap } from '../../generated/illustrationAssets'
|
|
13
|
-
import {
|
|
14
|
-
illustratedIcon,
|
|
15
|
-
illustratedPicture,
|
|
16
|
-
Illustration,
|
|
17
|
-
} from '../illustration/Illustration'
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Props for the LazyIllustration component.
|
|
21
|
-
*
|
|
22
|
-
* This type is a union of two possible prop types:
|
|
23
|
-
* 1. Props for the picture variant (omitting 'src' and adding 'name')
|
|
24
|
-
* 2. Props for the icon variant (omitting 'src' and adding 'name')
|
|
25
|
-
* @property {UnityIllustrationName} name - The name of the illustration to load dynamically.
|
|
26
|
-
* This must be one of the valid illustration names from the Unity illustration library.
|
|
27
|
-
* @property {'picture' | 'icon'} variant - The illustration variant. It can be a regular picture or an illustrated icon.
|
|
28
|
-
* @property {string} alt - Accessible name for the illustration (required when isDecorative is false or undefined).
|
|
29
|
-
* @property {string} [description] - Optional description for complex illustrations.
|
|
30
|
-
* @property {boolean} [isDecorative] - Whether this is decorative (hidden from screen readers).
|
|
31
|
-
* @property {'sm' | 'md' | 'lg'} [size] - The size of the illustration. Required when variant is 'icon'.
|
|
32
|
-
*/
|
|
33
|
-
export type LazyIllustrationProps =
|
|
34
|
-
| (Omit<IllustratedPictureProps, 'src'> & { name: UnityIllustrationName })
|
|
35
|
-
| (Omit<IllustratedIconProps, 'src'> & { name: UnityIllustrationName })
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* A component that lazily loads illustrations by name and renders them using the Illustration component.
|
|
39
|
-
*
|
|
40
|
-
* The LazyIllustration component dynamically imports illustrations based on their name using the
|
|
41
|
-
* lazyIllustrationsMap from the generated illustrationAssets file. This allows for code-splitting
|
|
42
|
-
* and on-demand loading of illustrations, which can significantly improve initial load performance.
|
|
43
|
-
* @param {LazyIllustrationProps} props - Component props including name, variant, and standard HTML attributes
|
|
44
|
-
* @see {@link LazyIllustrationProps} for all available props
|
|
45
|
-
* @example
|
|
46
|
-
* ```tsx
|
|
47
|
-
* import { LazyIllustration } from '@payfit/unity-illustrations'
|
|
48
|
-
*
|
|
49
|
-
* function Example() {
|
|
50
|
-
* return (
|
|
51
|
-
* <LazyIllustration
|
|
52
|
-
* variant="picture"
|
|
53
|
-
* name="FAQ"
|
|
54
|
-
* className="uy:size-[150px]"
|
|
55
|
-
* alt="FAQ illustration"
|
|
56
|
-
* />
|
|
57
|
-
* )
|
|
58
|
-
* }
|
|
59
|
-
* ```
|
|
60
|
-
* @example
|
|
61
|
-
* ```tsx
|
|
62
|
-
* // Using with icon variant
|
|
63
|
-
* import { LazyIllustration } from '@payfit/unity-illustrations'
|
|
64
|
-
*
|
|
65
|
-
* function IconExample() {
|
|
66
|
-
* return (
|
|
67
|
-
* <LazyIllustration
|
|
68
|
-
* variant="icon"
|
|
69
|
-
* size="md"
|
|
70
|
-
* name="Binoculars"
|
|
71
|
-
* alt="Binoculars icon"
|
|
72
|
-
* />
|
|
73
|
-
* )
|
|
74
|
-
* }
|
|
75
|
-
* ```
|
|
76
|
-
* @remarks
|
|
77
|
-
* Unlike the Illustration component, you don't need to import illustration assets individually.
|
|
78
|
-
* Simply provide the name of the illustration you want to use, and LazyIllustration will handle
|
|
79
|
-
* the dynamic import for you. The component returns null during loading, so you may want to
|
|
80
|
-
* provide your own loading state or placeholder.
|
|
81
|
-
*/
|
|
82
|
-
export const LazyIllustration = forwardRef<
|
|
83
|
-
HTMLImageElement,
|
|
84
|
-
LazyIllustrationProps
|
|
85
|
-
>(({ name, ...props }, ref) => {
|
|
86
|
-
const [illustration, setIllustration] =
|
|
87
|
-
useState<UnityIllustrationAsset | null>(null)
|
|
88
|
-
const [isLoading, setIsLoading] = useState(true)
|
|
89
|
-
|
|
90
|
-
useEffect(() => {
|
|
91
|
-
const loadIllustration = async () => {
|
|
92
|
-
try {
|
|
93
|
-
setIsLoading(true)
|
|
94
|
-
const importFn = lazyIllustrationsMap[name]
|
|
95
|
-
|
|
96
|
-
const module = await importFn()
|
|
97
|
-
setIllustration(module.default)
|
|
98
|
-
} catch (error) {
|
|
99
|
-
console.error(`Failed to load illustration "${name}":`, error)
|
|
100
|
-
} finally {
|
|
101
|
-
setIsLoading(false)
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
void loadIllustration()
|
|
106
|
-
}, [name])
|
|
107
|
-
|
|
108
|
-
if (isLoading || !illustration) {
|
|
109
|
-
const clsx =
|
|
110
|
-
props.variant === 'picture'
|
|
111
|
-
? illustratedPicture({ className: props.className })
|
|
112
|
-
: illustratedIcon({
|
|
113
|
-
className: props.className,
|
|
114
|
-
size: (props as IllustratedIconProps).size,
|
|
115
|
-
})
|
|
116
|
-
return <div className={clsx} />
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
// Handle the discriminated union by using type assertion
|
|
120
|
-
// This is safe because LazyIllustrationProps inherits from IllustrationProps (excluding src and name)
|
|
121
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
122
|
-
return <Illustration ref={ref} src={illustration} {...(props as any)} />
|
|
123
|
-
})
|
|
124
|
-
|
|
125
|
-
LazyIllustration.displayName = 'LazyIllustration'
|