mirror of
https://github.com/misode/misode.github.io.git
synced 2026-04-26 08:26:51 +00:00
Special support for obsolete tags
This commit is contained in:
@@ -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>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user