|
1 | 1 | import React, { useRef, useEffect, useState, useCallback } from 'react' |
2 | 2 | import { navigate } from 'gatsby' |
3 | 3 | import '../styles/timeline.css' |
4 | | - |
5 | | -const CATEGORY_COLORS = { |
6 | | - systems: '#ff6b6b', |
7 | | - 'general-purpose': '#4ecdc4', |
8 | | - functional: '#a78bfa', |
9 | | - scripting: '#fbbf24', |
10 | | - web: '#60a5fa', |
11 | | - historical: '#9ca3af', |
12 | | - esoteric: '#f472b6', |
13 | | - jvm: '#fb923c', |
14 | | - shell: '#34d399', |
15 | | - 'ml-family': '#c084fc', |
16 | | -} |
17 | | - |
18 | | -const CATEGORY_LANES = { |
19 | | - historical: 0, |
20 | | - systems: 1, |
21 | | - 'general-purpose': 2, |
22 | | - functional: 3, |
23 | | - 'ml-family': 4, |
24 | | - jvm: 5, |
25 | | - scripting: 6, |
26 | | - web: 7, |
27 | | - shell: 8, |
28 | | - esoteric: 9, |
29 | | -} |
30 | | - |
31 | | -const ALL_CATEGORIES = Object.keys(CATEGORY_LANES) |
| 4 | +import { CATEGORY_COLORS, CATEGORY_LANES, CATEGORIES } from '../categories' |
32 | 5 |
|
33 | 6 | export default function TimelineGraph({ languages }) { |
34 | 7 | const containerRef = useRef(null) |
35 | 8 | const svgRef = useRef(null) |
36 | 9 | const tooltipRef = useRef(null) |
37 | | - const [activeCategories, setActiveCategories] = useState(new Set(ALL_CATEGORIES)) |
| 10 | + const [activeCategories, setActiveCategories] = useState(new Set(CATEGORIES)) |
38 | 11 | const [dimensions, setDimensions] = useState({ width: 1200, height: 450 }) |
39 | 12 |
|
40 | 13 | const toggleCategory = (cat) => { |
@@ -255,7 +228,7 @@ export default function TimelineGraph({ languages }) { |
255 | 228 | <span style={{ fontSize: '0.7rem', color: 'var(--text-muted)', fontFamily: "'JetBrains Mono', monospace", marginRight: '0.25rem' }}> |
256 | 229 | filter |
257 | 230 | </span> |
258 | | - {ALL_CATEGORIES.map(cat => ( |
| 231 | + {CATEGORIES.map(cat => ( |
259 | 232 | <button |
260 | 233 | key={cat} |
261 | 234 | className={`timeline-control-btn ${activeCategories.has(cat) ? 'active' : ''}`} |
|
0 commit comments