@oddsmith/ui 0.0.0

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.
Files changed (185) hide show
  1. package/.eleventy.cjs +14 -0
  2. package/LICENSE +28 -0
  3. package/README.md +118 -0
  4. package/custom-elements.json +1539 -0
  5. package/docs/_README/index.html +4 -0
  6. package/docs/api/index.html +2100 -0
  7. package/docs/components.bundle.js +1669 -0
  8. package/docs/components.bundle.js.map +1 -0
  9. package/docs/docs.css +162 -0
  10. package/docs/examples/index.html +56 -0
  11. package/docs/index.html +53 -0
  12. package/docs/install/index.html +45 -0
  13. package/docs/prism-okaidia.css +123 -0
  14. package/docs-src/.nojekyll +0 -0
  15. package/docs-src/_README.md +7 -0
  16. package/docs-src/_data/api.11tydata.js +8 -0
  17. package/docs-src/_includes/example.11ty.js +35 -0
  18. package/docs-src/_includes/footer.11ty.js +6 -0
  19. package/docs-src/_includes/header.11ty.js +7 -0
  20. package/docs-src/_includes/nav.11ty.js +11 -0
  21. package/docs-src/_includes/page.11ty.js +32 -0
  22. package/docs-src/_includes/relative-path.cjs +9 -0
  23. package/docs-src/api.11ty.js +85 -0
  24. package/docs-src/bundle.ts +9 -0
  25. package/docs-src/docs.css +162 -0
  26. package/docs-src/examples/index.md +15 -0
  27. package/docs-src/index.md +39 -0
  28. package/docs-src/install.md +28 -0
  29. package/docs-src/package.json +3 -0
  30. package/index.html +19 -0
  31. package/karma.conf.cjs +24 -0
  32. package/main.css +210 -0
  33. package/main.ts +124 -0
  34. package/package.json +86 -0
  35. package/previews/casino.ts +12 -0
  36. package/previews/catalog.ts +94 -0
  37. package/previews/leaderboard-v1.ts +12 -0
  38. package/previews/leaderboard-v2.ts +17 -0
  39. package/previews/sample-data.ts +101 -0
  40. package/previews/sf-leaderboard.ts +100 -0
  41. package/previews/sf-live-feed.ts +15 -0
  42. package/previews/streaks.ts +40 -0
  43. package/previews/types.ts +18 -0
  44. package/src/components/README.md +16 -0
  45. package/src/components/casino-leaderboard/casino-leaderboard.html +80 -0
  46. package/src/components/casino-leaderboard/casino-leaderboard.scss +585 -0
  47. package/src/components/casino-leaderboard/casino-leaderboard.ts +136 -0
  48. package/src/components/casino-leaderboard/data.ts +111 -0
  49. package/src/components/casino-leaderboard/index.ts +5 -0
  50. package/src/components/casino-leaderboard/todo.txt +2 -0
  51. package/src/components/casino-leaderboard/types.ts +19 -0
  52. package/src/components/leaderboard/components/leaderboard.ts +373 -0
  53. package/src/components/leaderboard/components/player-card.ts +342 -0
  54. package/src/components/leaderboard/components/ui.ts +452 -0
  55. package/src/components/leaderboard/data.ts +152 -0
  56. package/src/components/leaderboard/index.ts +2 -0
  57. package/src/components/leaderboard/main.ts +42 -0
  58. package/src/components/leaderboard/styles.ts +67 -0
  59. package/src/components/leaderboard/types.ts +28 -0
  60. package/src/components/leaderboard-v2/components/sf-leaderboard-player.ts +451 -0
  61. package/src/components/leaderboard-v2/components/sf-leaderboard-ui.ts +512 -0
  62. package/src/components/leaderboard-v2/components/sf-leaderboard.ts +205 -0
  63. package/src/components/leaderboard-v2/constants.ts +16 -0
  64. package/src/components/leaderboard-v2/demo/sample-data.ts +152 -0
  65. package/src/components/leaderboard-v2/events.ts +13 -0
  66. package/src/components/leaderboard-v2/icons.ts +22 -0
  67. package/src/components/leaderboard-v2/index.ts +23 -0
  68. package/src/components/leaderboard-v2/sf-leaderboard.html +1 -0
  69. package/src/components/leaderboard-v2/sf-leaderboard.scss +382 -0
  70. package/src/components/leaderboard-v2/tokens.ts +35 -0
  71. package/src/components/leaderboard-v2/types.ts +30 -0
  72. package/src/components/sf-leaderboard/index.ts +77 -0
  73. package/src/components/sf-leaderboard/sections/footer-section/footer-section.host.ts +3 -0
  74. package/src/components/sf-leaderboard/sections/footer-section/footer-section.html +3 -0
  75. package/src/components/sf-leaderboard/sections/footer-section/footer-section.scss +18 -0
  76. package/src/components/sf-leaderboard/sections/footer-section/footer-section.ts +22 -0
  77. package/src/components/sf-leaderboard/sections/header-section/header-section.host.ts +14 -0
  78. package/src/components/sf-leaderboard/sections/header-section/header-section.html +27 -0
  79. package/src/components/sf-leaderboard/sections/header-section/header-section.scss +189 -0
  80. package/src/components/sf-leaderboard/sections/header-section/header-section.ts +70 -0
  81. package/src/components/sf-leaderboard/sections/ranking-section/ranking-section.host.ts +22 -0
  82. package/src/components/sf-leaderboard/sections/ranking-section/ranking-section.html +38 -0
  83. package/src/components/sf-leaderboard/sections/ranking-section/ranking-section.scss +99 -0
  84. package/src/components/sf-leaderboard/sections/ranking-section/ranking-section.ts +121 -0
  85. package/src/components/sf-leaderboard/sections/stats-section/stats-section.host.ts +8 -0
  86. package/src/components/sf-leaderboard/sections/stats-section/stats-section.html +6 -0
  87. package/src/components/sf-leaderboard/sections/stats-section/stats-section.scss +44 -0
  88. package/src/components/sf-leaderboard/sections/stats-section/stats-section.ts +41 -0
  89. package/src/components/sf-leaderboard/sections/table-section/table-section.host.ts +17 -0
  90. package/src/components/sf-leaderboard/sections/table-section/table-section.html +19 -0
  91. package/src/components/sf-leaderboard/sections/table-section/table-section.scss +37 -0
  92. package/src/components/sf-leaderboard/sections/table-section/table-section.ts +108 -0
  93. package/src/components/sf-leaderboard/services/index.ts +22 -0
  94. package/src/components/sf-leaderboard/services/sf-leaderboard-data.service.ts +54 -0
  95. package/src/components/sf-leaderboard/services/sf-leaderboard.state.ts +160 -0
  96. package/src/components/sf-leaderboard/shared/components/activity-feed/activity-feed.host.ts +7 -0
  97. package/src/components/sf-leaderboard/shared/components/activity-feed/activity-feed.html +10 -0
  98. package/src/components/sf-leaderboard/shared/components/activity-feed/activity-feed.scss +180 -0
  99. package/src/components/sf-leaderboard/shared/components/activity-feed/activity-feed.ts +88 -0
  100. package/src/components/sf-leaderboard/shared/components/filters/filters.host.ts +12 -0
  101. package/src/components/sf-leaderboard/shared/components/filters/filters.html +22 -0
  102. package/src/components/sf-leaderboard/shared/components/filters/filters.scss +122 -0
  103. package/src/components/sf-leaderboard/shared/components/filters/filters.ts +75 -0
  104. package/src/components/sf-leaderboard/shared/components/player-avatar/player-avatar.host.ts +9 -0
  105. package/src/components/sf-leaderboard/shared/components/player-avatar/player-avatar.html +5 -0
  106. package/src/components/sf-leaderboard/shared/components/player-avatar/player-avatar.scss +81 -0
  107. package/src/components/sf-leaderboard/shared/components/player-avatar/player-avatar.ts +34 -0
  108. package/src/components/sf-leaderboard/shared/components/podium/map-players.ts +24 -0
  109. package/src/components/sf-leaderboard/shared/components/podium/podium.host.ts +10 -0
  110. package/src/components/sf-leaderboard/shared/components/podium/podium.html +53 -0
  111. package/src/components/sf-leaderboard/shared/components/podium/podium.scss +580 -0
  112. package/src/components/sf-leaderboard/shared/components/podium/podium.ts +49 -0
  113. package/src/components/sf-leaderboard/shared/components/podium/podium.types.ts +9 -0
  114. package/src/components/sf-leaderboard/shared/components/rank-badge/rank-badge.host.ts +11 -0
  115. package/src/components/sf-leaderboard/shared/components/rank-badge/rank-badge.html +9 -0
  116. package/src/components/sf-leaderboard/shared/components/rank-badge/rank-badge.scss +98 -0
  117. package/src/components/sf-leaderboard/shared/components/rank-badge/rank-badge.ts +63 -0
  118. package/src/components/sf-leaderboard/shared/components/stat-card/stat-card.host.ts +9 -0
  119. package/src/components/sf-leaderboard/shared/components/stat-card/stat-card.html +15 -0
  120. package/src/components/sf-leaderboard/shared/components/stat-card/stat-card.scss +210 -0
  121. package/src/components/sf-leaderboard/shared/components/stat-card/stat-card.ts +36 -0
  122. package/src/components/sf-leaderboard/shared/components/table/table.host.ts +5 -0
  123. package/src/components/sf-leaderboard/shared/components/table/table.html +11 -0
  124. package/src/components/sf-leaderboard/shared/components/table/table.scss +212 -0
  125. package/src/components/sf-leaderboard/shared/components/table/table.ts +111 -0
  126. package/src/components/sf-leaderboard/shared/constants/defaults.ts +7 -0
  127. package/src/components/sf-leaderboard/shared/constants/filters.ts +16 -0
  128. package/src/components/sf-leaderboard/shared/constants/index.ts +5 -0
  129. package/src/components/sf-leaderboard/shared/constants/player-stats.ts +3 -0
  130. package/src/components/sf-leaderboard/shared/constants/stats-overview.ts +38 -0
  131. package/src/components/sf-leaderboard/shared/constants/tags.ts +16 -0
  132. package/src/components/sf-leaderboard/shared/styles/_section.scss +35 -0
  133. package/src/components/sf-leaderboard/shared/types/data.ts +29 -0
  134. package/src/components/sf-leaderboard/shared/types/events.ts +30 -0
  135. package/src/components/sf-leaderboard/shared/types/player-stats.ts +3 -0
  136. package/src/components/sf-leaderboard/shared/types/sections.ts +100 -0
  137. package/src/components/sf-leaderboard/shared/utils/utils.ts +17 -0
  138. package/src/components/sf-leaderboard/theme/THEMING.md +54 -0
  139. package/src/components/sf-leaderboard/theme/context.ts +16 -0
  140. package/src/components/sf-leaderboard/theme/default-theme.ts +4 -0
  141. package/src/components/sf-leaderboard/theme/hex-to-rgb.ts +25 -0
  142. package/src/components/sf-leaderboard/theme/index.ts +18 -0
  143. package/src/components/sf-leaderboard/theme/inject-theme.ts +39 -0
  144. package/src/components/sf-leaderboard/theme/load-theme.ts +26 -0
  145. package/src/components/sf-leaderboard/theme/merge-theme.ts +59 -0
  146. package/src/components/sf-leaderboard/theme/scss/_colors.scss +101 -0
  147. package/src/components/sf-leaderboard/theme/scss/shared.scss +123 -0
  148. package/src/components/sf-leaderboard/theme/styles.ts +6 -0
  149. package/src/components/sf-leaderboard/theme/theme-to-css-vars.ts +99 -0
  150. package/src/components/sf-leaderboard/theme/themes/fallback.json +62 -0
  151. package/src/components/sf-leaderboard/theme/themes/red.json +62 -0
  152. package/src/components/sf-leaderboard/theme/types.ts +71 -0
  153. package/src/components/sf-live-feed/components/avatar/avatar.host.ts +5 -0
  154. package/src/components/sf-live-feed/components/avatar/avatar.html +3 -0
  155. package/src/components/sf-live-feed/components/avatar/avatar.scss +24 -0
  156. package/src/components/sf-live-feed/components/avatar/avatar.ts +27 -0
  157. package/src/components/sf-live-feed/components/sf-live-feed/sf-live-feed.host.ts +8 -0
  158. package/src/components/sf-live-feed/components/sf-live-feed/sf-live-feed.html +10 -0
  159. package/src/components/sf-live-feed/components/sf-live-feed/sf-live-feed.scss +177 -0
  160. package/src/components/sf-live-feed/components/sf-live-feed/sf-live-feed.ts +65 -0
  161. package/src/components/sf-live-feed/constants.ts +4 -0
  162. package/src/components/sf-live-feed/demo/sample-data.ts +34 -0
  163. package/src/components/sf-live-feed/index.ts +19 -0
  164. package/src/components/sf-live-feed/styles/theme.scss +19 -0
  165. package/src/components/sf-live-feed/styles/theme.ts +5 -0
  166. package/src/components/sf-live-feed/types.ts +19 -0
  167. package/src/components/sf-live-feed/utils.ts +17 -0
  168. package/src/components/streaks/constants.ts +17 -0
  169. package/src/components/streaks/demo/sample-steps.ts +10 -0
  170. package/src/components/streaks/events.ts +8 -0
  171. package/src/components/streaks/index.ts +16 -0
  172. package/src/components/streaks/sf-streaks.html +26 -0
  173. package/src/components/streaks/sf-streaks.scss +351 -0
  174. package/src/components/streaks/sf-streaks.ts +235 -0
  175. package/src/components/streaks/types.ts +7 -0
  176. package/src/lib/lit/component.ts +10 -0
  177. package/src/lib/lit/safe-custom-element.ts +12 -0
  178. package/src/lib/lit/scss.ts +6 -0
  179. package/src/vite-env.d.ts +18 -0
  180. package/styles/global.css +125 -0
  181. package/todo.txt +54 -0
  182. package/tsconfig.json +31 -0
  183. package/vite.config.ts +56 -0
  184. package/vite.docs.config.ts +33 -0
  185. package/vite.lit-html-plugin.ts +43 -0
