Skip to content

Commit

Permalink
[C-3431] Add universal harmony icons (#6877)
Browse files Browse the repository at this point in the history
  • Loading branch information
dylanjeffers authored Dec 7, 2023
1 parent 7df0fda commit 71f093e
Show file tree
Hide file tree
Showing 18 changed files with 934 additions and 348 deletions.
1,051 changes: 830 additions & 221 deletions package-lock.json

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions packages/harmony/.svgrrc.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
module.exports = {
template: require('./svgr-template'),
dimensions: false
template: require('../../svgr-template'),
dimensions: false,
replaceAttrValues: {
red: '{props.fill}'
}
}
27 changes: 27 additions & 0 deletions packages/harmony/src/components/icon.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import type { ComponentType, SVGProps } from 'react'

import type { IconColors } from 'foundations'

export const iconSizes = {
xs: 14,
s: 16,
m: 20,
l: 24,
xl: 30,
'2xl': 32
}

type IconSize = keyof typeof iconSizes

type SVGBaseProps = SVGProps<SVGSVGElement>

export type IconProps = {
color?: IconColors
size?: IconSize
sizeW?: IconSize
sizeH?: IconSize
}

type SVGIconProps = SVGBaseProps & IconProps

export type IconComponent = ComponentType<SVGBaseProps | SVGIconProps>
56 changes: 0 additions & 56 deletions packages/harmony/src/components/icon/Icon.tsx

This file was deleted.

1 change: 0 additions & 1 deletion packages/harmony/src/components/icon/index.ts

This file was deleted.

10 changes: 9 additions & 1 deletion packages/harmony/src/foundations/theme/theme.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { iconSizes } from '../../components/icon'
import type { ColorTheme } from '../color'
import { colorTheme } from '../color'
import { CornerRadius, cornerRadius } from '../corner-radius'
Expand All @@ -10,6 +9,15 @@ import type { Typography } from '../typography'

import type { Theme } from './types'

const iconSizes = {
xs: 14,
s: 16,
m: 20,
l: 24,
xl: 30,
'2xl': 32
}

const commonFoundations = {
shadows,
typography,
Expand Down
38 changes: 0 additions & 38 deletions packages/harmony/svgr-template.js

This file was deleted.

6 changes: 0 additions & 6 deletions packages/mobile/.svgrrc

This file was deleted.

9 changes: 9 additions & 0 deletions packages/mobile/.svgrrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
module.exports = {
template: require('../../svgr-template'),
dimensions: false,
replaceAttrValues: {
'#FF0000': '{props.fill}',
'#000': '{props.fill}',
'#f00': '{props.fillSecondary}'
}
}
6 changes: 2 additions & 4 deletions packages/mobile/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,6 @@
"@solana-mobile/mobile-wallet-adapter-protocol-web3js": "0.9.9",
"@stripe/crypto": "0.0.4",
"@stripe/stripe-js": "1.54.1",
"@svgr/core": "5.5.0",
"@tanstack/react-query": "4.35.7",
"@walletconnect/react-native-dapp": "1.8.0",
"array.prototype.flat": "1.2.5",
Expand Down Expand Up @@ -152,7 +151,7 @@
"react-native-screens": "3.17.0",
"react-native-share": "8.0.0",
"react-native-svg": "12.3.0",
"react-native-svg-transformer": "0.14.3",
"react-native-svg-transformer": "1.1.0",
"react-native-tab-view": "3.1.1",
"react-native-tiktok": "1.1.1",
"react-native-track-player": "3.2.0",
Expand Down Expand Up @@ -193,10 +192,9 @@
"@storybook/addon-actions": "6.5.16",
"@storybook/addon-controls": "6.5.16",
"@storybook/addon-ondevice-actions": "6.5.6",
"@storybook/addon-ondevice-controls": "6.5.6",
"@storybook/addon-ondevice-backgrounds": "6.5.6",
"@storybook/addon-ondevice-controls": "6.5.6",
"@storybook/react-native": "6.5.6",
"@svgr/plugin-svgo": "5.5.0",
"@testing-library/jest-native": "5.4.3",
"@testing-library/react-native": "12.3.0",
"@tsconfig/react-native": "2.0.3",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { BadgeTier } from '@audius/common'
import type { ImageStyle } from 'react-native'
import { Image } from 'react-native'
import type { SvgProps } from 'react-native-svg'

import type { IconProps } from '@audius/harmony-native'
import IconBronzeBadge from 'app/assets/images/IconBronzeBadge.svg'
import IconGoldBadge from 'app/assets/images/IconGoldBadge.svg'
import IconPlatinumBadge from 'app/assets/images/IconPlatinumBadge.svg'
Expand All @@ -17,7 +17,7 @@ const audioTierMap = {
platinum: IconPlatinumBadge
}

type IconBadgeProps = SvgProps & {
type IconBadgeProps = IconProps & {
tier: BadgeTier
showNoTier?: boolean
}
Expand Down
8 changes: 8 additions & 0 deletions packages/mobile/src/harmony-native/icons.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import type { IconProps as HarmonyIconProps } from '@audius/harmony'
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>
1 change: 1 addition & 0 deletions packages/mobile/src/harmony-native/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export * from './foundations'
export * from './components'
export * from './icons'
2 changes: 2 additions & 0 deletions packages/mobile/src/screens/feed-screen/FeedScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
} from '@audius/common'
import { useDispatch } from 'react-redux'

// import { IconPlay } from '@audius/harmony-native'
import IconFeed from 'app/assets/images/iconFeed.svg'
import { Screen, ScreenContent, ScreenHeader } from 'app/components/core'
import { FeedTipTile } from 'app/components/feed-tip-tile'
Expand Down Expand Up @@ -55,6 +56,7 @@ export const FeedScreen = () => {
</OnlineOnly>
</ScreenHeader>
<ScreenContent>
{/* <IconPlay color={} /> */}
<Lineup
pullToRefresh
delineate
Expand Down
9 changes: 3 additions & 6 deletions packages/mobile/src/types/declarations.d.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
/// <reference types="@testing-library/jest-native" />

/* eslint-disable import/order, import/no-duplicates */

declare module 'fxa-common-password-list'
declare module 'react-native-static-server'

declare module '*.svg' {
import type { SvgProps } from 'react-native-svg'
const content: React.FC<
SvgProps & {
fillSecondary?: string
}
>
import type { Icon } from '@audius/harmony-native'
const content: Icon
export default content
}

Expand Down
11 changes: 0 additions & 11 deletions packages/mobile/types/global.d.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,3 @@
declare module '*.svg' {
import type * as React from 'react'

export const ReactComponent: React.FunctionComponent<
React.SVGProps<SVGSVGElement> & { title?: string }
>

const src: string
export default src
}

declare module 'antd/lib/popover'
declare module 'classnames/types' {
export type ClassValue = any
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
FeatureFlags,
useFeatureFlag
} from '@audius/common'
import { IconAlbum } from '@audius/harmony'

import { make, useRecord } from 'common/store/analytics/actions'
import Header from 'components/header/desktop/Header'
Expand Down Expand Up @@ -102,6 +103,7 @@ const FeedPageContent = ({
size='large'
header={header}
>
<IconAlbum color='default' size='s' />
<Lineup
emptyElement={
<EmptyFeed
Expand Down
34 changes: 34 additions & 0 deletions svgr-template.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
const template = (variables, { tpl }) => {
return tpl`
${variables.imports};
import {useTheme} from '@emotion/react'
${variables.interfaces};
const ${variables.componentName} = (${variables.props}) => {
const theme = useTheme()
const {
color,
size,
sizeH,
sizeW,
height: heightProp,
width: widthProp,
fill: fillProp,
...other
} = props
const height = heightProp ?? theme.iconSizes[sizeH ?? size ?? 'l']
const width = widthProp ?? theme.iconSizes[sizeW ?? size ?? 'l']
const fill = fillProp ?? theme.color.icon[color] ?? 'red'
props = {...other, height, width, fill}
return (${variables.jsx})
};
${variables.exports};
`
}

module.exports = template

0 comments on commit 71f093e

Please sign in to comment.