@graph-render/tournament-tree 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintrc.json +6 -0
- package/CHANGELOG.md +23 -0
- package/README.md +0 -0
- package/dist/index.js +2258 -0
- package/dist/src/components/BracketToolbar.d.ts +11 -0
- package/dist/src/components/BracketToolbar.d.ts.map +1 -0
- package/dist/src/components/SquashNode.d.ts +10 -0
- package/dist/src/components/SquashNode.d.ts.map +1 -0
- package/dist/src/components/TournamentBracket.d.ts +4 -0
- package/dist/src/components/TournamentBracket.d.ts.map +1 -0
- package/dist/src/constants/index.d.ts +3 -0
- package/dist/src/constants/index.d.ts.map +1 -0
- package/dist/src/constants/node.d.ts +127 -0
- package/dist/src/constants/node.d.ts.map +1 -0
- package/dist/src/constants/tournament.d.ts +4 -0
- package/dist/src/constants/tournament.d.ts.map +1 -0
- package/dist/src/contexts/BracketThemeContext.d.ts +16 -0
- package/dist/src/contexts/BracketThemeContext.d.ts.map +1 -0
- package/dist/src/index.d.ts +9 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/types/index.d.ts +3 -0
- package/dist/src/types/index.d.ts.map +1 -0
- package/dist/src/types/squash.d.ts +18 -0
- package/dist/src/types/squash.d.ts.map +1 -0
- package/dist/src/types/tournament.d.ts +13 -0
- package/dist/src/types/tournament.d.ts.map +1 -0
- package/dist/src/utils/pathKeys.d.ts +8 -0
- package/dist/src/utils/pathKeys.d.ts.map +1 -0
- package/dist/src/utils/roundLabels.d.ts +16 -0
- package/dist/src/utils/roundLabels.d.ts.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/index.html +18 -0
- package/package.json +51 -0
- package/project.json +60 -0
- package/src/components/BracketToolbar.tsx +135 -0
- package/src/components/SquashNode.tsx +813 -0
- package/src/components/TournamentBracket.tsx +992 -0
- package/src/constants/index.ts +2 -0
- package/src/constants/node.ts +96 -0
- package/src/constants/tournament.ts +54 -0
- package/src/contexts/BracketThemeContext.tsx +35 -0
- package/src/index.ts +12 -0
- package/src/types/index.ts +2 -0
- package/src/types/squash.ts +21 -0
- package/src/types/tournament.ts +14 -0
- package/src/utils/pathKeys.ts +50 -0
- package/src/utils/roundLabels.ts +110 -0
- package/tsconfig.json +19 -0
- package/tsconfig.node.json +11 -0
- package/vite.config.ts +21 -0
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
interface BracketToolbarProps {
|
|
4
|
+
isDarkMode: boolean;
|
|
5
|
+
isNavigationMode: boolean;
|
|
6
|
+
onToggleDarkMode: () => void;
|
|
7
|
+
onToggleNavigationMode: () => void;
|
|
8
|
+
onExportSVG: () => void;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const iconSize = 16;
|
|
12
|
+
|
|
13
|
+
const DownloadIcon = () => (
|
|
14
|
+
<svg width={iconSize} height={iconSize} viewBox="0 0 24 24" fill="none" aria-hidden="true">
|
|
15
|
+
<path d="M12 4v9" stroke="currentColor" strokeWidth="2" strokeLinecap="round" />
|
|
16
|
+
<path
|
|
17
|
+
d="m8.5 10.5 3.5 3.5 3.5-3.5"
|
|
18
|
+
stroke="currentColor"
|
|
19
|
+
strokeWidth="2"
|
|
20
|
+
strokeLinecap="round"
|
|
21
|
+
strokeLinejoin="round"
|
|
22
|
+
/>
|
|
23
|
+
<path d="M5 19h14" stroke="currentColor" strokeWidth="2" strokeLinecap="round" />
|
|
24
|
+
</svg>
|
|
25
|
+
);
|
|
26
|
+
|
|
27
|
+
const SunMoonIcon = ({ isDarkMode }: { isDarkMode: boolean }) => (
|
|
28
|
+
<svg width={iconSize} height={iconSize} viewBox="0 0 24 24" fill="none" aria-hidden="true">
|
|
29
|
+
{isDarkMode ? (
|
|
30
|
+
<>
|
|
31
|
+
<circle cx="12" cy="12" r="4.5" stroke="currentColor" strokeWidth="2" />
|
|
32
|
+
<path
|
|
33
|
+
d="M12 2.5v2.25M12 19.25v2.25M4.75 12H2.5M21.5 12h-2.25M5.78 5.78 4.2 4.2M19.8 19.8l-1.58-1.58M18.22 5.78 19.8 4.2M4.2 19.8l1.58-1.58"
|
|
34
|
+
stroke="currentColor"
|
|
35
|
+
strokeWidth="1.7"
|
|
36
|
+
strokeLinecap="round"
|
|
37
|
+
/>
|
|
38
|
+
</>
|
|
39
|
+
) : (
|
|
40
|
+
<path
|
|
41
|
+
d="M20 14.7A8.5 8.5 0 0 1 9.3 4a8.5 8.5 0 1 0 10.7 10.7Z"
|
|
42
|
+
stroke="currentColor"
|
|
43
|
+
strokeWidth="2"
|
|
44
|
+
strokeLinejoin="round"
|
|
45
|
+
/>
|
|
46
|
+
)}
|
|
47
|
+
</svg>
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
const NavigationIcon = ({ isActive }: { isActive: boolean }) => (
|
|
51
|
+
<svg width={iconSize} height={iconSize} viewBox="0 0 24 24" fill="none" aria-hidden="true">
|
|
52
|
+
<rect
|
|
53
|
+
x="3.5"
|
|
54
|
+
y="5"
|
|
55
|
+
width="17"
|
|
56
|
+
height="14"
|
|
57
|
+
rx="3"
|
|
58
|
+
stroke="currentColor"
|
|
59
|
+
strokeWidth="1.8"
|
|
60
|
+
opacity={isActive ? 1 : 0.9}
|
|
61
|
+
/>
|
|
62
|
+
<path d="M8.5 5v14M15.5 5v14" stroke="currentColor" strokeWidth="1.4" opacity={0.7} />
|
|
63
|
+
<circle cx="12" cy="12" r="2.2" fill="currentColor" />
|
|
64
|
+
</svg>
|
|
65
|
+
);
|
|
66
|
+
|
|
67
|
+
export const BracketToolbar = React.memo<BracketToolbarProps>(function BracketToolbar({
|
|
68
|
+
isDarkMode,
|
|
69
|
+
isNavigationMode,
|
|
70
|
+
onToggleDarkMode,
|
|
71
|
+
onToggleNavigationMode,
|
|
72
|
+
onExportSVG,
|
|
73
|
+
}) {
|
|
74
|
+
const buttonBaseStyle: React.CSSProperties = {
|
|
75
|
+
display: 'flex',
|
|
76
|
+
alignItems: 'center',
|
|
77
|
+
justifyContent: 'center',
|
|
78
|
+
width: 32,
|
|
79
|
+
height: 32,
|
|
80
|
+
borderRadius: 10,
|
|
81
|
+
border: `1px solid ${isDarkMode ? '#38424d' : '#e4ded2'}`,
|
|
82
|
+
background: isDarkMode ? '#232b33' : '#f7f3ec',
|
|
83
|
+
color: isDarkMode ? '#f7f5ef' : '#4b5563',
|
|
84
|
+
cursor: 'pointer',
|
|
85
|
+
boxShadow: 'none',
|
|
86
|
+
transition: 'background-color 120ms ease, color 120ms ease, transform 120ms ease',
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
return (
|
|
90
|
+
<div
|
|
91
|
+
style={{
|
|
92
|
+
display: 'flex',
|
|
93
|
+
gap: 8,
|
|
94
|
+
alignItems: 'center',
|
|
95
|
+
}}
|
|
96
|
+
>
|
|
97
|
+
<button type="button" onClick={onExportSVG} style={buttonBaseStyle} title="Export as SVG">
|
|
98
|
+
<DownloadIcon />
|
|
99
|
+
</button>
|
|
100
|
+
|
|
101
|
+
<button
|
|
102
|
+
type="button"
|
|
103
|
+
onClick={onToggleNavigationMode}
|
|
104
|
+
style={{
|
|
105
|
+
...buttonBaseStyle,
|
|
106
|
+
background: isNavigationMode
|
|
107
|
+
? isDarkMode
|
|
108
|
+
? '#33403d'
|
|
109
|
+
: '#e7ede3'
|
|
110
|
+
: buttonBaseStyle.background,
|
|
111
|
+
borderColor: isNavigationMode
|
|
112
|
+
? isDarkMode
|
|
113
|
+
? '#6d8470'
|
|
114
|
+
: '#b8c7ae'
|
|
115
|
+
: (buttonBaseStyle.border as string),
|
|
116
|
+
color: isNavigationMode ? (isDarkMode ? '#f5f8f2' : '#516347') : buttonBaseStyle.color,
|
|
117
|
+
}}
|
|
118
|
+
title={isNavigationMode ? 'Exit Navigation Mode' : 'Enter Navigation Mode'}
|
|
119
|
+
>
|
|
120
|
+
<NavigationIcon isActive={isNavigationMode} />
|
|
121
|
+
</button>
|
|
122
|
+
|
|
123
|
+
<button
|
|
124
|
+
type="button"
|
|
125
|
+
onClick={onToggleDarkMode}
|
|
126
|
+
style={buttonBaseStyle}
|
|
127
|
+
title={isDarkMode ? 'Switch to Light Mode' : 'Switch to Dark Mode'}
|
|
128
|
+
>
|
|
129
|
+
<SunMoonIcon isDarkMode={isDarkMode} />
|
|
130
|
+
</button>
|
|
131
|
+
</div>
|
|
132
|
+
);
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
BracketToolbar.displayName = 'BracketToolbar';
|