Skip to content

Commit

Permalink
[fix] fix table pagination and createIcon (#257)
Browse files Browse the repository at this point in the history
  • Loading branch information
sijav authored Jun 19, 2024
1 parent bb16659 commit 1e34d29
Show file tree
Hide file tree
Showing 23 changed files with 264 additions and 174 deletions.
2 changes: 0 additions & 2 deletions src/assets/icons/aws-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions src/assets/icons/azure-logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 7 additions & 4 deletions src/assets/icons/createIcon.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,17 @@ import { FC, FunctionComponent, SVGProps, forwardRef } from 'react'

type SvgIconProps = SVGProps<SVGSVGElement> & { title?: string; nonce?: string }

export const createIcon = (Icon: FunctionComponent<SvgIconProps>) => {
export const createIcon = (Icon: FunctionComponent<SvgIconProps>, colors?: [string, string?]) => {
const whiteColor = colors?.[0]
const darkColor = colors?.[1]
const SvgIconComp: FC<SvgIconProps> = forwardRef(({ color, fill, ...props }, ref) => {
const { palette } = useTheme()
type KeyOfPalette = 'common'
type PaletteAsObject = Palette[KeyOfPalette]
type KeyOfPaletteAsObject = keyof PaletteAsObject
let iconColor = fill || color || palette.primary.main
const [firstColorKey, secondColorKey] = (color?.split('.') ?? []) as KeyOfPalette[]
let iconColor =
fill || color || (colors ? (palette.mode === 'dark' ? darkColor || whiteColor : whiteColor) : undefined) || palette.common.black
const [firstColorKey, secondColorKey] = (iconColor?.split('.') ?? []) as KeyOfPalette[]
if (
!fill &&
firstColorKey &&
Expand All @@ -20,7 +23,7 @@ export const createIcon = (Icon: FunctionComponent<SvgIconProps>) => {
) {
iconColor = palette[firstColorKey][secondColorKey as KeyOfPaletteAsObject]
}
return <Icon {...props} ref={ref} fill={iconColor} />
return <Icon key={iconColor} {...props} ref={ref} fill={iconColor} />
})
SvgIconComp.displayName = Icon.displayName || Icon.name
return SvgIconComp
Expand Down
2 changes: 2 additions & 0 deletions src/assets/icons/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import AwsLogoComp from './aws-logo.svg?react'
import AzureLogoComp from './azure-logo.svg?react'
import { createIcon } from './createIcon'
import CrownComp from './crown.svg?react'
import DiscordIconComp from './discord-icon.svg?react'
Expand All @@ -22,6 +23,7 @@ export const DiscordWithTextLogo = createIcon(DiscordWithTextLogoComp)
export const FixBetaLogo = createIcon(FixBetaLogoComp)
export const FixLogo = createIcon(FixLogoComp)
export const GcpLogo = createIcon(GcpLogoComp)
export const AzureLogo = createIcon(AzureLogoComp)
export const GithubSEBIcon = createIcon(GithubSEBIconComp)
export const GoogleSEBIcon = createIcon(GoogleSEBIconComp)
export const LogoWhiteNoBackground = createIcon(LogoWhiteNoBackgroundComp)
Expand Down
Loading

0 comments on commit 1e34d29

Please sign in to comment.