Special support for obsolete tags

This commit is contained in:
Misode
2023-06-07 19:44:38 +02:00
parent a471c93a22
commit 42e8da47f7
4 changed files with 11 additions and 3 deletions

View File

@@ -1,4 +1,5 @@
import { hashString } from '../Utils.js'
import { useLocale } from '../contexts/Locale.jsx'
import { Octicon } from './index.js'
interface Props {
@@ -7,9 +8,14 @@ interface Props {
onClick?: (e: MouseEvent) => unknown,
}
export function Badge({ label, active, onClick }: Props) {
const color = label === 'breaking' ? 5 : hashString(label) % 360
return <div class={`badge${active ? ' active' : ''}${onClick ? ' clickable' : ''}`} style={`--tint: ${color}`} onClick={onClick}>
const { locale } = useLocale()
const color = {
breaking: 5,
obsolete: 340,
}[label] ?? (hashString(label) % 360)
return <div class={`badge${active ? ' active' : ''}${onClick ? ' clickable' : ''}${label === 'obsolete' ? ' tooltipped tip-se' : ''}`} style={`--tint: ${color}`} onClick={onClick} aria-label={{ obsolete: locale('change.obsolete') }[label]}>
{label === 'breaking' && Octicon.alert}
{label === 'obsolete' && Octicon.circle_slash}
{label}
</div>
}