@cypress-design/react-icon 0.2.0 → 0.2.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 +7 -0
- package/Icon.tsx +23 -20
- package/IconReact.cy.tsx +38 -0
- package/ReadMe.md +6 -6
- package/compileProperties.ts +12 -12
- package/dist/Icon.d.ts.map +1 -1
- package/dist/TreeShakableIcons.d.ts +15 -4
- package/dist/TreeShakableIcons.d.ts.map +1 -1
- package/dist/compileProperties.d.ts.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.es.js +177 -52
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +191 -55
- package/dist/index.umd.js.map +1 -1
- package/generate-icons.js +16 -16
- package/index.ts +5 -5
- package/package.json +3 -3
- package/rollup.config.js +2 -2
- package/tsconfig.build.json +1 -1
- package/Icon.cy.tsx +0 -22
package/generate-icons.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
const path = require('path')
|
|
2
|
-
const dedent = require('dedent')
|
|
3
|
-
const { promises: fs } = require('fs')
|
|
4
|
-
const camelcase = require('camelcase')
|
|
5
|
-
const { iconsMetadata, iconSet } = require('@cypress-design/icon-registry')
|
|
1
|
+
const path = require('path')
|
|
2
|
+
const dedent = require('dedent')
|
|
3
|
+
const { promises: fs } = require('fs')
|
|
4
|
+
const camelcase = require('camelcase')
|
|
5
|
+
const { iconsMetadata, iconSet } = require('@cypress-design/icon-registry')
|
|
6
6
|
|
|
7
7
|
const iconsComponents = Object.keys(iconsMetadata).map((name) => {
|
|
8
|
-
const pascalCaseName = camelcase(name, { pascalCase: true })
|
|
9
|
-
const iconMetadata = iconsMetadata[name]
|
|
8
|
+
const pascalCaseName = camelcase(name, { pascalCase: true })
|
|
9
|
+
const iconMetadata = iconsMetadata[name]
|
|
10
10
|
const availableIds = iconMetadata.availableSizes.map(
|
|
11
11
|
(size) => `${camelcase(name)}X${size}`
|
|
12
|
-
)
|
|
12
|
+
)
|
|
13
13
|
|
|
14
14
|
const iconBodies = iconSet.reduce((acc, icon) => {
|
|
15
|
-
const sizeIndex = availableIds.indexOf(icon.name)
|
|
15
|
+
const sizeIndex = availableIds.indexOf(icon.name)
|
|
16
16
|
if (sizeIndex > -1) {
|
|
17
|
-
acc[iconMetadata.availableSizes[sizeIndex]] = icon.data
|
|
17
|
+
acc[iconMetadata.availableSizes[sizeIndex]] = icon.data
|
|
18
18
|
}
|
|
19
|
-
return acc
|
|
20
|
-
}, {})
|
|
19
|
+
return acc
|
|
20
|
+
}, {})
|
|
21
21
|
return dedent`
|
|
22
22
|
export const Icon${pascalCaseName}: React.FC<
|
|
23
23
|
Omit<iconsRegistry.Icon${pascalCaseName}Props, 'name'> & React.SVGProps<SVGSVGElement>
|
|
@@ -41,8 +41,8 @@ const iconsComponents = Object.keys(iconsMetadata).map((name) => {
|
|
|
41
41
|
compiledClasses
|
|
42
42
|
}))
|
|
43
43
|
}
|
|
44
|
-
|
|
45
|
-
})
|
|
44
|
+
`
|
|
45
|
+
})
|
|
46
46
|
|
|
47
47
|
writeFile(`
|
|
48
48
|
import * as iconsRegistry from '@cypress-design/icon-registry'
|
|
@@ -50,12 +50,12 @@ import { compileReactIconProperties } from './compileProperties'
|
|
|
50
50
|
import * as React from 'react';
|
|
51
51
|
|
|
52
52
|
${iconsComponents.join('\n\n\n')}
|
|
53
|
-
`)
|
|
53
|
+
`)
|
|
54
54
|
|
|
55
55
|
async function writeFile(fileContents) {
|
|
56
56
|
await fs.writeFile(
|
|
57
57
|
path.resolve(__dirname, './TreeShakableIcons.ts'),
|
|
58
58
|
fileContents,
|
|
59
59
|
'utf-8'
|
|
60
|
-
)
|
|
60
|
+
)
|
|
61
61
|
}
|
package/index.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { iconsMetadata } from '@cypress-design/icon-registry'
|
|
2
|
-
export type { WindiColor } from '@cypress-design/icon-registry'
|
|
3
|
-
export { default } from './Icon'
|
|
4
|
-
export * from './TreeShakableIcons'
|
|
1
|
+
import type { iconsMetadata } from '@cypress-design/icon-registry'
|
|
2
|
+
export type { WindiColor } from '@cypress-design/icon-registry'
|
|
3
|
+
export { default } from './Icon'
|
|
4
|
+
export * from './TreeShakableIcons'
|
|
5
5
|
|
|
6
|
-
export type IconId = keyof typeof iconsMetadata
|
|
6
|
+
export type IconId = keyof typeof iconsMetadata
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cypress-design/react-icon",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"files": [
|
|
5
5
|
"*"
|
|
6
6
|
],
|
|
@@ -20,11 +20,11 @@
|
|
|
20
20
|
"build:types": "tsc --project ./tsconfig.build.json"
|
|
21
21
|
},
|
|
22
22
|
"dependencies": {
|
|
23
|
-
"@cypress-design/icon-registry": "^0.
|
|
23
|
+
"@cypress-design/icon-registry": "^0.3.0"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"camelcase": "^6.3.0",
|
|
27
27
|
"dedent": "^0.7.0"
|
|
28
28
|
},
|
|
29
29
|
"license": "MIT"
|
|
30
|
-
}
|
|
30
|
+
}
|
package/rollup.config.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import rootRollupConfig from '../../root.rollup.config'
|
|
1
|
+
import rootRollupConfig from '../../root.rollup.config'
|
|
2
2
|
|
|
3
|
-
export default rootRollupConfig({ input: './index.ts' })
|
|
3
|
+
export default rootRollupConfig({ input: './index.ts' })
|
package/tsconfig.build.json
CHANGED
package/Icon.cy.tsx
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import Icon, { IconObjectBookCode } from './index'
|
|
3
|
-
import { mount } from 'cypress/react';
|
|
4
|
-
|
|
5
|
-
describe('Icon', () => {
|
|
6
|
-
it('renders correctly', () => {
|
|
7
|
-
mount(<ul className="m-4">
|
|
8
|
-
<li className="flex items-center mb-3 px-2">
|
|
9
|
-
fillColor="red-100" - <IconObjectBookCode fillColor="red-100" className="ml-2" strokeColor="red-500" secondaryFillColor="indigo-100" secondaryStrokeColor="indigo-600"/>
|
|
10
|
-
</li>
|
|
11
|
-
<li className="flex items-center mb-3 px-2 bg-magenta-100">
|
|
12
|
-
fillColor="transparent" - <Icon name="arrow-outline-down" strokeColor="magenta-500" fillColor="transparent" className="ml-2" />
|
|
13
|
-
</li>
|
|
14
|
-
<li className="flex items-center px-2">
|
|
15
|
-
strokeColor="current" - <button className="flex gap-2 items-center m-2 bg-jade-600 hover:bg-jade-800 text-white py-1 px-2 rounded">
|
|
16
|
-
<Icon name="action-add-large" strokeColor="current" />
|
|
17
|
-
Add a new icon
|
|
18
|
-
</button>
|
|
19
|
-
</li>
|
|
20
|
-
</ul>)
|
|
21
|
-
})
|
|
22
|
-
})
|