diff --git a/src/components/Inbox/DialogAvatar.module.scss b/src/components/Inbox/DialogAvatar.module.scss new file mode 100644 index 00000000..0bf16d19 --- /dev/null +++ b/src/components/Inbox/DialogAvatar.module.scss @@ -0,0 +1,35 @@ +.DialogAvatar { + width: 40px; + height: 40px; + border-radius: 100%; + display: flex; + align-items: center; + justify-content: center; + position: relative; + + &.online::before { + content: ''; + position: absolute; + background: #2bb452; + width: 8px; + height: 8px; + top: -2px; + right: -2px; + border-radius: 50%; + border: 3px solid #fff; + } + + > img, + > .letter { + display: block; + border-radius: 100%; + } + + > .letter { + margin-bottom: -2px; + font-weight: 500; + font-size: 18px; + line-height: 10px; + color: #fff; + } +} diff --git a/src/components/Inbox/DialogAvatar.tsx b/src/components/Inbox/DialogAvatar.tsx new file mode 100644 index 00000000..7d3788d8 --- /dev/null +++ b/src/components/Inbox/DialogAvatar.tsx @@ -0,0 +1,48 @@ +import { Show, createMemo } from 'solid-js' +import './DialogCard.module.scss' +import styles from './DialogAvatar.module.scss' +import { clsx } from 'clsx' + +type Props = { + url: string + name: string + online?: boolean +} + +const colors = [ + '#001219', + '#005f73', + '#0a9396', + '#94d2bd', + '#ee9b00', + '#ca6702', + '#ae2012', + '#9b2226', + '#668CFF', + '#C34CFE', + '#E699FF', + '#6633FF' +] + +const getById = (letter: string) => + colors[Math.abs(Number(BigInt(letter.toLowerCase().charCodeAt(0) - 97) % BigInt(colors.length)))] + +const DialogAvatar = (props: Props) => { + const nameFirstLetter = props.name.substring(0, 1) + const randomBg = createMemo(() => { + return getById(nameFirstLetter) + }) + + return ( +