Skip to content

Commit

Permalink
fix(IconLibrary): Export missing interface
Browse files Browse the repository at this point in the history
TS compiler throws an error downstream. The interface is required when wrapping an icon as a styled-component: `styled(IconName)`.
  • Loading branch information
m7kvqbe1 committed Jan 5, 2021
1 parent 65f80aa commit 9730adf
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 13 deletions.
20 changes: 9 additions & 11 deletions packages/icon-library/.svgrrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,15 @@ module.exports = {
) {
const typeScriptTpl = template.smart({ plugins: ['jsx', 'typescript'] })
return typeScriptTpl.ast`
import React, { SVGProps } from 'react';
import { SVGUniqueID } from 'react-svg-unique-id';
interface SVGIconProps extends SVGProps<SVGSVGElement> {
size?: number
className?: string
}
const ${componentName} = ({ size = 16, ...props }: SVGIconProps) => (
<SVGUniqueID>{${jsx}}</SVGUniqueID>
);
export default ${componentName};
import React from 'react'
import { SVGUniqueID } from 'react-svg-unique-id';
import { SVGIconProps } from '../types'
const ${componentName} = ({ size = 16, ...props }: SVGIconProps) => (
<SVGUniqueID>{${jsx}}</SVGUniqueID>
);
export default ${componentName};
`
},
svgoConfig: {
Expand Down
6 changes: 4 additions & 2 deletions packages/icon-library/generate-exports.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@ IFS=$'\n\t'

:> src/index.ts

echo "export type { SVGIconProps } from './types'" >> src/index.ts

for file in src/icons/*; do
filename=$(basename -- "$file")
filename_no_ext=${filename%%.*}
echo "export {default as Icon${filename_no_ext}} from './icons/${filename_no_ext}'" >> src/index.ts
echo "export {default as Icon${filename_no_ext} } from './icons/${filename_no_ext}'" >> src/index.ts
done

for file in src/silhouettes/*; do
filename=$(basename -- "$file")
filename_no_ext=${filename%%.*}
echo "export {default as Silhouette${filename_no_ext}} from './silhouettes/${filename_no_ext}'" >> src/index.ts
echo "export {default as Silhouette${filename_no_ext} } from './silhouettes/${filename_no_ext}'" >> src/index.ts
done
6 changes: 6 additions & 0 deletions packages/icon-library/src/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import { SVGProps } from 'react'

export interface SVGIconProps extends SVGProps<SVGSVGElement> {
size?: number
className?: string
}

0 comments on commit 9730adf

Please sign in to comment.