Skip to content

Commit

Permalink
Update ImageGenerator size settings
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexeyTripleA committed Dec 13, 2024
1 parent 37c1547 commit c44284f
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ function DataContract ({ identifier }) {
<div className={'TableHeader__Content'}>
{dataContract?.data?.name || ''}
{dataContract.data?.identifier
? <ImageGenerator className={'TableHeader__Avatar'} username={dataContract.data?.identifier} lightness={50} saturation={50} width={32} height={32}/>
? <ImageGenerator className={'TableHeader__Avatar'} hat={'christmas'} username={dataContract.data?.identifier} lightness={50} saturation={50} width={32} height={32}/>
: <Box w={'32px'} h={'32px'} />
}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ function Identity ({ identifier }) {
<Th className={'TableHeader TableHeader--Name'}>
{identifier
? <div className={'TableHeader__Content'}>
<ImageGenerator className={'TableHeader__Avatar'} username={identifier} lightness={50} saturation={50} width={32} height={32}/>
<ImageGenerator className={'TableHeader__Avatar'} hat={'christmas'} username={identifier} lightness={50} saturation={50} width={32} height={32}/>
</div>
: <Box w={'32px'} h={'32px'} />
}
Expand Down
2 changes: 2 additions & 0 deletions packages/frontend/src/components/breadcrumbs/Breadcrumbs.scss
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@

&__Avatar {
margin-right: 4px;
width: 16px;
height: 16px;
}

&__Separator {
Expand Down
1 change: 1 addition & 0 deletions packages/frontend/src/components/data/Identifier.scss
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
}

&__Avatar {
@include mixins.AvatarSize;
flex-shrink: 0;
margin-right: 10px;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,18 @@
position: absolute;
top: 0;
left: 50%;
transform: translate(-45%, -35%);

&--Christmas {
background: url('/images/christmas-hat.svg') center no-repeat;
background-size: contain;
transform: translate(-45%, -35%);
width: 100%;
height: 48%;
}
}

&__Image {
width: 100%;
height: 48%;
background: url('/images/christmas-hat.svg') center no-repeat;
background-size: contain;
height: 100%;
}
}
16 changes: 8 additions & 8 deletions packages/frontend/src/components/imageGenerator/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@ import { minidenticon } from 'minidenticons'
import { useMemo } from 'react'
import './ImageGenerator.scss'

export default function ImageGenerator ({ username, hat = null, saturation, lightness, ...props }) {
export default function ImageGenerator ({ username, className, hat = null, saturation, lightness, ...props }) {
const svgURI = useMemo(
() => 'data:image/svg+xml;utf8,' + encodeURIComponent(minidenticon(username, saturation, lightness)),
[username, saturation, lightness]
)

const ImageElement = <Image src={svgURI} alt={username || ''} {...props} />
const ImageElement = <Image src={svgURI} alt={username || ''} className={'ImageGenerator__Image'} {...props}/>

const hatClasses = {
christmas: 'ImageGenerator__Hat--Christmas'
}

return hat
? <div className={'ImageGenerator'}>
{hat && <div className={`ImageGenerator__Hat ${hatClasses?.[hat] || ''}`}></div>}
{ImageElement}
</div>
: ImageElement
return (
<div className={`ImageGenerator ${className || ''}`}>
{hat && <div className={`ImageGenerator__Hat ${hatClasses?.[hat] || ''}`}></div>}
{ImageElement}
</div>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
.Identifier,
.TransactionsListItem__AliasContainer,
.Identifier__Avatar,
img,
a {
display: block !important;
}
Expand Down
2 changes: 2 additions & 0 deletions packages/frontend/src/styles/components/Table.scss
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@

&__Avatar {
margin-left: 8px;
width: 32px;
height: 32px;
}

&__SortDirection {
Expand Down
9 changes: 7 additions & 2 deletions packages/frontend/src/styles/mixins.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
@import './variables.scss';

@mixin AvatarSize() {
height: 24px;
width: 24px;
}

@mixin DefListItem($clickable: true) {
display: flex;
width: 100%;
Expand Down Expand Up @@ -41,9 +46,9 @@
}

&__Avatar {
@include AvatarSize;
flex-shrink: 0;
margin-right: 12px;
height: 28px;
width: 28px;
}

&__NotActiveText {
Expand Down

0 comments on commit c44284f

Please sign in to comment.