@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,224 +0,0 @@
|
|
|
1
|
-
import path from 'path'
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Generates a single asset module
|
|
5
|
-
*/
|
|
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
|
-
) {
|
|
12
|
-
// Use relative path from the generated TypeScript file to the optimized asset
|
|
13
|
-
const relativePath = `./assets/${path.basename(optimizedAssetPath)}`
|
|
14
|
-
|
|
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') {
|
|
19
|
-
return generateSvgAsset(componentName, relativePath, originalFileName)
|
|
20
|
-
} else {
|
|
21
|
-
return generateImageAsset(componentName, relativePath, originalFileName, assetType.animated)
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export function generateThemedSvgAssetModule(
|
|
26
|
-
componentName: string,
|
|
27
|
-
optimizedAssets: {
|
|
28
|
-
default: string,
|
|
29
|
-
legacy?: string,
|
|
30
|
-
rebrand?: string,
|
|
31
|
-
},
|
|
32
|
-
originalFileNames: {
|
|
33
|
-
default: string,
|
|
34
|
-
legacy?: string,
|
|
35
|
-
rebrand?: string,
|
|
36
|
-
},
|
|
37
|
-
) {
|
|
38
|
-
const defaultRelativePath = `./assets/${path.basename(optimizedAssets.default)}`
|
|
39
|
-
const legacyRelativePath = optimizedAssets.legacy
|
|
40
|
-
? `./assets/${path.basename(optimizedAssets.legacy)}`
|
|
41
|
-
: undefined
|
|
42
|
-
const rebrandRelativePath = optimizedAssets.rebrand
|
|
43
|
-
? `./assets/${path.basename(optimizedAssets.rebrand)}`
|
|
44
|
-
: undefined
|
|
45
|
-
|
|
46
|
-
return generateSvgAsset(
|
|
47
|
-
componentName,
|
|
48
|
-
defaultRelativePath,
|
|
49
|
-
originalFileNames.default,
|
|
50
|
-
legacyRelativePath,
|
|
51
|
-
originalFileNames.legacy,
|
|
52
|
-
rebrandRelativePath,
|
|
53
|
-
originalFileNames.rebrand,
|
|
54
|
-
)
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Generates SVG asset module
|
|
59
|
-
*/
|
|
60
|
-
function generateSvgAsset(
|
|
61
|
-
componentName: string,
|
|
62
|
-
relativePath: string,
|
|
63
|
-
originalFileName: string,
|
|
64
|
-
legacyRelativePath?: string,
|
|
65
|
-
legacyOriginalFileName?: string,
|
|
66
|
-
rebrandRelativePath?: string,
|
|
67
|
-
rebrandOriginalFileName?: string,
|
|
68
|
-
) {
|
|
69
|
-
const sourceComments = [
|
|
70
|
-
legacyOriginalFileName ? `// Legacy source: ${legacyOriginalFileName}` : '',
|
|
71
|
-
rebrandOriginalFileName
|
|
72
|
-
? `// Rebrand source: ${rebrandOriginalFileName}`
|
|
73
|
-
: '',
|
|
74
|
-
]
|
|
75
|
-
.filter(Boolean)
|
|
76
|
-
.join('\n')
|
|
77
|
-
const legacyImport =
|
|
78
|
-
legacyRelativePath && legacyRelativePath !== relativePath
|
|
79
|
-
? `\nimport legacySvgUrl from '${legacyRelativePath}'`
|
|
80
|
-
: ''
|
|
81
|
-
const rebrandImport =
|
|
82
|
-
rebrandRelativePath && rebrandRelativePath !== relativePath
|
|
83
|
-
? `\nimport rebrandSvgUrl from '${rebrandRelativePath}'`
|
|
84
|
-
: ''
|
|
85
|
-
const legacyUrl = legacyRelativePath
|
|
86
|
-
? legacyRelativePath === relativePath
|
|
87
|
-
? 'defaultSvgUrl'
|
|
88
|
-
: 'legacySvgUrl'
|
|
89
|
-
: 'defaultSvgUrl'
|
|
90
|
-
const rebrandUrl = rebrandRelativePath
|
|
91
|
-
? rebrandRelativePath === relativePath
|
|
92
|
-
? 'defaultSvgUrl'
|
|
93
|
-
: 'rebrandSvgUrl'
|
|
94
|
-
: 'defaultSvgUrl'
|
|
95
|
-
|
|
96
|
-
return `// AUTO-GENERATED FILE. DO NOT EDIT.
|
|
97
|
-
// Source: ${originalFileName}${sourceComments ? `\n${sourceComments}` : ''}
|
|
98
|
-
import defaultSvgUrl from '${relativePath}'${legacyImport}${rebrandImport}
|
|
99
|
-
import type { IllustrationAsset, BaseSvgAsset } from './types'
|
|
100
|
-
|
|
101
|
-
export type ${componentName}Asset = IllustrationAsset<BaseSvgAsset & {
|
|
102
|
-
readonly name: '${componentName}'
|
|
103
|
-
}>
|
|
104
|
-
|
|
105
|
-
/**
|
|
106
|
-
* ${componentName} illustration asset
|
|
107
|
-
* @example
|
|
108
|
-
* \`\`\`tsx
|
|
109
|
-
* import { Illustration } from '@payfit/unity-illustrations'
|
|
110
|
-
* import ${componentName} from '@payfit/unity-illustrations/assets/${componentName}'
|
|
111
|
-
*
|
|
112
|
-
* <Illustration
|
|
113
|
-
* illustration={${componentName}}
|
|
114
|
-
* alt="${componentName} illustration"
|
|
115
|
-
* size="md"
|
|
116
|
-
* />
|
|
117
|
-
* \`\`\`
|
|
118
|
-
*/
|
|
119
|
-
const ${componentName}: ${componentName}Asset = {
|
|
120
|
-
type: 'svg',
|
|
121
|
-
url: defaultSvgUrl,
|
|
122
|
-
urls: {
|
|
123
|
-
legacy: ${legacyUrl},
|
|
124
|
-
rebrand: ${rebrandUrl},
|
|
125
|
-
},
|
|
126
|
-
animated: false,
|
|
127
|
-
name: '${componentName}',
|
|
128
|
-
} as ${componentName}Asset
|
|
129
|
-
|
|
130
|
-
export default ${componentName}
|
|
131
|
-
`
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
/**
|
|
135
|
-
* Generates animated asset module
|
|
136
|
-
*/
|
|
137
|
-
function generateAnimatedAsset(
|
|
138
|
-
componentName: string,
|
|
139
|
-
relativePath: string,
|
|
140
|
-
originalFileName: string,
|
|
141
|
-
dimensions: { width: number, height: number }
|
|
142
|
-
) {
|
|
143
|
-
return `// AUTO-GENERATED FILE. DO NOT EDIT.
|
|
144
|
-
// Source: ${originalFileName} (Animated WEBP - ${dimensions.width}x${dimensions.height})
|
|
145
|
-
import assetUrl from '${relativePath}'
|
|
146
|
-
import type { IllustrationAsset, BaseAnimatedImageAsset } from './types'
|
|
147
|
-
|
|
148
|
-
export type ${componentName}Asset = IllustrationAsset<BaseAnimatedImageAsset & {
|
|
149
|
-
readonly name: '${componentName}'
|
|
150
|
-
}>
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* ${componentName} animated illustration asset (${dimensions.width}x${dimensions.height})
|
|
154
|
-
* @example
|
|
155
|
-
* \`\`\`tsx
|
|
156
|
-
* import { Illustration } from '@payfit/unity-illustrations'
|
|
157
|
-
* import ${componentName} from '@payfit/unity-illustrations/assets/${componentName}'
|
|
158
|
-
*
|
|
159
|
-
* <Illustration
|
|
160
|
-
* variant="picture"
|
|
161
|
-
* src={${componentName}}
|
|
162
|
-
* alt="${componentName.replace('Animation', '')} animation"
|
|
163
|
-
* />
|
|
164
|
-
* \`\`\`
|
|
165
|
-
*/
|
|
166
|
-
const ${componentName}: ${componentName}Asset = {
|
|
167
|
-
type: 'image',
|
|
168
|
-
url: assetUrl,
|
|
169
|
-
urls: {
|
|
170
|
-
legacy: assetUrl,
|
|
171
|
-
rebrand: assetUrl,
|
|
172
|
-
},
|
|
173
|
-
animated: true,
|
|
174
|
-
dimensions: { width: ${dimensions.width}, height: ${dimensions.height} },
|
|
175
|
-
category: 'animation',
|
|
176
|
-
name: '${componentName}',
|
|
177
|
-
} as ${componentName}Asset
|
|
178
|
-
|
|
179
|
-
export default ${componentName}
|
|
180
|
-
`
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
/**
|
|
184
|
-
* Generates image asset module
|
|
185
|
-
*/
|
|
186
|
-
function generateImageAsset(componentName: string, relativePath: string, originalFileName: string, animated: boolean) {
|
|
187
|
-
return `// AUTO-GENERATED FILE. DO NOT EDIT.
|
|
188
|
-
// Source: ${originalFileName}
|
|
189
|
-
import assetUrl from '${relativePath}'
|
|
190
|
-
import type { IllustrationAsset, BaseImageAsset } from './types'
|
|
191
|
-
|
|
192
|
-
export type ${componentName}Asset = IllustrationAsset<BaseImageAsset & {
|
|
193
|
-
readonly name: '${componentName}'
|
|
194
|
-
readonly animated: ${animated}
|
|
195
|
-
}>
|
|
196
|
-
|
|
197
|
-
/**
|
|
198
|
-
* ${componentName} illustration asset
|
|
199
|
-
* @example
|
|
200
|
-
* \`\`\`tsx
|
|
201
|
-
* import { Illustration } from '@payfit/unity-illustrations'
|
|
202
|
-
* import ${componentName} from '@payfit/unity-illustrations/assets/${componentName}'
|
|
203
|
-
*
|
|
204
|
-
* <Illustration
|
|
205
|
-
* illustration={${componentName}}
|
|
206
|
-
* alt="${componentName} illustration"
|
|
207
|
-
* size="md"
|
|
208
|
-
* />
|
|
209
|
-
* \`\`\`
|
|
210
|
-
*/
|
|
211
|
-
const ${componentName}: ${componentName}Asset = {
|
|
212
|
-
type: 'image',
|
|
213
|
-
url: assetUrl,
|
|
214
|
-
urls: {
|
|
215
|
-
legacy: assetUrl,
|
|
216
|
-
rebrand: assetUrl,
|
|
217
|
-
},
|
|
218
|
-
animated: ${animated},
|
|
219
|
-
name: '${componentName}',
|
|
220
|
-
} as ${componentName}Asset
|
|
221
|
-
|
|
222
|
-
export default ${componentName}
|
|
223
|
-
`
|
|
224
|
-
}
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Generates the base types file content
|
|
3
|
-
*/
|
|
4
|
-
export function generateBaseTypes() {
|
|
5
|
-
return `// AUTO-GENERATED FILE. DO NOT EDIT.
|
|
6
|
-
import type { UnityTheme } from '@payfit/unity-themes'
|
|
7
|
-
|
|
8
|
-
// Brand symbol for type safety
|
|
9
|
-
declare const __UNITY_ILLUSTRATION: unique symbol
|
|
10
|
-
|
|
11
|
-
export interface IllustrationAssetBrand {
|
|
12
|
-
readonly [__UNITY_ILLUSTRATION]: true
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export type IllustrationAssetUrls = Partial<Record<UnityTheme, string>>
|
|
16
|
-
|
|
17
|
-
// Base interfaces
|
|
18
|
-
export interface BaseSvgAsset {
|
|
19
|
-
readonly type: 'svg'
|
|
20
|
-
readonly url: string
|
|
21
|
-
readonly urls?: IllustrationAssetUrls
|
|
22
|
-
readonly animated: false
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export interface BaseImageAsset {
|
|
26
|
-
readonly type: 'image'
|
|
27
|
-
readonly url: string
|
|
28
|
-
readonly urls?: IllustrationAssetUrls
|
|
29
|
-
readonly animated: boolean
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export interface BaseAnimatedImageAsset extends BaseImageAsset {
|
|
33
|
-
readonly animated: true
|
|
34
|
-
readonly dimensions: {
|
|
35
|
-
readonly width: number
|
|
36
|
-
readonly height: number
|
|
37
|
-
}
|
|
38
|
-
readonly category: 'animation'
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// Branded wrapper type
|
|
42
|
-
export type IllustrationAsset<T extends (BaseSvgAsset | BaseImageAsset | BaseAnimatedImageAsset) & { readonly name: string }> =
|
|
43
|
-
T & IllustrationAssetBrand
|
|
44
|
-
`
|
|
45
|
-
}
|
|
@@ -1,109 +0,0 @@
|
|
|
1
|
-
type Component = {
|
|
2
|
-
name: string,
|
|
3
|
-
type: string,
|
|
4
|
-
animated: boolean,
|
|
5
|
-
sizeBefore: number,
|
|
6
|
-
sizeAfter: number
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Generates the main index file
|
|
11
|
-
*/
|
|
12
|
-
export function generateIndexFile(components: Component[]) {
|
|
13
|
-
// Import all the actual assets
|
|
14
|
-
const assetImports = components
|
|
15
|
-
.map(({ name }) => `import { type ${name}Asset } from './${name}'`)
|
|
16
|
-
.join('\n')
|
|
17
|
-
|
|
18
|
-
const typeExports = components
|
|
19
|
-
.map(({ name }) => `export type { ${name}Asset } from './${name}'`)
|
|
20
|
-
.join('\n')
|
|
21
|
-
|
|
22
|
-
const nameUnion = components
|
|
23
|
-
.map(({ name }) => `'${name}'`)
|
|
24
|
-
.join(' | ')
|
|
25
|
-
|
|
26
|
-
const assetTypeUnion = components
|
|
27
|
-
.map(({ name }) => `${name}Asset`)
|
|
28
|
-
.join(' | ')
|
|
29
|
-
|
|
30
|
-
const illustrationNamesArray = components
|
|
31
|
-
.map(({ name }) => `'${name}'`)
|
|
32
|
-
.join(', ')
|
|
33
|
-
|
|
34
|
-
// Create the components map for lazy loading
|
|
35
|
-
const componentsMap = `{
|
|
36
|
-
${components.map(({ name }) => `'${name}': () => import('./${name}')`).join(',\n ')}
|
|
37
|
-
}`
|
|
38
|
-
|
|
39
|
-
// Generate statistics comment
|
|
40
|
-
const stats = generateStatsComment(components)
|
|
41
|
-
|
|
42
|
-
return `// AUTO-GENERATED FILE. DO NOT EDIT.
|
|
43
|
-
${stats}
|
|
44
|
-
|
|
45
|
-
// Re-export shared types
|
|
46
|
-
export type {
|
|
47
|
-
IllustrationAsset,
|
|
48
|
-
IllustrationAssetBrand,
|
|
49
|
-
BaseSvgAsset,
|
|
50
|
-
BaseImageAsset,
|
|
51
|
-
BaseAnimatedImageAsset
|
|
52
|
-
} from './types'
|
|
53
|
-
|
|
54
|
-
// Import all assets for union type
|
|
55
|
-
${assetImports}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* Map of all illustrations with lazy loading
|
|
59
|
-
* Use this for dynamic imports of illustrations
|
|
60
|
-
*/
|
|
61
|
-
export const lazyIllustrationsMap = ${componentsMap}
|
|
62
|
-
|
|
63
|
-
// Type exports
|
|
64
|
-
${typeExports}
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Union of all available illustration names
|
|
68
|
-
*/
|
|
69
|
-
export type UnityIllustrationName = ${nameUnion}
|
|
70
|
-
|
|
71
|
-
/**
|
|
72
|
-
* Union of all branded illustration asset types
|
|
73
|
-
* This prevents creation of fake illustration objects
|
|
74
|
-
*/
|
|
75
|
-
export type UnityIllustrationAsset = ${assetTypeUnion}
|
|
76
|
-
|
|
77
|
-
/**
|
|
78
|
-
* Array of all available illustration names
|
|
79
|
-
* Useful for iteration or validation
|
|
80
|
-
*/
|
|
81
|
-
export const illustrationNames: readonly UnityIllustrationName[] = [${illustrationNamesArray}] as const
|
|
82
|
-
`
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Generates statistics comment for the index file
|
|
87
|
-
*/
|
|
88
|
-
function generateStatsComment(components: Component[]) {
|
|
89
|
-
const totalCount = components.length
|
|
90
|
-
const svgCount = components.filter(c => c.type === 'svg').length
|
|
91
|
-
const imageCount = components.filter(c => c.type === 'image').length
|
|
92
|
-
const animatedCount = components.filter(c => c.animated).length
|
|
93
|
-
|
|
94
|
-
const totalSizeBefore = components.reduce((sum, c) => sum + (c.sizeBefore || 0), 0)
|
|
95
|
-
const totalSizeAfter = components.reduce((sum, c) => sum + (c.sizeAfter || 0), 0)
|
|
96
|
-
const totalReduction = totalSizeBefore > 0
|
|
97
|
-
? ((totalSizeBefore - totalSizeAfter) / totalSizeBefore * 100).toFixed(1)
|
|
98
|
-
: '0'
|
|
99
|
-
|
|
100
|
-
return `//
|
|
101
|
-
// 📊 Generation Statistics:
|
|
102
|
-
// - Total illustrations: ${totalCount}
|
|
103
|
-
// - SVGs: ${svgCount}
|
|
104
|
-
// - Images: ${imageCount}
|
|
105
|
-
// - Animated: ${animatedCount}
|
|
106
|
-
// - Size optimization: ${(totalSizeBefore / 1024).toFixed(1)}KB → ${(totalSizeAfter / 1024).toFixed(1)}KB (-${totalReduction}%)
|
|
107
|
-
// - Generated: ${new Date().toISOString()}
|
|
108
|
-
//`
|
|
109
|
-
}
|