-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #52 from tloncorp/ja/notif-reno
garden: new notifications
- Loading branch information
Showing
17 changed files
with
501 additions
and
75 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 |
---|---|---|
|
@@ -5,4 +5,5 @@ dist-ssr | |
*.local | ||
stats.html | ||
.eslintcache | ||
.vercel | ||
.vercel | ||
storybook-static |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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,66 @@ | ||
import cn from 'classnames'; | ||
import React, { useState } from 'react'; | ||
import ColorBoxIcon from '../components/icons/ColorBoxIcon'; | ||
import { isColor } from '../state/util'; | ||
import { useIsDark } from '../logic/useMedia'; | ||
import { useCalm } from '../state/settings'; | ||
import { useAvatar } from '../state/avatar'; | ||
|
||
interface GroupAvatarProps { | ||
image?: string; | ||
size?: string; | ||
className?: string; | ||
title?: string; | ||
loadImage?: boolean; | ||
} | ||
|
||
const textSize = (size: string) => { | ||
const dims = parseInt(size.replace(/[^0-9.]/g, ''), 10); | ||
switch (dims) { | ||
case 7272: | ||
return 'text-3xl'; | ||
case 2020: | ||
return 'text-xl'; | ||
case 1616: | ||
return 'text-xl'; | ||
case 1414: | ||
return 'text-xl'; | ||
case 1212: | ||
return 'text-xl'; | ||
case 66: | ||
return 'text-sm'; | ||
default: | ||
return 'text-sm'; | ||
} | ||
}; | ||
|
||
export default function GroupAvatar({ | ||
image, | ||
size = 'h-6 w-6', | ||
className, | ||
title, | ||
loadImage = true, | ||
}: GroupAvatarProps) { | ||
const { hasLoaded, load } = useAvatar(image || ''); | ||
const showImage = hasLoaded || loadImage; | ||
const dark = useIsDark(); | ||
const calm = useCalm(); | ||
let background; | ||
const symbols = [...(title || '')]; | ||
|
||
if (showImage && !calm.disableRemoteContent) { | ||
background = image || (dark ? '#333333' : '#E5E5E5'); | ||
} else { | ||
background = dark ? '#333333' : '#E5E5E5'; | ||
} | ||
|
||
return image && showImage && !calm.disableRemoteContent && !isColor(image) ? ( | ||
<img className={cn('rounded', size, className)} src={image} onLoad={load} /> | ||
) : ( | ||
<ColorBoxIcon | ||
className={cn('rounded', size, textSize(size), className)} | ||
color={background} | ||
letter={title ? symbols[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
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,27 @@ | ||
import React from 'react'; | ||
import classNames from 'classnames'; | ||
import { IconProps } from './icon'; | ||
import { foregroundFromBackground } from '../Avatar'; | ||
|
||
interface ColorBoxIconProps extends IconProps { | ||
color: string; | ||
letter: string; | ||
} | ||
|
||
export default function ColorBoxIcon({ | ||
className, | ||
color, | ||
letter, | ||
}: ColorBoxIconProps) { | ||
return ( | ||
<div | ||
className={classNames( | ||
className, | ||
'flex items-center justify-center rounded-md' | ||
)} | ||
style={{ backgroundColor: color }} | ||
> | ||
<span style={{ color: foregroundFromBackground(color) }}>{letter}</span> | ||
</div> | ||
); | ||
} |
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
Oops, something went wrong.