-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(UserPic): show colored circle by default
- Loading branch information
1 parent
15eb911
commit e080bd0
Showing
5 changed files
with
80 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import styled from 'styled-components'; | ||
|
||
import { stringToColor, isColorDark } from '../utils/stringToColor'; | ||
|
||
export const Circle = styled.div<{ size: number; str: string }>` | ||
border-radius: 100%; | ||
${({ size, str }) => { | ||
const mainColor = stringToColor(str); | ||
return { | ||
width: `${size}px`, | ||
height: `${size}px`, | ||
background: `linear-gradient(90deg,${mainColor},${stringToColor(str.toUpperCase())})`, | ||
color: `${isColorDark(mainColor) ? 'white' : 'black'}`, | ||
fontSize: `calc(${size / 2}px - 2px)`, | ||
}; | ||
}}; | ||
display: flex; | ||
align-items: center; | ||
justify-content: center; | ||
letter-spacing: -1.5px; | ||
font-weight: 600; | ||
user-select: none; | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export const getInitials = (fullName?: string | null) => { | ||
if (!fullName) return ''; | ||
const arr = fullName.split(' '); | ||
return `${arr[0]?.[0] || ''} ${arr[1]?.[0] || ''}`; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
export const preloadImage = (src: string) => { | ||
return new Promise((resolve, reject) => { | ||
const img = new Image(); | ||
|
||
img.onload = () => { | ||
resolve(img); | ||
}; | ||
|
||
img.onerror = (error) => { | ||
reject(error); | ||
}; | ||
|
||
img.src = src; | ||
}); | ||
}; |