@@ -0,0 +1,452 @@
1
+ import { LitElement, html } from 'lit';
2
+ import { customElement, property } from 'lit/decorators.js';
3
+ import { unsafeHTML } from 'lit/directives/unsafe-html.js';
4
+ import { getIcon, sharedStyles } from '../styles';
5
+ import { css } from 'lit';
6
+ import { Badge } from '../types';
7
+
8
+ @customElement('rank-badge')
9
+ export class RankBadge extends LitElement {
10
+ static styles = [
11
+ sharedStyles,
12
+ css`
13
+ .badge {
14
+ display: flex;
15
+ align-items: center;
16
+ justify-content: center;
17
+ gap: 0.25rem;
18
+ border-radius: 0.5rem;
19
+ font-weight: 700;
20
+ font-size: 0.875rem;
21
+ min-width: 48px;
22
+ height: 32px;
23
+ padding: 0 0.5rem;
24
+ }
25
+ .badge.rank-1 {
26
+ background: var(--gold);
27
+ color: var(--background);
28
+ box-shadow: 0 0 20px oklch(0.8 0.18 85 / 0.4);
29
+ }
30
+ .badge.rank-2 {
31
+ background: var(--silver);
32
+ color: var(--background);
33
+ }
34
+ .badge.rank-3 {
35
+ background: var(--bronze);
36
+ color: var(--background);
37
+ }
38
+ .badge.rank-default {
39
+ background: var(--secondary);
40
+ color: var(--secondary-foreground);
41
+ }
42
+ .icon {
43
+ display: flex;
44
+ align-items: center;
45
+ }
46
+ `,
47
+ ];
48
+
49
+ @property({ type: Number }) rank = 1;
50
+
51
+ render() {
52
+ const rankClass = this.rank <= 3 ? `rank-${this.rank}` : 'rank-default';
53
+ const showIcon = this.rank <= 3;
54
+
55
+ return html`
56
+ <div class="badge ${rankClass}">
57
+ ${showIcon
58
+ ? html`<span class="icon">${unsafeHTML(getIcon('trophy', 12))}</span>`
59
+ : ''}
60
+ <span>${this.rank}</span>
61
+ </div>
62
+ `;
63
+ }
64
+ }
65
+
66
+ @customElement('xp-progress')
67
+ export class XPProgress extends LitElement {
68
+ static styles = [
69
+ sharedStyles,
70
+ css`
71
+ .container {
72
+ width: 100%;
73
+ }
74
+ .label-row {
75
+ display: flex;
76
+ align-items: center;
77
+ justify-content: space-between;
78
+ margin-bottom: 0.25rem;
79
+ }
80
+ .label {
81
+ font-size: 0.75rem;
82
+ color: var(--muted-foreground);
83
+ }
84
+ .track {
85
+ width: 100%;
86
+ background: var(--secondary);
87
+ border-radius: 9999px;
88
+ overflow: hidden;
89
+ }
90
+ .track.sm {
91
+ height: 6px;
92
+ }
93
+ .track.md {
94
+ height: 8px;
95
+ }
96
+ .track.lg {
97
+ height: 12px;
98
+ }
99
+ .fill {
100
+ height: 100%;
101
+ background: var(--primary);
102
+ border-radius: 9999px;
103
+ transition: width 0.5s ease-out;
104
+ }
105
+ `,
106
+ ];
107
+
108
+ @property({ type: Number }) xp = 0;
109
+ @property({ type: Number }) xpToNextLevel = 100;
110
+ @property({ type: Number }) level = 1;
111
+ @property({ type: Boolean }) showLabel = true;
112
+ @property({ type: String }) size: 'sm' | 'md' | 'lg' = 'md';
113
+
114
+ render() {
115
+ const progress = (this.xp / this.xpToNextLevel) * 100;
116
+
117
+ return html`
118
+ <div class="container">
119
+ ${this.showLabel
120
+ ? html`
121
+ <div class="label-row">
122
+ <span class="label">Level ${this.level}</span>
123
+ <span class="label"
124
+ >${this.xp.toLocaleString()} /
125
+ ${this.xpToNextLevel.toLocaleString()} XP</span
126
+ >
127
+ </div>
128
+ `
129
+ : ''}
130
+ <div class="track ${this.size}">
131
+ <div class="fill" style="width: ${progress}%"></div>
132
+ </div>
133
+ </div>
134
+ `;
135
+ }
136
+ }
137
+
138
+ @customElement('trend-indicator')
139
+ export class TrendIndicator extends LitElement {
140
+ static styles = [
141
+ sharedStyles,
142
+ css`
143
+ .container {
144
+ display: flex;
145
+ align-items: center;
146
+ gap: 2px;
147
+ }
148
+ .up {
149
+ color: var(--primary);
150
+ }
151
+ .down {
152
+ color: var(--destructive);
153
+ }
154
+ .same {
155
+ color: var(--muted-foreground);
156
+ }
157
+ .change {
158
+ font-size: 0.75rem;
159
+ font-weight: 500;
160
+ }
161
+ .icon {
162
+ display: flex;
163
+ align-items: center;
164
+ }
165
+ `,
166
+ ];
167
+
168
+ @property({ type: String }) trend: 'up' | 'down' | 'same' = 'same';
169
+ @property({ type: Number }) rankChange?: number;
170
+
171
+ render() {
172
+ const iconName =
173
+ this.trend === 'up'
174
+ ? 'trendingUp'
175
+ : this.trend === 'down'
176
+ ? 'trendingDown'
177
+ : 'minus';
178
+ const prefix = this.trend === 'up' ? '+' : this.trend === 'down' ? '-' : '';
179
+
180
+ return html`
181
+ <div class="container ${this.trend}">
182
+ <span class="icon">${unsafeHTML(getIcon(iconName, 16))}</span>
183
+ ${this.rankChange
184
+ ? html`<span class="change">${prefix}${this.rankChange}</span>`
185
+ : ''}
186
+ </div>
187
+ `;
188
+ }
189
+ }
190
+
191
+ @customElement('streak-badge')
192
+ export class StreakBadge extends LitElement {
193
+ static styles = [
194
+ sharedStyles,
195
+ css`
196
+ .badge {
197
+ display: flex;
198
+ align-items: center;
199
+ gap: 0.25rem;
200
+ padding: 0.25rem 0.5rem;
201
+ border-radius: 9999px;
202
+ background: oklch(0.75 0.2 50 / 0.2);
203
+ color: var(--accent);
204
+ font-size: 0.75rem;
205
+ font-weight: 500;
206
+ }
207
+ .icon {
208
+ display: flex;
209
+ align-items: center;
210
+ }
211
+ `,
212
+ ];
213
+
214
+ @property({ type: Number }) streak = 0;
215
+
216
+ render() {
217
+ if (this.streak < 3) return html``;
218
+
219
+ return html`
220
+ <div class="badge">
221
+ <span class="icon">${unsafeHTML(getIcon('flame', 12))}</span>
222
+ <span>${this.streak}</span>
223
+ </div>
224
+ `;
225
+ }
226
+ }
227
+
228
+ @customElement('level-badge')
229
+ export class LevelBadge extends LitElement {
230
+ static styles = [
231
+ sharedStyles,
232
+ css`
233
+ .badge {
234
+ display: flex;
235
+ align-items: center;
236
+ justify-content: center;
237
+ border-radius: 9999px;
238
+ border-width: 2px;
239
+ border-style: solid;
240
+ background: var(--background);
241
+ font-weight: 700;
242
+ }
243
+ .badge.sm {
244
+ width: 24px;
245
+ height: 24px;
246
+ font-size: 10px;
247
+ }
248
+ .badge.md {
249
+ width: 32px;
250
+ height: 32px;
251
+ font-size: 12px;
252
+ }
253
+ .badge.lg {
254
+ width: 40px;
255
+ height: 40px;
256
+ font-size: 14px;
257
+ }
258
+ .badge.level-90 {
259
+ border-color: var(--gold);
260
+ color: var(--gold);
261
+ box-shadow: 0 0 20px oklch(0.8 0.18 85 / 0.4);
262
+ }
263
+ .badge.level-70 {
264
+ border-color: var(--accent);
265
+ color: var(--accent);
266
+ box-shadow: 0 0 20px oklch(0.75 0.2 50 / 0.4);
267
+ }
268
+ .badge.level-50 {
269
+ border-color: var(--primary);
270
+ color: var(--primary);
271
+ box-shadow: 0 0 20px oklch(0.7 0.18 145 / 0.4);
272
+ }
273
+ .badge.level-default {
274
+ border-color: var(--muted-foreground);
275
+ color: var(--muted-foreground);
276
+ }
277
+ `,
278
+ ];
279
+
280
+ @property({ type: Number }) level = 1;
281
+ @property({ type: String }) size: 'sm' | 'md' | 'lg' = 'md';
282
+
283
+ render() {
284
+ const levelClass =
285
+ this.level >= 90
286
+ ? 'level-90'
287
+ : this.level >= 70
288
+ ? 'level-70'
289
+ : this.level >= 50
290
+ ? 'level-50'
291
+ : 'level-default';
292
+
293
+ return html`
294
+ <div class="badge ${this.size} ${levelClass}">${this.level}</div>
295
+ `;
296
+ }
297
+ }
298
+
299
+ @customElement('badge-display')
300
+ export class BadgeDisplay extends LitElement {
301
+ static styles = [
302
+ sharedStyles,
303
+ css`
304
+ .container {
305
+ display: flex;
306
+ align-items: center;
307
+ gap: 0.25rem;
308
+ }
309
+ .badge {
310
+ display: flex;
311
+ align-items: center;
312
+ justify-content: center;
313
+ width: 24px;
314
+ height: 24px;
315
+ border-radius: 0.375rem;
316
+ border: 1px solid;
317
+ font-size: 0.875rem;
318
+ }
319
+ .badge.common {
320
+ background: oklch(0.6 0.02 260 / 0.2);
321
+ border-color: oklch(0.6 0.02 260 / 0.4);
322
+ }
323
+ .badge.rare {
324
+ background: oklch(0.7 0.18 145 / 0.2);
325
+ border-color: oklch(0.7 0.18 145 / 0.4);
326
+ }
327
+ .badge.epic {
328
+ background: oklch(0.75 0.2 50 / 0.2);
329
+ border-color: oklch(0.75 0.2 50 / 0.4);
330
+ }
331
+ .badge.legendary {
332
+ background: oklch(0.8 0.18 85 / 0.2);
333
+ border-color: oklch(0.8 0.18 85 / 0.4);
334
+ }
335
+ .remaining {
336
+ font-size: 0.75rem;
337
+ color: var(--muted-foreground);
338
+ margin-left: 0.25rem;
339
+ }
340
+ .icon {
341
+ display: flex;
342
+ align-items: center;
343
+ }
344
+ `,
345
+ ];
346
+
347
+ @property({ type: Array }) badges: Badge[] = [];
348
+ @property({ type: Number }) max = 3;
349
+
350
+ private getBadgeIcon(icon: string): string {
351
+ const iconMap: Record<string, string> = {
352
+ trophy: getIcon('trophy', 14),
353
+ flame: getIcon('flame', 14),
354
+ star: getIcon('star', 14),
355
+ crown: getIcon('crown', 14),
356
+ zap: getIcon('zap', 14),
357
+ gem: getIcon('gem', 14),
358
+ };
359
+ return iconMap[icon] || '';
360
+ }
361
+
362
+ render() {
363
+ const displayBadges = this.badges.slice(0, this.max);
364
+ const remaining = this.badges.length - this.max;
365
+
366
+ return html`
367
+ <div class="container">
368
+ ${displayBadges.map(
369
+ (badge) => html`
370
+ <div class="badge ${badge.rarity}" title="${badge.name}">
371
+ <span class="icon"
372
+ >${unsafeHTML(this.getBadgeIcon(badge.icon))}</span
373
+ >
374
+ </div>
375
+ `,
376
+ )}
377
+ ${remaining > 0
378
+ ? html`<span class="remaining">+${remaining}</span>`
379
+ : ''}
380
+ </div>
381
+ `;
382
+ }
383
+ }
384
+
385
+ @customElement('stat-card')
386
+ export class StatCard extends LitElement {
387
+ static styles = [
388
+ sharedStyles,
389
+ css`
390
+ .card {
391
+ display: flex;
392
+ flex-direction: column;
393
+ align-items: center;
394
+ justify-content: center;
395
+ padding: 1rem;
396
+ border-radius: 0.75rem;
397
+ background: var(--card);
398
+ border: 1px solid var(--border);
399
+ }
400
+ .card.highlight {
401
+ border-color: var(--primary);
402
+ box-shadow: 0 0 20px oklch(0.7 0.18 145 / 0.4);
403
+ }
404
+ .icon {
405
+ display: flex;
406
+ align-items: center;
407
+ margin-bottom: 0.5rem;
408
+ color: var(--muted-foreground);
409
+ }
410
+ .value {
411
+ font-size: 1.5rem;
412
+ font-weight: 700;
413
+ color: var(--foreground);
414
+ }
415
+ .label {
416
+ font-size: 0.75rem;
417
+ color: var(--muted-foreground);
418
+ }
419
+ `,
420
+ ];
421
+
422
+ @property({ type: String }) label = '';
423
+ @property({ type: String }) value = '';
424
+ @property({ type: String }) icon = '';
425
+ @property({ type: Boolean }) highlight = false;
426
+
427
+ render() {
428
+ return html`
429
+ <div class="card ${this.highlight ? 'highlight' : ''}">
430
+ ${this.icon
431
+ ? html`<span class="icon"
432
+ >${unsafeHTML(getIcon(this.icon as any, 20))}</span
433
+ >`
434
+ : ''}
435
+ <span class="value">${this.value}</span>
436
+ <span class="label">${this.label}</span>
437
+ </div>
438
+ `;
439
+ }
440
+ }
441
+
442
+ declare global {
443
+ interface HTMLElementTagNameMap {
444
+ 'rank-badge': RankBadge;
445
+ 'xp-progress': XPProgress;
446
+ 'trend-indicator': TrendIndicator;
447
+ 'streak-badge': StreakBadge;
448
+ 'level-badge': LevelBadge;
449
+ 'badge-display': BadgeDisplay;
450
+ 'stat-card': StatCard;
451
+ }
452
+ }
@@ -0,0 +1,152 @@
1
+ import { Player, Badge, LeaderboardStats } from './types';
2
+
3
+ export const badges: Badge[] = [
4
+ { id: '1', name: 'First Win', icon: 'trophy', rarity: 'common' },
5
+ { id: '2', name: 'Streak Master', icon: 'flame', rarity: 'rare' },
6
+ { id: '3', name: 'Top 10', icon: 'star', rarity: 'epic' },
7
+ { id: '4', name: 'Legend', icon: 'crown', rarity: 'legendary' },
8
+ { id: '5', name: 'Speed Demon', icon: 'zap', rarity: 'rare' },
9
+ { id: '6', name: 'Perfectionist', icon: 'gem', rarity: 'epic' },
10
+ ];
11
+
12
+ export const players: Player[] = [
13
+ {
14
+ id: '1',
15
+ rank: 1,
16
+ username: 'ShadowNinja',
17
+ avatar: 'https://api.dicebear.com/7.x/avataaars/svg?seed=shadow',
18
+ level: 99,
19
+ xp: 45000,
20
+ xpToNextLevel: 50000,
21
+ score: 2847500,
22
+ wins: 342,
23
+ streak: 15,
24
+ badges: [badges[3], badges[2], badges[5]],
25
+ trend: 'same',
26
+ },
27
+ {
28
+ id: '2',
29
+ rank: 2,
30
+ username: 'CyberPhoenix',
31
+ avatar: 'https://api.dicebear.com/7.x/avataaars/svg?seed=phoenix',
32
+ level: 95,
33
+ xp: 38000,
34
+ xpToNextLevel: 45000,
35
+ score: 2654200,
36
+ wins: 298,
37
+ streak: 8,
38
+ badges: [badges[2], badges[1], badges[4]],
39
+ trend: 'up',
40
+ rankChange: 2,
41
+ },
42
+ {
43
+ id: '3',
44
+ rank: 3,
45
+ username: 'NeonBlade',
46
+ avatar: 'https://api.dicebear.com/7.x/avataaars/svg?seed=blade',
47
+ level: 92,
48
+ xp: 41000,
49
+ xpToNextLevel: 44000,
50
+ score: 2501800,
51
+ wins: 276,
52
+ streak: 5,
53
+ badges: [badges[2], badges[0], badges[1]],
54
+ trend: 'down',
55
+ rankChange: 1,
56
+ },
57
+ {
58
+ id: '4',
59
+ rank: 4,
60
+ username: 'StormWatcher',
61
+ avatar: 'https://api.dicebear.com/7.x/avataaars/svg?seed=storm',
62
+ level: 88,
63
+ xp: 22000,
64
+ xpToNextLevel: 42000,
65
+ score: 2234500,
66
+ wins: 245,
67
+ streak: 12,
68
+ badges: [badges[1], badges[4]],
69
+ trend: 'up',
70
+ rankChange: 3,
71
+ },
72
+ {
73
+ id: '5',
74
+ rank: 5,
75
+ username: 'VoidRunner',
76
+ avatar: 'https://api.dicebear.com/7.x/avataaars/svg?seed=void',
77
+ level: 85,
78
+ xp: 35000,
79
+ xpToNextLevel: 40000,
80
+ score: 2087300,
81
+ wins: 218,
82
+ streak: 3,
83
+ badges: [badges[0], badges[5]],
84
+ trend: 'same',
85
+ },
86
+ {
87
+ id: '6',
88
+ rank: 6,
89
+ username: 'PixelHunter',
90
+ avatar: 'https://api.dicebear.com/7.x/avataaars/svg?seed=pixel',
91
+ level: 82,
92
+ xp: 18000,
93
+ xpToNextLevel: 38000,
94
+ score: 1956700,
95
+ wins: 195,
96
+ streak: 7,
97
+ badges: [badges[1], badges[0]],
98
+ trend: 'up',
99
+ rankChange: 1,
100
+ },
101
+ {
102
+ id: '7',
103
+ rank: 7,
104
+ username: 'GhostCoder',
105
+ avatar: 'https://api.dicebear.com/7.x/avataaars/svg?seed=ghost',
106
+ level: 79,
107
+ xp: 28000,
108
+ xpToNextLevel: 36000,
109
+ score: 1823400,
110
+ wins: 178,
111
+ streak: 2,
112
+ badges: [badges[4], badges[0]],
113
+ trend: 'down',
114
+ rankChange: 2,
115
+ },
116
+ {
117
+ id: '8',
118
+ rank: 8,
119
+ username: 'ThunderFist',
120
+ avatar: 'https://api.dicebear.com/7.x/avataaars/svg?seed=thunder',
121
+ level: 76,
122
+ xp: 12000,
123
+ xpToNextLevel: 34000,
124
+ score: 1678900,
125
+ wins: 156,
126
+ streak: 4,
127
+ badges: [badges[0]],
128
+ trend: 'same',
129
+ },
130
+ ];
131
+
132
+ export const stats: LeaderboardStats = {
133
+ totalPlayers: 12847,
134
+ yourRank: 156,
135
+ topScore: 2847500,
136
+ };
137
+
138
+ export const currentUser: Player = {
139
+ id: 'current',
140
+ rank: 156,
141
+ username: 'YourPlayer',
142
+ avatar: 'https://api.dicebear.com/7.x/avataaars/svg?seed=current',
143
+ level: 45,
144
+ xp: 12500,
145
+ xpToNextLevel: 20000,
146
+ score: 456780,
147
+ wins: 42,
148
+ streak: 3,
149
+ badges: [badges[0], badges[1]],
150
+ trend: 'up',
151
+ rankChange: 12,
152
+ };
@@ -0,0 +1,2 @@
1
+ export { LeaderboardApp } from './main.js';
2
+ import './main.js';
@@ -0,0 +1,42 @@
1
+ import { LitElement, html } from 'lit';
2
+ import { customElement } from 'lit/decorators.js';
3
+ import { players, stats, currentUser } from './data';
4
+ import './components/leaderboard';
5
+ import { sharedStyles } from './styles';
6
+ import { css } from 'lit';
7
+
8
+ @customElement('leaderboard-app')
9
+ export class LeaderboardApp extends LitElement {
10
+ static styles = [
11
+ sharedStyles,
12
+ css`
13
+ :host {
14
+ display: block;
15
+ min-height: 100vh;
16
+ background: var(--background);
17
+ padding: 2rem 1rem;
18
+ }
19
+ @media (min-width: 768px) {
20
+ :host {
21
+ padding: 3rem 2rem;
22
+ }
23
+ }
24
+ `,
25
+ ];
26
+
27
+ render() {
28
+ return html`
29
+ <game-leaderboard
30
+ .players=${players}
31
+ .currentUser=${currentUser}
32
+ .stats=${stats}
33
+ ></game-leaderboard>
34
+ `;
35
+ }
36
+ }
37
+
38
+ declare global {
39
+ interface HTMLElementTagNameMap {
40
+ 'leaderboard-app': LeaderboardApp;
41
+ }
42
+ }