blob: 4f4bfd96fc25cde4a90ddb195d1c29e5059da6cc (
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
|
import React, { useMemo } from "react";
import "./LineIcon.css";
import { type RegionId } from "../data/RegionConfig";
interface LineIconProps {
line: string;
region?: RegionId;
}
const LineIcon: React.FC<LineIconProps> = ({ line, region = "vigo" }) => {
const formattedLine = useMemo(() => {
return /^[a-zA-Z]/.test(line) ? line : `L${line}`;
}, [line]);
const cssVarName = `--line-${region}-${formattedLine.toLowerCase()}`;
return (
<span
className="line-icon"
style={{ borderColor: `var(${cssVarName})` }}
>
{formattedLine}
</span>
);
};
export default LineIcon;
|