blob: 5ccf80a9960b6a0da61b7fada7e8c2bd8313205f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
import React, { useMemo } from "react";
import { type RegionId } from "../config/RegionConfig";
import "./LineIcon.css";
interface LineIconProps {
line: string;
/**
* @deprecated Unused since region is only Vigo
*/
region?: RegionId;
mode?: "rounded"|"pill"|"default";
}
const LineIcon: React.FC<LineIconProps> = ({
line,
mode = "default",
}) => {
const formattedLine = useMemo(() => {
return /^[a-zA-Z]/.test(line) ? line : `L${line}`;
}, [line]);
const cssVarName = `--line-${formattedLine.toLowerCase()}`;
const cssTextVarName = `--line-${formattedLine.toLowerCase()}-text`;
return (
<span
className={`line-icon-${mode}`}
style={
{
"--line-colour": `var(${cssVarName})`,
"--line-text-colour": `var(${cssTextVarName}, #000000)`,
} as React.CSSProperties
}
>
{line}
</span>
);
};
export default LineIcon;
|