Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[C-3504] Enable native animated icons #6914

Merged
merged 1 commit into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion packages/mobile/src/harmony-native/icons.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import type { ComponentType } from 'react'

import type { IconProps as HarmonyIconProps } from '@audius/harmony'
import type { AnimateProps } from 'react-native-reanimated'
import type { SvgProps } from 'react-native-svg'

export * from '@audius/harmony/src/icons'

export type IconProps = SvgProps & HarmonyIconProps & { fillSecondary?: string }

export type Icon = React.FC<IconProps>
export type Icon = ComponentType<AnimateProps<IconProps> | IconProps>
4 changes: 2 additions & 2 deletions packages/mobile/src/types/declarations.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ declare module 'fxa-common-password-list'
declare module 'react-native-static-server'

declare module '*.svg' {
import type { Icon } from '@audius/harmony-native'
const content: Icon
import type { IconProps } from '@audius/harmony-native'
const content: ComponentType<IconProps>
export default content
}

Expand Down
7 changes: 4 additions & 3 deletions svgr-template.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ const template = (variables, { tpl }) => {
return tpl`
${variables.imports};
import {useTheme} from '@emotion/react'
import {forwardRef} from 'react'

${variables.interfaces};

const ${variables.componentName} = (${variables.props}) => {
const ${variables.componentName} = forwardRef((${variables.props}, ref) => {
const theme = useTheme()
let {
color,
Expand All @@ -29,10 +30,10 @@ const ${variables.componentName} = (${variables.props}) => {

const fillColor = other.fill ?? theme.color.icon[color] ?? 'red'

props = {...other, fillColor}
props = {...other, ref, fillColor}

return (${variables.jsx})
};
});

${variables.exports};
`
Expand Down