Skip to content
Open
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
2 changes: 1 addition & 1 deletion src/components/cid/Cid.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react'
import { Identicon } from '../identicon/Identicon.js'
import { Identicon } from '../identicon/identicon.js'
import ErrorBoundary from '../error/error-boundary.jsx'

export function cidStartAndEnd (value) {
Expand Down
10 changes: 0 additions & 10 deletions src/components/identicon/Identicon.js

This file was deleted.

46 changes: 0 additions & 46 deletions src/components/identicon/Identicon.stories.js

This file was deleted.

23 changes: 23 additions & 0 deletions src/components/identicon/identicon.stories.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// @ts-check
import { Identicon } from './identicon'

const meta = {
title: 'Identicon',
component: Identicon,
parameters: {
actions: { disable: false, handles: ['click'] }
},
args: {
cid: 'QmYPNmahJAvkMTU6tDx5zvhEkoLzEFeTDz6azDCSNqzKkW',
className: 'ma2',
size: 14
}
} as const

export default meta

export const Default = {}

export const Large = {
args: { size: 64 }
}
27 changes: 27 additions & 0 deletions src/components/identicon/identicon.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import React from 'react'
import ReactIdenticon from 'react-identicons'
import theme from 'ipfs-css/theme.json'

const { colors } = theme
const identiconPalette = [colors.navy, colors.aqua, colors.gray, colors.charcoal, colors.red, colors.yellow, colors.teal, colors.green]

export interface IdenticonProps {
size?: number
cid: string
className?: string
}

export const Identicon: React.FC<IdenticonProps> = ({
size = 14,
cid,
className = 'v-btm'
}) => (
<ReactIdenticon
string={cid}
size={size}
palette={identiconPalette}
className={className}
/>
)

export default Identicon
13 changes: 13 additions & 0 deletions src/types/react-identicons.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
declare module 'react-identicons' {
import { FC } from 'react'

interface ReactIdenticonProps {
string: string
size?: number
palette?: string[]
className?: string
}

const ReactIdenticon: FC<ReactIdenticonProps>
export default ReactIdenticon
}
2 changes: 2 additions & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@
"src/components/about-webui/AboutWebUI.js",
"src/components/box/Box.js",
"src/components/shell/Shell.js",
"src/components/identicon/identicon.tsx",
"src/components/identicon/identicon.stories.tsx",
"src/i18n-decorator.js",
"src/i18n.js",
"src/lib/i18n-localeParser.js"
Expand Down