mirror of
https://github.com/oceanprotocol/market.git
synced 2024-12-02 05:57:29 +01:00
move Blockies into separate component
This commit is contained in:
parent
f8ffcbac75
commit
b30fcf0c4b
8
src/components/atoms/Blockies.module.css
Normal file
8
src/components/atoms/Blockies.module.css
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
.blockies {
|
||||||
|
width: var(--font-size-large);
|
||||||
|
height: var(--font-size-large);
|
||||||
|
border-radius: 50%;
|
||||||
|
overflow: hidden;
|
||||||
|
display: inline-block;
|
||||||
|
vertical-align: middle;
|
||||||
|
}
|
23
src/components/atoms/Blockies.tsx
Normal file
23
src/components/atoms/Blockies.tsx
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
import { toDataUrl } from 'ethereum-blockies'
|
||||||
|
import React, { ReactElement } from 'react'
|
||||||
|
import styles from './Blockies.module.css'
|
||||||
|
|
||||||
|
export default function Blockies({
|
||||||
|
accountId,
|
||||||
|
className
|
||||||
|
}: {
|
||||||
|
accountId: string
|
||||||
|
className?: string
|
||||||
|
}): ReactElement {
|
||||||
|
if (!accountId) return null
|
||||||
|
const blockies = toDataUrl(accountId)
|
||||||
|
|
||||||
|
return (
|
||||||
|
<img
|
||||||
|
className={`${styles.blockies} ${className || ''}`}
|
||||||
|
src={blockies}
|
||||||
|
alt="Blockies"
|
||||||
|
aria-hidden="true"
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
}
|
@ -41,20 +41,12 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.blockies {
|
|
||||||
width: var(--font-size-large);
|
|
||||||
height: var(--font-size-large);
|
|
||||||
border-radius: 50%;
|
|
||||||
overflow: hidden;
|
|
||||||
display: inline-block;
|
|
||||||
vertical-align: middle;
|
|
||||||
}
|
|
||||||
|
|
||||||
.address {
|
.address {
|
||||||
display: none;
|
display: none;
|
||||||
text-transform: none;
|
text-transform: none;
|
||||||
border-right: 1px solid var(--border-color);
|
border-right: 1px solid var(--border-color);
|
||||||
padding-right: calc(var(--spacer) / 3);
|
padding-right: calc(var(--spacer) / 3);
|
||||||
|
padding-left: calc(var(--spacer) / 8);
|
||||||
}
|
}
|
||||||
|
|
||||||
@media screen and (min-width: 60rem) {
|
@media screen and (min-width: 60rem) {
|
||||||
|
@ -1,24 +1,10 @@
|
|||||||
import { toDataUrl } from 'ethereum-blockies'
|
|
||||||
import React, { FormEvent } from 'react'
|
import React, { FormEvent } from 'react'
|
||||||
import { ReactComponent as Caret } from '../../../images/caret.svg'
|
import { ReactComponent as Caret } from '../../../images/caret.svg'
|
||||||
import { accountTruncate } from '../../../utils/web3'
|
import { accountTruncate } from '../../../utils/web3'
|
||||||
import Loader from '../../atoms/Loader'
|
import Loader from '../../atoms/Loader'
|
||||||
import styles from './Account.module.css'
|
import styles from './Account.module.css'
|
||||||
import { useWeb3 } from '../../../providers/Web3'
|
import { useWeb3 } from '../../../providers/Web3'
|
||||||
|
import Blockies from '../../atoms/Blockies'
|
||||||
const Blockies = ({ account }: { account: string | undefined }) => {
|
|
||||||
if (!account) return null
|
|
||||||
const blockies = toDataUrl(account)
|
|
||||||
|
|
||||||
return (
|
|
||||||
<img
|
|
||||||
className={styles.blockies}
|
|
||||||
src={blockies}
|
|
||||||
alt="Blockies"
|
|
||||||
aria-hidden="true"
|
|
||||||
/>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Forward ref for Tippy.js
|
// Forward ref for Tippy.js
|
||||||
// eslint-disable-next-line
|
// eslint-disable-next-line
|
||||||
@ -44,7 +30,7 @@ const Account = React.forwardRef((props, ref: any) => {
|
|||||||
ref={ref}
|
ref={ref}
|
||||||
onClick={(e) => e.preventDefault()}
|
onClick={(e) => e.preventDefault()}
|
||||||
>
|
>
|
||||||
<Blockies account={accountId} />
|
<Blockies accountId={accountId} />
|
||||||
<span className={styles.address} title={accountId}>
|
<span className={styles.address} title={accountId}>
|
||||||
{accountTruncate(accountId)}
|
{accountTruncate(accountId)}
|
||||||
</span>
|
</span>
|
||||||
|
@ -16,9 +16,13 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.imageWrap {
|
.imageWrap,
|
||||||
|
.image {
|
||||||
width: 96px;
|
width: 96px;
|
||||||
height: 96px;
|
height: 96px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.imageWrap {
|
||||||
border-radius: 50%;
|
border-radius: 50%;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
margin-bottom: calc(var(--spacer) / 4);
|
margin-bottom: calc(var(--spacer) / 4);
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
import { toDataUrl } from 'ethereum-blockies'
|
|
||||||
import React, { ReactElement } from 'react'
|
import React, { ReactElement } from 'react'
|
||||||
import { useUserPreferences } from '../../../providers/UserPreferences'
|
import { useUserPreferences } from '../../../providers/UserPreferences'
|
||||||
import { accountTruncate } from '../../../utils/web3'
|
import { accountTruncate } from '../../../utils/web3'
|
||||||
@ -7,21 +6,7 @@ import NetworkName from '../../atoms/NetworkName'
|
|||||||
import jellyfish from '@oceanprotocol/art/creatures/jellyfish/jellyfish-grid.svg'
|
import jellyfish from '@oceanprotocol/art/creatures/jellyfish/jellyfish-grid.svg'
|
||||||
import styles from './Account.module.css'
|
import styles from './Account.module.css'
|
||||||
import Copy from '../../atoms/Copy'
|
import Copy from '../../atoms/Copy'
|
||||||
|
import Blockies from '../../atoms/Blockies'
|
||||||
const Blockies = ({ account }: { account: string | undefined }) => {
|
|
||||||
if (!account) return null
|
|
||||||
|
|
||||||
const blockies = toDataUrl(account)
|
|
||||||
|
|
||||||
return (
|
|
||||||
<img
|
|
||||||
className={styles.image}
|
|
||||||
src={blockies}
|
|
||||||
alt="Blockies"
|
|
||||||
aria-hidden="true"
|
|
||||||
/>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
export default function Account({
|
export default function Account({
|
||||||
name,
|
name,
|
||||||
@ -40,7 +25,7 @@ export default function Account({
|
|||||||
{image ? (
|
{image ? (
|
||||||
<img src={image} className={styles.image} width="96" height="96" />
|
<img src={image} className={styles.image} width="96" height="96" />
|
||||||
) : accountId ? (
|
) : accountId ? (
|
||||||
<Blockies account={accountId} />
|
<Blockies accountId={accountId} className={styles.image} />
|
||||||
) : (
|
) : (
|
||||||
<img
|
<img
|
||||||
src={jellyfish}
|
src={jellyfish}
|
||||||
|
Loading…
Reference in New Issue
Block a user