@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.
- package/.eleventy.cjs +14 -0
- package/LICENSE +28 -0
- package/README.md +118 -0
- package/custom-elements.json +1539 -0
- package/docs/_README/index.html +4 -0
- package/docs/api/index.html +2100 -0
- package/docs/components.bundle.js +1669 -0
- package/docs/components.bundle.js.map +1 -0
- package/docs/docs.css +162 -0
- package/docs/examples/index.html +56 -0
- package/docs/index.html +53 -0
- package/docs/install/index.html +45 -0
- package/docs/prism-okaidia.css +123 -0
- package/docs-src/.nojekyll +0 -0
- package/docs-src/_README.md +7 -0
- package/docs-src/_data/api.11tydata.js +8 -0
- package/docs-src/_includes/example.11ty.js +35 -0
- package/docs-src/_includes/footer.11ty.js +6 -0
- package/docs-src/_includes/header.11ty.js +7 -0
- package/docs-src/_includes/nav.11ty.js +11 -0
- package/docs-src/_includes/page.11ty.js +32 -0
- package/docs-src/_includes/relative-path.cjs +9 -0
- package/docs-src/api.11ty.js +85 -0
- package/docs-src/bundle.ts +9 -0
- package/docs-src/docs.css +162 -0
- package/docs-src/examples/index.md +15 -0
- package/docs-src/index.md +39 -0
- package/docs-src/install.md +28 -0
- package/docs-src/package.json +3 -0
- package/index.html +19 -0
- package/karma.conf.cjs +24 -0
- package/main.css +210 -0
- package/main.ts +124 -0
- package/package.json +86 -0
- package/previews/casino.ts +12 -0
- package/previews/catalog.ts +94 -0
- package/previews/leaderboard-v1.ts +12 -0
- package/previews/leaderboard-v2.ts +17 -0
- package/previews/sample-data.ts +101 -0
- package/previews/sf-leaderboard.ts +100 -0
- package/previews/sf-live-feed.ts +15 -0
- package/previews/streaks.ts +40 -0
- package/previews/types.ts +18 -0
- package/src/components/README.md +16 -0
- package/src/components/casino-leaderboard/casino-leaderboard.html +80 -0
- package/src/components/casino-leaderboard/casino-leaderboard.scss +585 -0
- package/src/components/casino-leaderboard/casino-leaderboard.ts +136 -0
- package/src/components/casino-leaderboard/data.ts +111 -0
- package/src/components/casino-leaderboard/index.ts +5 -0
- package/src/components/casino-leaderboard/todo.txt +2 -0
- package/src/components/casino-leaderboard/types.ts +19 -0
- package/src/components/leaderboard/components/leaderboard.ts +373 -0
- package/src/components/leaderboard/components/player-card.ts +342 -0
- package/src/components/leaderboard/components/ui.ts +452 -0
- package/src/components/leaderboard/data.ts +152 -0
- package/src/components/leaderboard/index.ts +2 -0
- package/src/components/leaderboard/main.ts +42 -0
- package/src/components/leaderboard/styles.ts +67 -0
- package/src/components/leaderboard/types.ts +28 -0
- package/src/components/leaderboard-v2/components/sf-leaderboard-player.ts +451 -0
- package/src/components/leaderboard-v2/components/sf-leaderboard-ui.ts +512 -0
- package/src/components/leaderboard-v2/components/sf-leaderboard.ts +205 -0
- package/src/components/leaderboard-v2/constants.ts +16 -0
- package/src/components/leaderboard-v2/demo/sample-data.ts +152 -0
- package/src/components/leaderboard-v2/events.ts +13 -0
- package/src/components/leaderboard-v2/icons.ts +22 -0
- package/src/components/leaderboard-v2/index.ts +23 -0
- package/src/components/leaderboard-v2/sf-leaderboard.html +1 -0
- package/src/components/leaderboard-v2/sf-leaderboard.scss +382 -0
- package/src/components/leaderboard-v2/tokens.ts +35 -0
- package/src/components/leaderboard-v2/types.ts +30 -0
- package/src/components/sf-leaderboard/index.ts +77 -0
- package/src/components/sf-leaderboard/sections/footer-section/footer-section.host.ts +3 -0
- package/src/components/sf-leaderboard/sections/footer-section/footer-section.html +3 -0
- package/src/components/sf-leaderboard/sections/footer-section/footer-section.scss +18 -0
- package/src/components/sf-leaderboard/sections/footer-section/footer-section.ts +22 -0
- package/src/components/sf-leaderboard/sections/header-section/header-section.host.ts +14 -0
- package/src/components/sf-leaderboard/sections/header-section/header-section.html +27 -0
- package/src/components/sf-leaderboard/sections/header-section/header-section.scss +189 -0
- package/src/components/sf-leaderboard/sections/header-section/header-section.ts +70 -0
- package/src/components/sf-leaderboard/sections/ranking-section/ranking-section.host.ts +22 -0
- package/src/components/sf-leaderboard/sections/ranking-section/ranking-section.html +38 -0
- package/src/components/sf-leaderboard/sections/ranking-section/ranking-section.scss +99 -0
- package/src/components/sf-leaderboard/sections/ranking-section/ranking-section.ts +121 -0
- package/src/components/sf-leaderboard/sections/stats-section/stats-section.host.ts +8 -0
- package/src/components/sf-leaderboard/sections/stats-section/stats-section.html +6 -0
- package/src/components/sf-leaderboard/sections/stats-section/stats-section.scss +44 -0
- package/src/components/sf-leaderboard/sections/stats-section/stats-section.ts +41 -0
- package/src/components/sf-leaderboard/sections/table-section/table-section.host.ts +17 -0
- package/src/components/sf-leaderboard/sections/table-section/table-section.html +19 -0
- package/src/components/sf-leaderboard/sections/table-section/table-section.scss +37 -0
- package/src/components/sf-leaderboard/sections/table-section/table-section.ts +108 -0
- package/src/components/sf-leaderboard/services/index.ts +22 -0
- package/src/components/sf-leaderboard/services/sf-leaderboard-data.service.ts +54 -0
- package/src/components/sf-leaderboard/services/sf-leaderboard.state.ts +160 -0
- package/src/components/sf-leaderboard/shared/components/activity-feed/activity-feed.host.ts +7 -0
- package/src/components/sf-leaderboard/shared/components/activity-feed/activity-feed.html +10 -0
- package/src/components/sf-leaderboard/shared/components/activity-feed/activity-feed.scss +180 -0
- package/src/components/sf-leaderboard/shared/components/activity-feed/activity-feed.ts +88 -0
- package/src/components/sf-leaderboard/shared/components/filters/filters.host.ts +12 -0
- package/src/components/sf-leaderboard/shared/components/filters/filters.html +22 -0
- package/src/components/sf-leaderboard/shared/components/filters/filters.scss +122 -0
- package/src/components/sf-leaderboard/shared/components/filters/filters.ts +75 -0
- package/src/components/sf-leaderboard/shared/components/player-avatar/player-avatar.host.ts +9 -0
- package/src/components/sf-leaderboard/shared/components/player-avatar/player-avatar.html +5 -0
- package/src/components/sf-leaderboard/shared/components/player-avatar/player-avatar.scss +81 -0
- package/src/components/sf-leaderboard/shared/components/player-avatar/player-avatar.ts +34 -0
- package/src/components/sf-leaderboard/shared/components/podium/map-players.ts +24 -0
- package/src/components/sf-leaderboard/shared/components/podium/podium.host.ts +10 -0
- package/src/components/sf-leaderboard/shared/components/podium/podium.html +53 -0
- package/src/components/sf-leaderboard/shared/components/podium/podium.scss +580 -0
- package/src/components/sf-leaderboard/shared/components/podium/podium.ts +49 -0
- package/src/components/sf-leaderboard/shared/components/podium/podium.types.ts +9 -0
- package/src/components/sf-leaderboard/shared/components/rank-badge/rank-badge.host.ts +11 -0
- package/src/components/sf-leaderboard/shared/components/rank-badge/rank-badge.html +9 -0
- package/src/components/sf-leaderboard/shared/components/rank-badge/rank-badge.scss +98 -0
- package/src/components/sf-leaderboard/shared/components/rank-badge/rank-badge.ts +63 -0
- package/src/components/sf-leaderboard/shared/components/stat-card/stat-card.host.ts +9 -0
- package/src/components/sf-leaderboard/shared/components/stat-card/stat-card.html +15 -0
- package/src/components/sf-leaderboard/shared/components/stat-card/stat-card.scss +210 -0
- package/src/components/sf-leaderboard/shared/components/stat-card/stat-card.ts +36 -0
- package/src/components/sf-leaderboard/shared/components/table/table.host.ts +5 -0
- package/src/components/sf-leaderboard/shared/components/table/table.html +11 -0
- package/src/components/sf-leaderboard/shared/components/table/table.scss +212 -0
- package/src/components/sf-leaderboard/shared/components/table/table.ts +111 -0
- package/src/components/sf-leaderboard/shared/constants/defaults.ts +7 -0
- package/src/components/sf-leaderboard/shared/constants/filters.ts +16 -0
- package/src/components/sf-leaderboard/shared/constants/index.ts +5 -0
- package/src/components/sf-leaderboard/shared/constants/player-stats.ts +3 -0
- package/src/components/sf-leaderboard/shared/constants/stats-overview.ts +38 -0
- package/src/components/sf-leaderboard/shared/constants/tags.ts +16 -0
- package/src/components/sf-leaderboard/shared/styles/_section.scss +35 -0
- package/src/components/sf-leaderboard/shared/types/data.ts +29 -0
- package/src/components/sf-leaderboard/shared/types/events.ts +30 -0
- package/src/components/sf-leaderboard/shared/types/player-stats.ts +3 -0
- package/src/components/sf-leaderboard/shared/types/sections.ts +100 -0
- package/src/components/sf-leaderboard/shared/utils/utils.ts +17 -0
- package/src/components/sf-leaderboard/theme/THEMING.md +54 -0
- package/src/components/sf-leaderboard/theme/context.ts +16 -0
- package/src/components/sf-leaderboard/theme/default-theme.ts +4 -0
- package/src/components/sf-leaderboard/theme/hex-to-rgb.ts +25 -0
- package/src/components/sf-leaderboard/theme/index.ts +18 -0
- package/src/components/sf-leaderboard/theme/inject-theme.ts +39 -0
- package/src/components/sf-leaderboard/theme/load-theme.ts +26 -0
- package/src/components/sf-leaderboard/theme/merge-theme.ts +59 -0
- package/src/components/sf-leaderboard/theme/scss/_colors.scss +101 -0
- package/src/components/sf-leaderboard/theme/scss/shared.scss +123 -0
- package/src/components/sf-leaderboard/theme/styles.ts +6 -0
- package/src/components/sf-leaderboard/theme/theme-to-css-vars.ts +99 -0
- package/src/components/sf-leaderboard/theme/themes/fallback.json +62 -0
- package/src/components/sf-leaderboard/theme/themes/red.json +62 -0
- package/src/components/sf-leaderboard/theme/types.ts +71 -0
- package/src/components/sf-live-feed/components/avatar/avatar.host.ts +5 -0
- package/src/components/sf-live-feed/components/avatar/avatar.html +3 -0
- package/src/components/sf-live-feed/components/avatar/avatar.scss +24 -0
- package/src/components/sf-live-feed/components/avatar/avatar.ts +27 -0
- package/src/components/sf-live-feed/components/sf-live-feed/sf-live-feed.host.ts +8 -0
- package/src/components/sf-live-feed/components/sf-live-feed/sf-live-feed.html +10 -0
- package/src/components/sf-live-feed/components/sf-live-feed/sf-live-feed.scss +177 -0
- package/src/components/sf-live-feed/components/sf-live-feed/sf-live-feed.ts +65 -0
- package/src/components/sf-live-feed/constants.ts +4 -0
- package/src/components/sf-live-feed/demo/sample-data.ts +34 -0
- package/src/components/sf-live-feed/index.ts +19 -0
- package/src/components/sf-live-feed/styles/theme.scss +19 -0
- package/src/components/sf-live-feed/styles/theme.ts +5 -0
- package/src/components/sf-live-feed/types.ts +19 -0
- package/src/components/sf-live-feed/utils.ts +17 -0
- package/src/components/streaks/constants.ts +17 -0
- package/src/components/streaks/demo/sample-steps.ts +10 -0
- package/src/components/streaks/events.ts +8 -0
- package/src/components/streaks/index.ts +16 -0
- package/src/components/streaks/sf-streaks.html +26 -0
- package/src/components/streaks/sf-streaks.scss +351 -0
- package/src/components/streaks/sf-streaks.ts +235 -0
- package/src/components/streaks/types.ts +7 -0
- package/src/lib/lit/component.ts +10 -0
- package/src/lib/lit/safe-custom-element.ts +12 -0
- package/src/lib/lit/scss.ts +6 -0
- package/src/vite-env.d.ts +18 -0
- package/styles/global.css +125 -0
- package/todo.txt +54 -0
- package/tsconfig.json +31 -0
- package/vite.config.ts +56 -0
- package/vite.docs.config.ts +33 -0
- package/vite.lit-html-plugin.ts +43 -0
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
:host {
|
|
2
|
+
display: block;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.feed-container {
|
|
6
|
+
border-radius: var(--surface-radius);
|
|
7
|
+
border: 1px solid var(--surface-border-color);
|
|
8
|
+
background: var(--surface-gradient);
|
|
9
|
+
box-shadow: var(--surface-shadow);
|
|
10
|
+
overflow: hidden;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
.feed-header {
|
|
14
|
+
display: flex;
|
|
15
|
+
align-items: center;
|
|
16
|
+
justify-content: space-between;
|
|
17
|
+
padding: 0.75rem 1rem;
|
|
18
|
+
border-bottom: 1px solid var(--border-subtle);
|
|
19
|
+
background: var(--muted);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.header-left {
|
|
23
|
+
display: flex;
|
|
24
|
+
align-items: center;
|
|
25
|
+
gap: 0.5rem;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.live-dot {
|
|
29
|
+
position: relative;
|
|
30
|
+
width: 8px;
|
|
31
|
+
height: 8px;
|
|
32
|
+
background: var(--success);
|
|
33
|
+
border-radius: 50%;
|
|
34
|
+
|
|
35
|
+
&::before {
|
|
36
|
+
content: '';
|
|
37
|
+
position: absolute;
|
|
38
|
+
inset: 0;
|
|
39
|
+
border-radius: 50%;
|
|
40
|
+
background: var(--success);
|
|
41
|
+
animation: ping 1.5s ease-out infinite;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
@keyframes ping {
|
|
46
|
+
0% {
|
|
47
|
+
transform: scale(1);
|
|
48
|
+
opacity: 1;
|
|
49
|
+
}
|
|
50
|
+
100% {
|
|
51
|
+
transform: scale(2.5);
|
|
52
|
+
opacity: 0;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.header-title {
|
|
57
|
+
font-size: 0.875rem;
|
|
58
|
+
font-weight: 600;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.event-count {
|
|
62
|
+
font-size: 0.65rem;
|
|
63
|
+
padding: 0.2rem 0.5rem;
|
|
64
|
+
border-radius: var(--radius-sm);
|
|
65
|
+
border: 1px solid var(--inset-border);
|
|
66
|
+
background: var(--inset-bg);
|
|
67
|
+
color: var(--muted-foreground);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
.feed-body {
|
|
71
|
+
max-height: 400px;
|
|
72
|
+
overflow-y: auto;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
.activity-item {
|
|
76
|
+
display: flex;
|
|
77
|
+
align-items: flex-start;
|
|
78
|
+
gap: 0.75rem;
|
|
79
|
+
padding: 0.75rem 1rem;
|
|
80
|
+
border-bottom: 1px solid var(--border-subtle);
|
|
81
|
+
transition: background var(--transition-fast);
|
|
82
|
+
animation: slide-in 0.3s ease-out forwards;
|
|
83
|
+
opacity: 0;
|
|
84
|
+
|
|
85
|
+
&:hover {
|
|
86
|
+
background: var(--inset-hover-bg);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
&:last-child {
|
|
90
|
+
border-bottom: none;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
@keyframes slide-in {
|
|
95
|
+
from {
|
|
96
|
+
opacity: 0;
|
|
97
|
+
transform: translateY(-5px);
|
|
98
|
+
}
|
|
99
|
+
to {
|
|
100
|
+
opacity: 1;
|
|
101
|
+
transform: translateY(0);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
.activity-content {
|
|
106
|
+
flex: 1;
|
|
107
|
+
min-width: 0;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
.activity-header {
|
|
111
|
+
display: flex;
|
|
112
|
+
align-items: center;
|
|
113
|
+
gap: 0.5rem;
|
|
114
|
+
flex-wrap: wrap;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
.player-name {
|
|
118
|
+
font-size: 0.875rem;
|
|
119
|
+
font-weight: 600;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
.activity-badge {
|
|
123
|
+
display: inline-flex;
|
|
124
|
+
align-items: center;
|
|
125
|
+
gap: 0.25rem;
|
|
126
|
+
font-size: 0.6rem;
|
|
127
|
+
padding: 0.15rem 0.4rem;
|
|
128
|
+
border-radius: var(--radius-sm);
|
|
129
|
+
border: 1px solid;
|
|
130
|
+
font-weight: 600;
|
|
131
|
+
text-transform: uppercase;
|
|
132
|
+
letter-spacing: 0.04em;
|
|
133
|
+
|
|
134
|
+
&.win {
|
|
135
|
+
background: var(--badge-success-bg);
|
|
136
|
+
border-color: var(--badge-success-border);
|
|
137
|
+
color: var(--success);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
&.jackpot {
|
|
141
|
+
background: var(--medal-gold-bg);
|
|
142
|
+
border-color: var(--medal-gold-border);
|
|
143
|
+
color: var(--gold);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
&.streak {
|
|
147
|
+
background: var(--badge-warning-bg);
|
|
148
|
+
border-color: var(--badge-warning-border);
|
|
149
|
+
color: var(--warning);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
&.achievement {
|
|
153
|
+
background: var(--badge-accent-bg);
|
|
154
|
+
border-color: var(--badge-accent-border);
|
|
155
|
+
color: var(--primary);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
.activity-message {
|
|
160
|
+
font-size: 0.875rem;
|
|
161
|
+
color: var(--muted-foreground);
|
|
162
|
+
margin-top: 0.25rem;
|
|
163
|
+
white-space: nowrap;
|
|
164
|
+
overflow: hidden;
|
|
165
|
+
text-overflow: ellipsis;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
.activity-amount {
|
|
169
|
+
font-family: var(--font-mono);
|
|
170
|
+
font-weight: 700;
|
|
171
|
+
color: var(--success);
|
|
172
|
+
font-size: 0.875rem;
|
|
173
|
+
margin-top: 0.25rem;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
.activity-time {
|
|
177
|
+
font-size: 0.65rem;
|
|
178
|
+
color: var(--muted-foreground);
|
|
179
|
+
white-space: nowrap;
|
|
180
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
import { property } from 'lit/decorators.js';
|
|
3
|
+
import { Component } from '../../../../../../lib/lit/component.js';
|
|
4
|
+
import { scss } from '../../../../../../lib/lit/scss.js';
|
|
5
|
+
import { SF_LEADERBOARD_ACTIVITY_FEED, SF_LEADERBOARD_PLAYER_AVATAR } from '../../constants/tags.js';
|
|
6
|
+
import { sfLeaderboardTheme } from '../../../theme/styles.js';
|
|
7
|
+
import type { Activity } from '../../types/data.js';
|
|
8
|
+
import { formatCurrency, formatTime } from '../../utils/utils.js';
|
|
9
|
+
import '../player-avatar/player-avatar.js';
|
|
10
|
+
import type { ActivityFeedHost } from './activity-feed.host.js';
|
|
11
|
+
import renderTemplate from './activity-feed.html?lit-html';
|
|
12
|
+
import styles from './activity-feed.scss?inline';
|
|
13
|
+
|
|
14
|
+
@Component({ selector: SF_LEADERBOARD_ACTIVITY_FEED })
|
|
15
|
+
export class SfLeaderboardActivityFeed extends LitElement
|
|
16
|
+
implements ActivityFeedHost {
|
|
17
|
+
static styles = [sfLeaderboardTheme, scss(styles)];
|
|
18
|
+
|
|
19
|
+
@property({ type: Array }) activities: Activity[] = [];
|
|
20
|
+
|
|
21
|
+
private getActivityBadge(type: Activity['type']) {
|
|
22
|
+
const badges: Record<
|
|
23
|
+
Activity['type'],
|
|
24
|
+
{ label: string; icon: string }
|
|
25
|
+
> = {
|
|
26
|
+
win: { label: 'WIN', icon: '💵' },
|
|
27
|
+
jackpot: { label: 'JACKPOT', icon: '⚡' },
|
|
28
|
+
streak: { label: 'STREAK', icon: '🔥' },
|
|
29
|
+
achievement: { label: 'ACHIEVEMENT', icon: '🏆' },
|
|
30
|
+
};
|
|
31
|
+
return badges[type];
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
private createActivityItem(activity: Activity, index: number): HTMLElement {
|
|
35
|
+
const badge = this.getActivityBadge(activity.type);
|
|
36
|
+
|
|
37
|
+
const item = document.createElement('div');
|
|
38
|
+
item.className = 'activity-item';
|
|
39
|
+
item.style.animationDelay = `${index * 100}ms`;
|
|
40
|
+
|
|
41
|
+
const avatar = document.createElement(SF_LEADERBOARD_PLAYER_AVATAR);
|
|
42
|
+
avatar.username = activity.player.username;
|
|
43
|
+
avatar.avatar = activity.player.avatar || '';
|
|
44
|
+
avatar.size = 'sm';
|
|
45
|
+
|
|
46
|
+
const content = document.createElement('div');
|
|
47
|
+
content.className = 'activity-content';
|
|
48
|
+
|
|
49
|
+
const header = document.createElement('div');
|
|
50
|
+
header.className = 'activity-header';
|
|
51
|
+
const playerName = document.createElement('span');
|
|
52
|
+
playerName.className = 'player-name';
|
|
53
|
+
playerName.textContent = activity.player.username;
|
|
54
|
+
const badgeEl = document.createElement('span');
|
|
55
|
+
badgeEl.className = `activity-badge ${activity.type}`;
|
|
56
|
+
badgeEl.textContent = `${badge.icon} ${badge.label}`;
|
|
57
|
+
header.append(playerName, badgeEl);
|
|
58
|
+
|
|
59
|
+
const message = document.createElement('p');
|
|
60
|
+
message.className = 'activity-message';
|
|
61
|
+
message.textContent = activity.message;
|
|
62
|
+
content.append(header, message);
|
|
63
|
+
|
|
64
|
+
if (activity.amount) {
|
|
65
|
+
const amount = document.createElement('p');
|
|
66
|
+
amount.className = 'activity-amount';
|
|
67
|
+
amount.textContent = `+${formatCurrency(activity.amount)}`;
|
|
68
|
+
content.append(amount);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const time = document.createElement('span');
|
|
72
|
+
time.className = 'activity-time';
|
|
73
|
+
time.textContent = formatTime(activity.timestamp);
|
|
74
|
+
|
|
75
|
+
item.append(avatar, content, time);
|
|
76
|
+
return item;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
renderActivities() {
|
|
80
|
+
return this.activities.map((activity, index) =>
|
|
81
|
+
this.createActivityItem(activity, index),
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
render() {
|
|
86
|
+
return renderTemplate(this);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { TemplateResult } from 'lit';
|
|
2
|
+
import type { Category, TimeFrame } from '../../types/data.js';
|
|
3
|
+
|
|
4
|
+
export interface FiltersHost {
|
|
5
|
+
activeTimeframe: TimeFrame;
|
|
6
|
+
activeCategory: Category;
|
|
7
|
+
searchQuery: string;
|
|
8
|
+
renderTimeframeTabs(): TemplateResult;
|
|
9
|
+
renderCategoryOptions(): TemplateResult;
|
|
10
|
+
handleSearchInput(e: Event): void;
|
|
11
|
+
handleCategoryChange(e: Event): void;
|
|
12
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
<div class="filters">
|
|
2
|
+
<div class="search-wrapper">
|
|
3
|
+
<span class="search-icon">🔍</span>
|
|
4
|
+
<input
|
|
5
|
+
type="text"
|
|
6
|
+
class="search-input"
|
|
7
|
+
placeholder="Search players..."
|
|
8
|
+
.value="${host.searchQuery}"
|
|
9
|
+
@input="${host.handleSearchInput}"
|
|
10
|
+
/>
|
|
11
|
+
</div>
|
|
12
|
+
|
|
13
|
+
<div class="timeframe-tabs">${host.renderTimeframeTabs()}</div>
|
|
14
|
+
|
|
15
|
+
<select
|
|
16
|
+
class="category-select"
|
|
17
|
+
.value="${host.activeCategory}"
|
|
18
|
+
@change="${host.handleCategoryChange}"
|
|
19
|
+
>
|
|
20
|
+
${host.renderCategoryOptions()}
|
|
21
|
+
</select>
|
|
22
|
+
</div>
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
:host {
|
|
2
|
+
display: block;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.filters {
|
|
6
|
+
display: flex;
|
|
7
|
+
flex-direction: column;
|
|
8
|
+
gap: 0.75rem;
|
|
9
|
+
width: 100%;
|
|
10
|
+
min-width: 0;
|
|
11
|
+
|
|
12
|
+
@media (min-width: 640px) {
|
|
13
|
+
flex-direction: row;
|
|
14
|
+
flex-wrap: wrap;
|
|
15
|
+
align-items: center;
|
|
16
|
+
gap: 1rem;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.search-wrapper {
|
|
21
|
+
position: relative;
|
|
22
|
+
flex: 1;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.search-icon {
|
|
26
|
+
position: absolute;
|
|
27
|
+
left: 12px;
|
|
28
|
+
top: 50%;
|
|
29
|
+
transform: translateY(-50%);
|
|
30
|
+
color: var(--muted-foreground);
|
|
31
|
+
font-size: 0.875rem;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.search-input {
|
|
35
|
+
width: 100%;
|
|
36
|
+
padding: 0.625rem 1rem 0.625rem 2.5rem;
|
|
37
|
+
border-radius: var(--radius-sm);
|
|
38
|
+
border: 1px solid var(--surface-border-color);
|
|
39
|
+
background: var(--inset-bg);
|
|
40
|
+
color: var(--foreground);
|
|
41
|
+
font-size: 0.875rem;
|
|
42
|
+
font-family: inherit;
|
|
43
|
+
outline: none;
|
|
44
|
+
transition: border-color 0.2s ease;
|
|
45
|
+
|
|
46
|
+
&::placeholder {
|
|
47
|
+
color: var(--muted-foreground);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
&:focus {
|
|
51
|
+
border-color: var(--primary);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.timeframe-tabs {
|
|
56
|
+
display: flex;
|
|
57
|
+
align-items: center;
|
|
58
|
+
gap: 4px;
|
|
59
|
+
padding: 4px;
|
|
60
|
+
background: var(--inset-bg);
|
|
61
|
+
border: 1px solid var(--inset-border);
|
|
62
|
+
border-radius: var(--radius-sm);
|
|
63
|
+
width: 100%;
|
|
64
|
+
overflow-x: auto;
|
|
65
|
+
-webkit-overflow-scrolling: touch;
|
|
66
|
+
flex-wrap: nowrap;
|
|
67
|
+
|
|
68
|
+
@media (min-width: 640px) {
|
|
69
|
+
width: auto;
|
|
70
|
+
overflow-x: visible;
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.tab-btn {
|
|
75
|
+
padding: 0.375rem 0.75rem;
|
|
76
|
+
border: none;
|
|
77
|
+
border-radius: var(--radius-sm);
|
|
78
|
+
background: transparent;
|
|
79
|
+
color: var(--muted-foreground);
|
|
80
|
+
font-size: 0.75rem;
|
|
81
|
+
font-weight: 500;
|
|
82
|
+
font-family: inherit;
|
|
83
|
+
cursor: pointer;
|
|
84
|
+
transition: all 0.2s ease;
|
|
85
|
+
|
|
86
|
+
&:hover {
|
|
87
|
+
color: var(--foreground);
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
&.active {
|
|
91
|
+
background: var(--accent-gradient);
|
|
92
|
+
color: var(--primary-foreground);
|
|
93
|
+
box-shadow: var(--surface-shadow);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
.category-select {
|
|
98
|
+
display: flex;
|
|
99
|
+
align-items: center;
|
|
100
|
+
gap: 0.5rem;
|
|
101
|
+
padding: 0.5rem 1rem;
|
|
102
|
+
border-radius: var(--radius-sm);
|
|
103
|
+
border: 1px solid var(--surface-border-color);
|
|
104
|
+
background: var(--surface-gradient);
|
|
105
|
+
color: var(--foreground);
|
|
106
|
+
font-size: 0.875rem;
|
|
107
|
+
font-family: inherit;
|
|
108
|
+
cursor: pointer;
|
|
109
|
+
outline: none;
|
|
110
|
+
width: 100%;
|
|
111
|
+
min-width: 0;
|
|
112
|
+
max-width: 100%;
|
|
113
|
+
|
|
114
|
+
@media (min-width: 640px) {
|
|
115
|
+
width: auto;
|
|
116
|
+
min-width: 140px;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
&:focus {
|
|
120
|
+
border-color: var(--primary);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
import { property } from 'lit/decorators.js';
|
|
3
|
+
import { Component } from '../../../../../../lib/lit/component.js';
|
|
4
|
+
import { scss } from '../../../../../../lib/lit/scss.js';
|
|
5
|
+
import {
|
|
6
|
+
CATEGORY_OPTIONS,
|
|
7
|
+
DEFAULT_CATEGORY,
|
|
8
|
+
DEFAULT_TIMEFRAME,
|
|
9
|
+
SF_LEADERBOARD_FILTERS,
|
|
10
|
+
TIMEFRAME_OPTIONS,
|
|
11
|
+
} from '../../constants/index.js';
|
|
12
|
+
import {
|
|
13
|
+
SF_LEADERBOARD_CATEGORY_CHANGE,
|
|
14
|
+
SF_LEADERBOARD_SEARCH_CHANGE,
|
|
15
|
+
SF_LEADERBOARD_TIMEFRAME_CHANGE,
|
|
16
|
+
} from '../../types/events.js';
|
|
17
|
+
import { sfLeaderboardTheme } from '../../../theme/styles.js';
|
|
18
|
+
import type { Category, TimeFrame } from '../../types/data.js';
|
|
19
|
+
import type { FiltersHost } from './filters.host.js';
|
|
20
|
+
import renderTemplate from './filters.html?lit-html';
|
|
21
|
+
import styles from './filters.scss?inline';
|
|
22
|
+
|
|
23
|
+
@Component({ selector: SF_LEADERBOARD_FILTERS })
|
|
24
|
+
export class SfLeaderboardFilters extends LitElement implements FiltersHost {
|
|
25
|
+
static styles = [sfLeaderboardTheme, scss(styles)];
|
|
26
|
+
|
|
27
|
+
@property({ type: String }) activeTimeframe: TimeFrame = DEFAULT_TIMEFRAME;
|
|
28
|
+
@property({ type: String }) activeCategory: Category = DEFAULT_CATEGORY;
|
|
29
|
+
@property({ type: String }) searchQuery = '';
|
|
30
|
+
|
|
31
|
+
private emit<T>(name: string, detail: T) {
|
|
32
|
+
this.dispatchEvent(
|
|
33
|
+
new CustomEvent(name, { detail, bubbles: true, composed: true }),
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
handleSearchInput(e: Event) {
|
|
38
|
+
const input = e.target as HTMLInputElement;
|
|
39
|
+
this.emit(SF_LEADERBOARD_SEARCH_CHANGE, input.value);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
handleTimeframeClick(value: TimeFrame) {
|
|
43
|
+
this.emit(SF_LEADERBOARD_TIMEFRAME_CHANGE, value);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
handleCategoryChange(e: Event) {
|
|
47
|
+
const select = e.target as HTMLSelectElement;
|
|
48
|
+
this.emit(SF_LEADERBOARD_CATEGORY_CHANGE, select.value as Category);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
renderTimeframeTabs() {
|
|
52
|
+
return TIMEFRAME_OPTIONS.map((tf) => {
|
|
53
|
+
const btn = document.createElement('button');
|
|
54
|
+
btn.className = `tab-btn ${this.activeTimeframe === tf.value ? 'active' : ''}`;
|
|
55
|
+
btn.textContent = tf.label;
|
|
56
|
+
btn.addEventListener('click', () =>
|
|
57
|
+
this.handleTimeframeClick(tf.value as TimeFrame),
|
|
58
|
+
);
|
|
59
|
+
return btn;
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
renderCategoryOptions() {
|
|
64
|
+
return CATEGORY_OPTIONS.map((cat) => {
|
|
65
|
+
const option = document.createElement('option');
|
|
66
|
+
option.value = cat.value;
|
|
67
|
+
option.textContent = cat.label;
|
|
68
|
+
return option;
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
render() {
|
|
73
|
+
return renderTemplate(this);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
<div class="avatar ${host.size} ${host.highlight ? 'highlight' : ''}">
|
|
2
|
+
<img ?hidden="${!host.hasAvatar}" src="${host.avatar}" alt="${host.username}" />
|
|
3
|
+
<span ?hidden="${host.hasAvatar}">${host.initials}</span>
|
|
4
|
+
</div>
|
|
5
|
+
<span class="online-indicator" ?hidden="${!host.isOnline}"></span>
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
:host {
|
|
2
|
+
display: inline-block;
|
|
3
|
+
position: relative;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.avatar {
|
|
7
|
+
display: flex;
|
|
8
|
+
align-items: center;
|
|
9
|
+
justify-content: center;
|
|
10
|
+
border-radius: 50%;
|
|
11
|
+
border: 2px solid var(--border);
|
|
12
|
+
background: var(--secondary);
|
|
13
|
+
color: var(--foreground);
|
|
14
|
+
font-weight: 700;
|
|
15
|
+
overflow: hidden;
|
|
16
|
+
|
|
17
|
+
&.sm {
|
|
18
|
+
width: 32px;
|
|
19
|
+
height: 32px;
|
|
20
|
+
font-size: 0.7rem;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
&.md {
|
|
24
|
+
width: 48px;
|
|
25
|
+
height: 48px;
|
|
26
|
+
font-size: 0.875rem;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
&.lg {
|
|
30
|
+
width: 64px;
|
|
31
|
+
height: 64px;
|
|
32
|
+
font-size: 1.25rem;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
&.xl {
|
|
36
|
+
width: 80px;
|
|
37
|
+
height: 80px;
|
|
38
|
+
font-size: 1.5rem;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
&.highlight {
|
|
42
|
+
border-color: var(--primary);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
img {
|
|
46
|
+
width: 100%;
|
|
47
|
+
height: 100%;
|
|
48
|
+
object-fit: cover;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
.online-indicator {
|
|
53
|
+
position: absolute;
|
|
54
|
+
bottom: -2px;
|
|
55
|
+
right: -2px;
|
|
56
|
+
width: 12px;
|
|
57
|
+
height: 12px;
|
|
58
|
+
background: var(--success);
|
|
59
|
+
border-radius: 50%;
|
|
60
|
+
border: 2px solid var(--surface-border-color);
|
|
61
|
+
|
|
62
|
+
&::before {
|
|
63
|
+
content: '';
|
|
64
|
+
position: absolute;
|
|
65
|
+
inset: 0;
|
|
66
|
+
border-radius: 50%;
|
|
67
|
+
background: var(--success);
|
|
68
|
+
animation: pulse-ring 1.5s ease-out infinite;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
@keyframes pulse-ring {
|
|
73
|
+
0% {
|
|
74
|
+
transform: scale(0.8);
|
|
75
|
+
opacity: 1;
|
|
76
|
+
}
|
|
77
|
+
100% {
|
|
78
|
+
transform: scale(2);
|
|
79
|
+
opacity: 0;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { LitElement } from 'lit';
|
|
2
|
+
import { property } from 'lit/decorators.js';
|
|
3
|
+
import { Component } from '../../../../../../lib/lit/component.js';
|
|
4
|
+
import { scss } from '../../../../../../lib/lit/scss.js';
|
|
5
|
+
import { SF_LEADERBOARD_PLAYER_AVATAR } from '../../constants/tags.js';
|
|
6
|
+
import { sfLeaderboardTheme } from '../../../theme/styles.js';
|
|
7
|
+
import { getInitials } from '../../utils/utils.js';
|
|
8
|
+
import type { PlayerAvatarHost } from './player-avatar.host.js';
|
|
9
|
+
import renderTemplate from './player-avatar.html?lit-html';
|
|
10
|
+
import styles from './player-avatar.scss?inline';
|
|
11
|
+
|
|
12
|
+
@Component({ selector: SF_LEADERBOARD_PLAYER_AVATAR })
|
|
13
|
+
export class SfLeaderboardPlayerAvatar extends LitElement
|
|
14
|
+
implements PlayerAvatarHost {
|
|
15
|
+
static styles = [sfLeaderboardTheme, scss(styles)];
|
|
16
|
+
|
|
17
|
+
@property({ type: String }) username = '';
|
|
18
|
+
@property({ type: String }) avatar = '';
|
|
19
|
+
@property({ type: String }) size: 'sm' | 'md' | 'lg' | 'xl' = 'md';
|
|
20
|
+
@property({ type: Boolean }) isOnline = false;
|
|
21
|
+
@property({ type: Boolean }) highlight = false;
|
|
22
|
+
|
|
23
|
+
get hasAvatar(): boolean {
|
|
24
|
+
return Boolean(this.avatar);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
get initials(): string {
|
|
28
|
+
return getInitials(this.username);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
render() {
|
|
32
|
+
return renderTemplate(this);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Player } from '../../types/data.js';
|
|
2
|
+
import { formatCurrency, getInitials } from '../../utils/utils.js';
|
|
3
|
+
import type { PodiumEntry } from './podium.types.js';
|
|
4
|
+
|
|
5
|
+
function badgeFor(player: Player): string {
|
|
6
|
+
if (player.streak >= 5) return '🔥';
|
|
7
|
+
if (player.rank === 1) return '👑';
|
|
8
|
+
return '✌️';
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function mapPlayerToPodiumEntry(player: Player): PodiumEntry {
|
|
12
|
+
return {
|
|
13
|
+
rank: player.rank,
|
|
14
|
+
initials: getInitials(player.username),
|
|
15
|
+
username: player.username,
|
|
16
|
+
earnings: formatCurrency(player.totalWinnings),
|
|
17
|
+
winRate: `${player.winRate}% WR`,
|
|
18
|
+
badgeEmoji: badgeFor(player),
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export function mapPlayersToPodiumEntries(players: Player[]): PodiumEntry[] {
|
|
23
|
+
return players.map(mapPlayerToPodiumEntry);
|
|
24
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { PodiumEntry } from './podium.types.js';
|
|
2
|
+
|
|
3
|
+
/** Host API required by `podium.html`. */
|
|
4
|
+
export interface PodiumHost {
|
|
5
|
+
/** Set when `hasPodium` is true (template only renders then). */
|
|
6
|
+
readonly first: PodiumEntry;
|
|
7
|
+
readonly second: PodiumEntry;
|
|
8
|
+
readonly third: PodiumEntry;
|
|
9
|
+
readonly hasPodium: boolean;
|
|
10
|
+
}
|