mirror of
https://github.com/status-im/status-web.git
synced 2025-01-12 21:54:36 +00:00
367145c9ff
* update `tamagui` * a ch * f * f
22 lines
516 B
TypeScript
22 lines
516 B
TypeScript
import { opacity as colorOpacity } from '../consts/opacity'
|
|
|
|
export type RGBAColor = `rgba(${string} / ${string}%)`
|
|
|
|
export type HexColor = `#${string}`
|
|
|
|
type Opacity = keyof typeof colorOpacity
|
|
|
|
export function getColorWithOpacity(
|
|
color: RGBAColor | HexColor,
|
|
opacity: Opacity
|
|
): string {
|
|
if (color.startsWith('rgba')) {
|
|
return color
|
|
.replace(' / ', '/')
|
|
.replace(/\s/g, ',')
|
|
.replace(/(\d+)%/, `${colorOpacity[opacity].decimal}`)
|
|
}
|
|
|
|
return `${color}${colorOpacity[opacity].hex}`
|
|
}
|