cozy-ui 133.0.0-beta.1 → 133.0.1
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/CHANGELOG.md +42 -0
- package/assets/icons/ui/file-type-shared-drive-grey.svg +1 -0
- package/assets/icons/ui/file-type-shared-drive.svg +1 -0
- package/package.json +3 -2
- package/react/Icon/Readme.md +6 -4
- package/react/Icons/FileTypeSharedDrive.jsx +51 -0
- package/react/Icons/FileTypeSharedDriveGrey.jsx +24 -0
- package/react/index.js +0 -2
- package/scripts/screenshots/fetchAllComponents.js +114 -0
- package/scripts/screenshots/helpers.js +39 -0
- package/scripts/screenshots/parser.js +61 -0
- package/scripts/screenshots/prepares.js +58 -0
- package/scripts/screenshots/screenshotComponent.js +68 -0
- package/scripts/screenshots/screenshotKSSStyleguide.js +60 -0
- package/scripts/screenshots/screenshotReactStyleguide.js +74 -0
- package/transpiled/react/Icon/icons-sprite.d.ts +1 -1
- package/transpiled/react/Icon/icons-sprite.js +1 -1
- package/transpiled/react/Icons/FileTypeSharedDrive.d.ts +2 -0
- package/transpiled/react/Icons/FileTypeSharedDrive.js +54 -0
- package/transpiled/react/Icons/FileTypeSharedDriveGrey.d.ts +2 -0
- package/transpiled/react/Icons/FileTypeSharedDriveGrey.js +24 -0
- package/transpiled/react/index.js +0 -2
- package/react/Icon/icons-sprite.js +0 -178
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
const fs = require('fs')
|
|
2
|
+
|
|
3
|
+
const { parseViewportArgument } = require('./helpers')
|
|
4
|
+
const fetchAllComponents = require('./fetchAllComponents')
|
|
5
|
+
const screenshotComponent = require('./screenshotComponent')
|
|
6
|
+
|
|
7
|
+
const loadJSON = filename => {
|
|
8
|
+
try {
|
|
9
|
+
return JSON.parse(fs.readFileSync(filename).toString())
|
|
10
|
+
} catch {
|
|
11
|
+
return null
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const cacheToDisk = (fnToCache, options) =>
|
|
16
|
+
async function() {
|
|
17
|
+
const { cacheFile } = options
|
|
18
|
+
let res
|
|
19
|
+
if (cacheFile) {
|
|
20
|
+
res = loadJSON(cacheFile)
|
|
21
|
+
}
|
|
22
|
+
if (res) {
|
|
23
|
+
options.onLoadCache && options.onLoadCache()
|
|
24
|
+
} else {
|
|
25
|
+
res = await fnToCache.apply(this, arguments)
|
|
26
|
+
if (cacheFile) {
|
|
27
|
+
fs.writeFileSync(cacheFile, JSON.stringify(res, null, 2))
|
|
28
|
+
options.onSaveCache && options.onSaveCache()
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return res
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const screenshotReactStyleguide = async (page, args, config, theme) => {
|
|
35
|
+
const cachedFetchAllComponents = cacheToDisk(fetchAllComponents, {
|
|
36
|
+
cacheFile: args.cacheFile,
|
|
37
|
+
onLoadCache: () =>
|
|
38
|
+
console.log(`Using cached component list from ${args.cacheFile}`),
|
|
39
|
+
onSaveCache: () => console.log(`Saved component list to ${args.cacheFile}`)
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
let components = await cachedFetchAllComponents(page, args, config)
|
|
43
|
+
if (args.component) {
|
|
44
|
+
components = components.filter(component =>
|
|
45
|
+
component.name.includes(args.component)
|
|
46
|
+
)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
console.log('⌛ Screenshotting components...')
|
|
50
|
+
|
|
51
|
+
for (const component of components) {
|
|
52
|
+
// Skip components in Deprecated folder
|
|
53
|
+
if (component.link.includes('Deprecated')) continue
|
|
54
|
+
|
|
55
|
+
const componentConfig = config[component.name] || {}
|
|
56
|
+
const componentViewportSpec =
|
|
57
|
+
(componentConfig.viewports && componentConfig.viewports[args.viewport]) ||
|
|
58
|
+
null
|
|
59
|
+
const componentViewport = componentViewportSpec
|
|
60
|
+
? parseViewportArgument(componentViewportSpec)
|
|
61
|
+
: parseViewportArgument(args.viewport)
|
|
62
|
+
await page.setViewport(componentViewport)
|
|
63
|
+
await screenshotComponent(page, {
|
|
64
|
+
component,
|
|
65
|
+
componentConfig,
|
|
66
|
+
screenshotDir: args.screenshotDir,
|
|
67
|
+
viewport: componentViewport,
|
|
68
|
+
type: theme.type,
|
|
69
|
+
variant: theme.variant
|
|
70
|
+
})
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
module.exports = screenshotReactStyleguide
|