diff options
| author | Ariel Costas Guerrero <ariel@costas.dev> | 2025-10-21 17:38:01 +0200 |
|---|---|---|
| committer | Ariel Costas Guerrero <ariel@costas.dev> | 2025-10-21 17:38:01 +0200 |
| commit | 12ecc97b07093f3cac6567c70ff75d57b429c674 (patch) | |
| tree | cf4ec0abe4e1d20c01c62e0fc04af5eaa885e881 /src/frontend/app/components/LineIcon.tsx | |
| parent | 67c1dd5cb0025235c29ebd1f1706e5c17392dbff (diff) | |
Implement new Santiago region (WIP)
Diffstat (limited to 'src/frontend/app/components/LineIcon.tsx')
| -rw-r--r-- | src/frontend/app/components/LineIcon.tsx | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/src/frontend/app/components/LineIcon.tsx b/src/frontend/app/components/LineIcon.tsx index 3d613e6..4f4bfd9 100644 --- a/src/frontend/app/components/LineIcon.tsx +++ b/src/frontend/app/components/LineIcon.tsx @@ -1,14 +1,23 @@ -import React from "react"; +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 }) => { - const formattedLine = /^[a-zA-Z]/.test(line) ? line : `L${line}`; +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 line-${formattedLine.toLowerCase()}`}> + <span + className="line-icon" + style={{ borderColor: `var(${cssVarName})` }} + > {formattedLine} </span> ); |
