feat: add LoL Stats plugin — op.gg-powered player lookup
New plugin for League of Legends stats tracking, similar to op.gg: - Search summoners by Riot ID (Name#Tag) + region - Profile overview: rank, tier, LP, win rate, ladder position - Top champions with KDA and win rates - Match history with KDA, CS, items, game duration - Expandable match details showing all 10 players - Recent searches persisted across restarts Uses op.gg MCP server (no API key needed, no 24h expiration). Backend: server/src/plugins/lolstats/ (3 files) Frontend: web/src/plugins/lolstats/ (2 files) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
24b4dadb0f
commit
40c596fbfa
7 changed files with 1568 additions and 0 deletions
|
|
@ -1,6 +1,7 @@
|
|||
import { useState, useEffect, useRef } from 'react';
|
||||
import RadioTab from './plugins/radio/RadioTab';
|
||||
import SoundboardTab from './plugins/soundboard/SoundboardTab';
|
||||
import LolstatsTab from './plugins/lolstats/LolstatsTab';
|
||||
|
||||
interface PluginInfo {
|
||||
name: string;
|
||||
|
|
@ -12,6 +13,7 @@ interface PluginInfo {
|
|||
const tabComponents: Record<string, React.FC<{ data: any }>> = {
|
||||
radio: RadioTab,
|
||||
soundboard: SoundboardTab,
|
||||
lolstats: LolstatsTab,
|
||||
};
|
||||
|
||||
export function registerTab(pluginName: string, component: React.FC<{ data: any }>) {
|
||||
|
|
@ -79,6 +81,7 @@ export default function App() {
|
|||
const tabIcons: Record<string, string> = {
|
||||
radio: '\u{1F30D}',
|
||||
soundboard: '\u{1F3B5}',
|
||||
lolstats: '\u{2694}\uFE0F',
|
||||
stats: '\u{1F4CA}',
|
||||
events: '\u{1F4C5}',
|
||||
games: '\u{1F3B2}',
|
||||
|
|
|
|||
479
web/src/plugins/lolstats/LolstatsTab.tsx
Normal file
479
web/src/plugins/lolstats/LolstatsTab.tsx
Normal file
|
|
@ -0,0 +1,479 @@
|
|||
import { useState, useEffect, useCallback, useRef } from 'react';
|
||||
import './lolstats.css';
|
||||
|
||||
// ── Types ──
|
||||
|
||||
interface RegionInfo { code: string; label: string; }
|
||||
interface TierInfo { tier: string | null; division: number | null; lp: number | null; tier_image_url?: string; }
|
||||
interface LeagueStat { game_type: string; win: number | null; lose: number | null; is_hot_streak: boolean; tier_info: TierInfo; }
|
||||
interface LadderRank { rank: number | null; total: number | null; }
|
||||
interface ChampionStat { champion_name: string; id: number; play: number; win: number; lose: number; kill: number; death: number; assist: number; }
|
||||
interface MostChampions { game_type: string; play: number; win: number; lose: number; champion_stats: ChampionStat[]; }
|
||||
|
||||
interface SummonerProfile {
|
||||
game_name: string; tagline: string; level: number; profile_image_url: string;
|
||||
league_stats: LeagueStat[]; ladder_rank: LadderRank; most_champions: MostChampions;
|
||||
updated_at: string;
|
||||
}
|
||||
|
||||
interface MatchParticipant {
|
||||
champion_name: string; champion_id: number; items: number[]; items_names: string[];
|
||||
position: string; team_key: string; spells: number[];
|
||||
stats: {
|
||||
kill: number; death: number; assist: number; minion_kill: number; neutral_minion_kill: number;
|
||||
gold_earned: number; total_damage_dealt_to_champions: number; total_damage_taken: number;
|
||||
ward_place: number; vision_wards_bought_in_game: number; champion_level: number;
|
||||
op_score: number; op_score_rank: number; result: string;
|
||||
};
|
||||
summoner: { game_name: string; tagline: string; };
|
||||
}
|
||||
|
||||
interface TeamStat {
|
||||
key: string; banned_champions_names: string[];
|
||||
game_stat: { is_win: boolean; baron_kill: number; dragon_kill: number; tower_kill: number; champion_kill: number; gold_earned: number; };
|
||||
}
|
||||
|
||||
interface MatchEntry {
|
||||
id: string; created_at: string; game_length_second: number; game_type: string; game_map: string;
|
||||
average_tier_info?: { tier: string; division: number };
|
||||
participants: MatchParticipant[]; teams: TeamStat[];
|
||||
}
|
||||
|
||||
interface RecentSearch {
|
||||
game_name: string; tag_line: string; region: string;
|
||||
profile_image_url: string; level: number; tier?: string; rank?: string; timestamp: number;
|
||||
}
|
||||
|
||||
// ── Constants ──
|
||||
|
||||
const TIER_COLORS: Record<string, string> = {
|
||||
IRON: '#6b6b6b', BRONZE: '#8c6239', SILVER: '#8c8c8c', GOLD: '#d4a017',
|
||||
PLATINUM: '#28b29e', EMERALD: '#1e9e5e', DIAMOND: '#576cce',
|
||||
MASTER: '#9d48e0', GRANDMASTER: '#e44c3e', CHALLENGER: '#f4c874',
|
||||
};
|
||||
|
||||
const QUEUE_NAMES: Record<string, string> = {
|
||||
SOLORANKED: 'Ranked Solo', FLEXRANKED: 'Ranked Flex',
|
||||
NORMAL: 'Normal', ARAM: 'ARAM', ARENA: 'Arena', URF: 'URF',
|
||||
BOT: 'Co-op vs AI',
|
||||
};
|
||||
|
||||
const DDRAGON = 'https://ddragon.leagueoflegends.com/cdn/15.5.1/img';
|
||||
|
||||
// ── Helpers ──
|
||||
|
||||
function champImg(name: string): string {
|
||||
return `${DDRAGON}/champion/${name}.png`;
|
||||
}
|
||||
|
||||
function timeAgo(iso: string): string {
|
||||
const sec = Math.floor((Date.now() - new Date(iso).getTime()) / 1000);
|
||||
if (sec < 60) return `${sec}s`;
|
||||
if (sec < 3600) return `${Math.floor(sec / 60)}m`;
|
||||
if (sec < 86400) return `${Math.floor(sec / 3600)}h`;
|
||||
return `${Math.floor(sec / 86400)}d`;
|
||||
}
|
||||
|
||||
function fmtDuration(secs: number): string {
|
||||
const m = Math.floor(secs / 60);
|
||||
const s = secs % 60;
|
||||
return `${m}:${String(s).padStart(2, '0')}`;
|
||||
}
|
||||
|
||||
function kdaRatio(k: number, d: number, a: number): string {
|
||||
if (d === 0) return 'Perfect';
|
||||
return ((k + a) / d).toFixed(2);
|
||||
}
|
||||
|
||||
function winRate(w: number, l: number): number {
|
||||
const total = w + l;
|
||||
return total > 0 ? Math.round((w / total) * 100) : 0;
|
||||
}
|
||||
|
||||
function tierDisplay(tier: string | null, div: number | null): string {
|
||||
if (!tier) return 'Unranked';
|
||||
const roman = ['', 'I', 'II', 'III', 'IV'];
|
||||
return `${tier.charAt(0)}${tier.slice(1).toLowerCase()}${div ? ' ' + (roman[div] ?? div) : ''}`;
|
||||
}
|
||||
|
||||
// ── Component ──
|
||||
|
||||
export default function LolstatsTab({ data }: { data: any }) {
|
||||
const [searchText, setSearchText] = useState('');
|
||||
const [region, setRegion] = useState('EUW');
|
||||
const [regions, setRegions] = useState<RegionInfo[]>([]);
|
||||
|
||||
const [profile, setProfile] = useState<SummonerProfile | null>(null);
|
||||
const [matches, setMatches] = useState<MatchEntry[]>([]);
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [recentSearches, setRecentSearches] = useState<RecentSearch[]>([]);
|
||||
const [expandedMatch, setExpandedMatch] = useState<string | null>(null);
|
||||
const [matchDetails, setMatchDetails] = useState<Record<string, MatchEntry>>({});
|
||||
const [loadingMore, setLoadingMore] = useState(false);
|
||||
|
||||
const searchRef = useRef<HTMLInputElement>(null);
|
||||
|
||||
// Load regions
|
||||
useEffect(() => {
|
||||
fetch('/api/lolstats/regions').then(r => r.json()).then(setRegions).catch(() => {});
|
||||
fetch('/api/lolstats/recent').then(r => r.json()).then(setRecentSearches).catch(() => {});
|
||||
}, []);
|
||||
|
||||
// SSE data
|
||||
useEffect(() => {
|
||||
if (!data) return;
|
||||
if (data.recentSearches) setRecentSearches(data.recentSearches);
|
||||
if (data.regions && !regions.length) setRegions(data.regions);
|
||||
}, [data]);
|
||||
|
||||
// ── Search ──
|
||||
const doSearch = useCallback(async (gn?: string, tl?: string, rg?: string) => {
|
||||
let gameName = gn ?? '';
|
||||
let tagLine = tl ?? '';
|
||||
const searchRegion = rg ?? region;
|
||||
|
||||
if (!gameName) {
|
||||
// Parse from search text "Name#Tag"
|
||||
const parts = searchText.split('#');
|
||||
gameName = parts[0]?.trim() ?? '';
|
||||
tagLine = parts[1]?.trim() ?? '';
|
||||
}
|
||||
|
||||
if (!gameName || !tagLine) {
|
||||
setError('Bitte im Format Name#Tag eingeben');
|
||||
return;
|
||||
}
|
||||
|
||||
setLoading(true);
|
||||
setError(null);
|
||||
setProfile(null);
|
||||
setMatches([]);
|
||||
setExpandedMatch(null);
|
||||
setMatchDetails({});
|
||||
|
||||
try {
|
||||
const qs = `gameName=${encodeURIComponent(gameName)}&tagLine=${encodeURIComponent(tagLine)}®ion=${searchRegion}`;
|
||||
|
||||
// Fetch profile and matches in parallel
|
||||
const [profileRes, matchesRes] = await Promise.all([
|
||||
fetch(`/api/lolstats/profile?${qs}`),
|
||||
fetch(`/api/lolstats/matches?${qs}&limit=10`),
|
||||
]);
|
||||
|
||||
if (!profileRes.ok) {
|
||||
const err = await profileRes.json();
|
||||
throw new Error(err.error ?? `Fehler ${profileRes.status}`);
|
||||
}
|
||||
|
||||
const profileData = await profileRes.json();
|
||||
setProfile(profileData);
|
||||
|
||||
if (matchesRes.ok) {
|
||||
const matchesData = await matchesRes.json();
|
||||
setMatches(Array.isArray(matchesData) ? matchesData : []);
|
||||
}
|
||||
} catch (e: any) {
|
||||
setError(e.message);
|
||||
}
|
||||
setLoading(false);
|
||||
}, [searchText, region]);
|
||||
|
||||
// ── Load more matches ──
|
||||
const loadMore = useCallback(async () => {
|
||||
if (!profile || loadingMore) return;
|
||||
setLoadingMore(true);
|
||||
try {
|
||||
const qs = `gameName=${encodeURIComponent(profile.game_name)}&tagLine=${encodeURIComponent(profile.tagline)}®ion=${region}&limit=20`;
|
||||
const res = await fetch(`/api/lolstats/matches?${qs}`);
|
||||
if (res.ok) {
|
||||
const data = await res.json();
|
||||
setMatches(Array.isArray(data) ? data : []);
|
||||
}
|
||||
} catch {}
|
||||
setLoadingMore(false);
|
||||
}, [profile, region, loadingMore]);
|
||||
|
||||
// ── Expand match detail ──
|
||||
const toggleMatch = useCallback(async (match: MatchEntry) => {
|
||||
if (expandedMatch === match.id) {
|
||||
setExpandedMatch(null);
|
||||
return;
|
||||
}
|
||||
setExpandedMatch(match.id);
|
||||
|
||||
// If we already have full detail (10 participants), skip fetch
|
||||
if (match.participants?.length >= 10 || matchDetails[match.id]) return;
|
||||
|
||||
try {
|
||||
const qs = `region=${region}&createdAt=${encodeURIComponent(match.created_at)}`;
|
||||
const res = await fetch(`/api/lolstats/match/${encodeURIComponent(match.id)}?${qs}`);
|
||||
if (res.ok) {
|
||||
const detail = await res.json();
|
||||
setMatchDetails(prev => ({ ...prev, [match.id]: detail }));
|
||||
}
|
||||
} catch {}
|
||||
}, [expandedMatch, matchDetails, region]);
|
||||
|
||||
// Recent search click
|
||||
const onRecentClick = useCallback((r: RecentSearch) => {
|
||||
setSearchText(`${r.game_name}#${r.tag_line}`);
|
||||
setRegion(r.region);
|
||||
doSearch(r.game_name, r.tag_line, r.region);
|
||||
}, [doSearch]);
|
||||
|
||||
// ── Render Match Row ──
|
||||
const renderMatch = (match: MatchEntry) => {
|
||||
// The participant is the target summoner (first and only in list from matches endpoint)
|
||||
const me = match.participants?.[0];
|
||||
if (!me) return null;
|
||||
|
||||
const isWin = me.stats?.result === 'WIN';
|
||||
const kda = kdaRatio(me.stats.kill, me.stats.death, me.stats.assist);
|
||||
const cs = (me.stats.minion_kill ?? 0) + (me.stats.neutral_minion_kill ?? 0);
|
||||
const csPerMin = match.game_length_second > 0 ? (cs / (match.game_length_second / 60)).toFixed(1) : '0';
|
||||
const isExpanded = expandedMatch === match.id;
|
||||
const detail = matchDetails[match.id] ?? (match.participants?.length >= 10 ? match : null);
|
||||
|
||||
return (
|
||||
<div key={match.id}>
|
||||
<div
|
||||
className={`lol-match ${isWin ? 'win' : 'loss'}`}
|
||||
onClick={() => toggleMatch(match)}
|
||||
>
|
||||
<div className="lol-match-result">{isWin ? 'W' : 'L'}</div>
|
||||
|
||||
<div className="lol-match-champ">
|
||||
<img src={champImg(me.champion_name)} alt={me.champion_name} title={me.champion_name} />
|
||||
<span className="lol-match-champ-level">{me.stats.champion_level}</span>
|
||||
</div>
|
||||
|
||||
<div className="lol-match-kda">
|
||||
<div className="lol-match-kda-nums">{me.stats.kill}/{me.stats.death}/{me.stats.assist}</div>
|
||||
<div className={`lol-match-kda-ratio ${kda === 'Perfect' ? 'perfect' : Number(kda) >= 4 ? 'great' : ''}`}>
|
||||
{kda} KDA
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="lol-match-stats">
|
||||
<span>{cs} CS ({csPerMin}/m)</span>
|
||||
<span>{me.stats.ward_place} wards</span>
|
||||
</div>
|
||||
|
||||
<div className="lol-match-items">
|
||||
{(me.items_names ?? []).slice(0, 7).map((item, i) =>
|
||||
item ? (
|
||||
<img key={i} src={champImg('Aatrox')} alt={item} title={item}
|
||||
style={{ background: 'var(--bg-deep)' }}
|
||||
onError={e => { (e.target as HTMLImageElement).style.display = 'none'; }}
|
||||
/>
|
||||
) : <div key={i} className="lol-match-item-empty" />
|
||||
)}
|
||||
</div>
|
||||
|
||||
<div className="lol-match-meta">
|
||||
<div className="lol-match-duration">{fmtDuration(match.game_length_second)}</div>
|
||||
<div className="lol-match-queue">{QUEUE_NAMES[match.game_type] ?? match.game_type}</div>
|
||||
<div className="lol-match-ago">{timeAgo(match.created_at)} ago</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Expanded detail */}
|
||||
{isExpanded && detail && (
|
||||
<div className="lol-match-detail">
|
||||
{renderMatchDetail(detail, me.summoner?.game_name)}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
// ── Render Match Detail (all 10 players) ──
|
||||
const renderMatchDetail = (match: MatchEntry, myName?: string) => {
|
||||
const blue = match.participants?.filter(p => p.team_key === 'BLUE') ?? [];
|
||||
const red = match.participants?.filter(p => p.team_key === 'RED') ?? [];
|
||||
const blueWin = match.teams?.find(t => t.key === 'BLUE')?.game_stat?.is_win;
|
||||
|
||||
const renderTeam = (team: MatchParticipant[], isWin: boolean | undefined, label: string) => (
|
||||
<div className="lol-match-detail-team">
|
||||
<div className={`lol-match-detail-team-header ${isWin ? 'win' : 'loss'}`}>
|
||||
{label} — {isWin ? 'Victory' : 'Defeat'}
|
||||
</div>
|
||||
{team.map((p, i) => {
|
||||
const isMe = p.summoner?.game_name?.toLowerCase() === myName?.toLowerCase();
|
||||
const cs = (p.stats?.minion_kill ?? 0) + (p.stats?.neutral_minion_kill ?? 0);
|
||||
return (
|
||||
<div key={i} className={`lol-detail-row ${isMe ? 'me' : ''}`}>
|
||||
<img className="lol-detail-champ" src={champImg(p.champion_name)} alt={p.champion_name} />
|
||||
<span className="lol-detail-name" title={`${p.summoner?.game_name}#${p.summoner?.tagline}`}>
|
||||
{p.summoner?.game_name ?? p.champion_name}
|
||||
</span>
|
||||
<span className="lol-detail-kda">{p.stats?.kill}/{p.stats?.death}/{p.stats?.assist}</span>
|
||||
<span className="lol-detail-cs">{cs} CS</span>
|
||||
<span className="lol-detail-dmg">{((p.stats?.total_damage_dealt_to_champions ?? 0) / 1000).toFixed(1)}k</span>
|
||||
<span className="lol-detail-gold">{((p.stats?.gold_earned ?? 0) / 1000).toFixed(1)}k</span>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
);
|
||||
|
||||
return (
|
||||
<>
|
||||
{renderTeam(blue, blueWin, 'Blue Team')}
|
||||
{renderTeam(red, blueWin === undefined ? undefined : !blueWin, 'Red Team')}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
// ── Main Render ──
|
||||
return (
|
||||
<div className="lol-container">
|
||||
{/* Search */}
|
||||
<div className="lol-search">
|
||||
<input
|
||||
ref={searchRef}
|
||||
className="lol-search-input"
|
||||
placeholder="Summoner Name#Tag"
|
||||
value={searchText}
|
||||
onChange={e => setSearchText(e.target.value)}
|
||||
onKeyDown={e => e.key === 'Enter' && doSearch()}
|
||||
/>
|
||||
<select className="lol-search-region" value={region} onChange={e => setRegion(e.target.value)}>
|
||||
{regions.map(r => <option key={r.code} value={r.code}>{r.code}</option>)}
|
||||
</select>
|
||||
<button className="lol-search-btn" onClick={() => doSearch()} disabled={loading}>
|
||||
{loading ? '...' : 'Search'}
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Recent searches */}
|
||||
{recentSearches.length > 0 && (
|
||||
<div className="lol-recent">
|
||||
{recentSearches.map((r, i) => (
|
||||
<button key={i} className="lol-recent-chip" onClick={() => onRecentClick(r)}>
|
||||
{r.profile_image_url && <img src={r.profile_image_url} alt="" />}
|
||||
{r.game_name}#{r.tag_line}
|
||||
{r.tier && <span className="lol-recent-tier" style={{ color: TIER_COLORS[r.tier] }}>{r.tier}</span>}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Error */}
|
||||
{error && <div className="lol-error">{error}</div>}
|
||||
|
||||
{/* Loading */}
|
||||
{loading && (
|
||||
<div className="lol-loading">
|
||||
<div className="lol-spinner" />
|
||||
Lade Profil...
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* Profile */}
|
||||
{profile && !loading && (
|
||||
<>
|
||||
<div className="lol-profile">
|
||||
<img className="lol-profile-icon" src={profile.profile_image_url} alt="" />
|
||||
<div className="lol-profile-info">
|
||||
<h2>{profile.game_name}<span>#{profile.tagline}</span></h2>
|
||||
<div className="lol-profile-level">Level {profile.level}</div>
|
||||
{profile.ladder_rank?.rank && (
|
||||
<div className="lol-profile-ladder">
|
||||
Ladder Rank #{profile.ladder_rank.rank.toLocaleString()} / {profile.ladder_rank.total?.toLocaleString()}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Ranked Cards */}
|
||||
<div className="lol-ranked-row">
|
||||
{(profile.league_stats ?? [])
|
||||
.filter(ls => ls.game_type === 'SOLORANKED' || ls.game_type === 'FLEXRANKED')
|
||||
.map(ls => {
|
||||
const t = ls.tier_info;
|
||||
const hasRank = !!t?.tier;
|
||||
const tierColor = TIER_COLORS[t?.tier ?? ''] ?? 'var(--text-normal)';
|
||||
return (
|
||||
<div
|
||||
key={ls.game_type}
|
||||
className={`lol-ranked-card ${hasRank ? 'has-rank' : ''}`}
|
||||
style={{ '--tier-color': tierColor } as React.CSSProperties}
|
||||
>
|
||||
<div className="lol-ranked-type">
|
||||
{ls.game_type === 'SOLORANKED' ? 'Ranked Solo/Duo' : 'Ranked Flex'}
|
||||
</div>
|
||||
{hasRank ? (
|
||||
<>
|
||||
<div className="lol-ranked-tier" style={{ color: tierColor }}>
|
||||
{tierDisplay(t.tier, t.division)}
|
||||
<span className="lol-ranked-lp">{t.lp} LP</span>
|
||||
</div>
|
||||
<div className="lol-ranked-record">
|
||||
{ls.win}W {ls.lose}L
|
||||
<span className="lol-ranked-wr">({winRate(ls.win ?? 0, ls.lose ?? 0)}%)</span>
|
||||
{ls.is_hot_streak && <span className="lol-ranked-streak">🔥</span>}
|
||||
</div>
|
||||
</>
|
||||
) : (
|
||||
<div className="lol-ranked-tier">Unranked</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
|
||||
{/* Most Champions */}
|
||||
{profile.most_champions?.champion_stats?.length > 0 && (
|
||||
<>
|
||||
<div className="lol-section-title">Top Champions</div>
|
||||
<div className="lol-champs">
|
||||
{profile.most_champions.champion_stats.slice(0, 7).map(cs => {
|
||||
const wr = winRate(cs.win, cs.lose);
|
||||
const avgKda = cs.play > 0
|
||||
? kdaRatio(cs.kill / cs.play, cs.death / cs.play, cs.assist / cs.play)
|
||||
: '0';
|
||||
return (
|
||||
<div key={cs.champion_name} className="lol-champ-card">
|
||||
<img className="lol-champ-icon" src={champImg(cs.champion_name)} alt={cs.champion_name} />
|
||||
<div>
|
||||
<div className="lol-champ-name">{cs.champion_name}</div>
|
||||
<div className="lol-champ-stats">{cs.play} games · {wr}% WR</div>
|
||||
<div className="lol-champ-kda">{avgKda} KDA</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</>
|
||||
)}
|
||||
|
||||
{/* Match History */}
|
||||
{matches.length > 0 && (
|
||||
<>
|
||||
<div className="lol-section-title">Match History</div>
|
||||
<div className="lol-matches">
|
||||
{matches.map(m => renderMatch(m))}
|
||||
</div>
|
||||
{matches.length < 20 && (
|
||||
<button className="lol-load-more" onClick={loadMore} disabled={loadingMore}>
|
||||
{loadingMore ? 'Laden...' : 'Mehr laden'}
|
||||
</button>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
|
||||
{/* Empty state */}
|
||||
{!profile && !loading && !error && (
|
||||
<div className="lol-empty">
|
||||
<div className="lol-empty-icon">⚔️</div>
|
||||
<h3>League of Legends Stats</h3>
|
||||
<p>Gib einen Summoner Name#Tag ein und wähle die Region</p>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
464
web/src/plugins/lolstats/lolstats.css
Normal file
464
web/src/plugins/lolstats/lolstats.css
Normal file
|
|
@ -0,0 +1,464 @@
|
|||
/* ── LoL Stats Plugin ── */
|
||||
|
||||
.lol-container {
|
||||
max-width: 920px;
|
||||
margin: 0 auto;
|
||||
padding: 16px;
|
||||
height: 100%;
|
||||
overflow-y: auto;
|
||||
}
|
||||
|
||||
/* ── Search ── */
|
||||
.lol-search {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.lol-search-input {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
padding: 10px 14px;
|
||||
border: 1px solid var(--bg-tertiary);
|
||||
border-radius: 8px;
|
||||
background: var(--bg-secondary);
|
||||
color: var(--text-normal);
|
||||
font-size: 15px;
|
||||
outline: none;
|
||||
transition: border-color 0.2s;
|
||||
}
|
||||
.lol-search-input:focus { border-color: var(--accent); }
|
||||
.lol-search-input::placeholder { color: var(--text-faint); }
|
||||
|
||||
.lol-search-region {
|
||||
padding: 10px 12px;
|
||||
border: 1px solid var(--bg-tertiary);
|
||||
border-radius: 8px;
|
||||
background: var(--bg-secondary);
|
||||
color: var(--text-normal);
|
||||
font-size: 14px;
|
||||
cursor: pointer;
|
||||
outline: none;
|
||||
}
|
||||
|
||||
.lol-search-btn {
|
||||
padding: 10px 20px;
|
||||
border: none;
|
||||
border-radius: 8px;
|
||||
background: var(--accent);
|
||||
color: #fff;
|
||||
font-weight: 600;
|
||||
font-size: 14px;
|
||||
cursor: pointer;
|
||||
transition: opacity 0.2s;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.lol-search-btn:hover { opacity: 0.85; }
|
||||
.lol-search-btn:disabled { opacity: 0.4; cursor: not-allowed; }
|
||||
|
||||
/* ── Recent Searches ── */
|
||||
.lol-recent {
|
||||
display: flex;
|
||||
gap: 6px;
|
||||
flex-wrap: wrap;
|
||||
margin-bottom: 16px;
|
||||
}
|
||||
|
||||
.lol-recent-chip {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
padding: 4px 10px;
|
||||
border: 1px solid var(--bg-tertiary);
|
||||
border-radius: 16px;
|
||||
background: var(--bg-secondary);
|
||||
color: var(--text-muted);
|
||||
font-size: 12px;
|
||||
cursor: pointer;
|
||||
transition: border-color 0.2s, color 0.2s;
|
||||
}
|
||||
.lol-recent-chip:hover { border-color: var(--accent); color: var(--text-normal); }
|
||||
.lol-recent-chip img {
|
||||
width: 18px; height: 18px; border-radius: 50%;
|
||||
}
|
||||
.lol-recent-tier {
|
||||
font-size: 10px;
|
||||
font-weight: 600;
|
||||
opacity: 0.7;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
/* ── Profile Header ── */
|
||||
.lol-profile {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 16px;
|
||||
padding: 16px;
|
||||
border-radius: 12px;
|
||||
background: var(--bg-secondary);
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
.lol-profile-icon {
|
||||
width: 72px; height: 72px;
|
||||
border-radius: 12px;
|
||||
border: 2px solid var(--bg-tertiary);
|
||||
object-fit: cover;
|
||||
}
|
||||
.lol-profile-info h2 {
|
||||
margin: 0 0 2px;
|
||||
font-size: 20px;
|
||||
color: var(--text-normal);
|
||||
}
|
||||
.lol-profile-info h2 span {
|
||||
color: var(--text-faint);
|
||||
font-weight: 400;
|
||||
font-size: 14px;
|
||||
}
|
||||
.lol-profile-level {
|
||||
font-size: 12px;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
.lol-profile-ladder {
|
||||
font-size: 11px;
|
||||
color: var(--text-faint);
|
||||
}
|
||||
|
||||
/* ── Ranked Cards ── */
|
||||
.lol-ranked-row {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.lol-ranked-card {
|
||||
flex: 1;
|
||||
padding: 12px 14px;
|
||||
border-radius: 10px;
|
||||
background: var(--bg-secondary);
|
||||
border-left: 4px solid var(--bg-tertiary);
|
||||
}
|
||||
.lol-ranked-card.has-rank { border-left-color: var(--tier-color, var(--accent)); }
|
||||
.lol-ranked-type {
|
||||
font-size: 11px;
|
||||
color: var(--text-faint);
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.5px;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
.lol-ranked-tier {
|
||||
font-size: 18px;
|
||||
font-weight: 700;
|
||||
color: var(--tier-color, var(--text-normal));
|
||||
}
|
||||
.lol-ranked-lp {
|
||||
font-size: 13px;
|
||||
color: var(--text-muted);
|
||||
margin-left: 4px;
|
||||
font-weight: 400;
|
||||
}
|
||||
.lol-ranked-record {
|
||||
font-size: 12px;
|
||||
color: var(--text-muted);
|
||||
margin-top: 2px;
|
||||
}
|
||||
.lol-ranked-wr {
|
||||
color: var(--text-faint);
|
||||
margin-left: 4px;
|
||||
}
|
||||
.lol-ranked-streak {
|
||||
color: #e74c3c;
|
||||
font-size: 11px;
|
||||
margin-left: 4px;
|
||||
}
|
||||
|
||||
/* ── Section Headers ── */
|
||||
.lol-section-title {
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
color: var(--text-muted);
|
||||
text-transform: uppercase;
|
||||
letter-spacing: 0.5px;
|
||||
margin: 16px 0 8px;
|
||||
padding-left: 2px;
|
||||
}
|
||||
|
||||
/* ── Most Champions ── */
|
||||
.lol-champs {
|
||||
display: flex;
|
||||
gap: 8px;
|
||||
margin-bottom: 12px;
|
||||
overflow-x: auto;
|
||||
padding-bottom: 4px;
|
||||
}
|
||||
.lol-champ-card {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 8px 12px;
|
||||
border-radius: 8px;
|
||||
background: var(--bg-secondary);
|
||||
min-width: 180px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.lol-champ-icon {
|
||||
width: 36px; height: 36px;
|
||||
border-radius: 50%;
|
||||
object-fit: cover;
|
||||
}
|
||||
.lol-champ-name {
|
||||
font-size: 13px;
|
||||
font-weight: 600;
|
||||
color: var(--text-normal);
|
||||
}
|
||||
.lol-champ-stats {
|
||||
font-size: 11px;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
.lol-champ-kda {
|
||||
font-size: 11px;
|
||||
color: var(--text-faint);
|
||||
}
|
||||
|
||||
/* ── Match History ── */
|
||||
.lol-matches {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.lol-match {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
padding: 10px 12px;
|
||||
border-radius: 8px;
|
||||
background: var(--bg-secondary);
|
||||
border-left: 4px solid var(--bg-tertiary);
|
||||
cursor: pointer;
|
||||
transition: background 0.15s;
|
||||
}
|
||||
.lol-match:hover { background: var(--bg-tertiary); }
|
||||
.lol-match.win { border-left-color: #2ecc71; }
|
||||
.lol-match.loss { border-left-color: #e74c3c; }
|
||||
|
||||
.lol-match-result {
|
||||
width: 28px;
|
||||
font-size: 11px;
|
||||
font-weight: 700;
|
||||
text-align: center;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.lol-match.win .lol-match-result { color: #2ecc71; }
|
||||
.lol-match.loss .lol-match-result { color: #e74c3c; }
|
||||
|
||||
.lol-match-champ {
|
||||
position: relative;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.lol-match-champ img {
|
||||
width: 40px; height: 40px; border-radius: 50%;
|
||||
display: block;
|
||||
}
|
||||
.lol-match-champ-level {
|
||||
position: absolute;
|
||||
bottom: -2px; right: -2px;
|
||||
background: var(--bg-deep);
|
||||
color: var(--text-muted);
|
||||
font-size: 9px;
|
||||
font-weight: 700;
|
||||
width: 16px; height: 16px;
|
||||
border-radius: 50%;
|
||||
display: flex; align-items: center; justify-content: center;
|
||||
}
|
||||
|
||||
.lol-match-kda {
|
||||
min-width: 80px;
|
||||
text-align: center;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.lol-match-kda-nums {
|
||||
font-size: 14px;
|
||||
font-weight: 600;
|
||||
color: var(--text-normal);
|
||||
}
|
||||
.lol-match-kda-ratio {
|
||||
font-size: 11px;
|
||||
color: var(--text-faint);
|
||||
}
|
||||
.lol-match-kda-ratio.perfect { color: #f39c12; }
|
||||
.lol-match-kda-ratio.great { color: #2ecc71; }
|
||||
|
||||
.lol-match-stats {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1px;
|
||||
min-width: 70px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.lol-match-stats span {
|
||||
font-size: 11px;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
|
||||
.lol-match-items {
|
||||
display: flex;
|
||||
gap: 2px;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.lol-match-items img {
|
||||
width: 24px; height: 24px;
|
||||
border-radius: 4px;
|
||||
background: var(--bg-deep);
|
||||
}
|
||||
.lol-match-item-empty {
|
||||
width: 24px; height: 24px;
|
||||
border-radius: 4px;
|
||||
background: var(--bg-deep);
|
||||
}
|
||||
|
||||
.lol-match-meta {
|
||||
margin-left: auto;
|
||||
text-align: right;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.lol-match-duration {
|
||||
font-size: 12px;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
.lol-match-queue {
|
||||
font-size: 10px;
|
||||
color: var(--text-faint);
|
||||
}
|
||||
.lol-match-ago {
|
||||
font-size: 10px;
|
||||
color: var(--text-faint);
|
||||
}
|
||||
|
||||
/* ── Match Detail (expanded) ── */
|
||||
.lol-match-detail {
|
||||
background: var(--bg-primary);
|
||||
border-radius: 8px;
|
||||
padding: 8px;
|
||||
margin-top: 4px;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
.lol-match-detail-team {
|
||||
margin-bottom: 6px;
|
||||
}
|
||||
.lol-match-detail-team-header {
|
||||
font-size: 11px;
|
||||
font-weight: 600;
|
||||
padding: 4px 8px;
|
||||
border-radius: 4px;
|
||||
margin-bottom: 4px;
|
||||
}
|
||||
.lol-match-detail-team-header.win { background: rgba(46,204,113,0.15); color: #2ecc71; }
|
||||
.lol-match-detail-team-header.loss { background: rgba(231,76,60,0.15); color: #e74c3c; }
|
||||
|
||||
.lol-detail-row {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
padding: 3px 8px;
|
||||
border-radius: 4px;
|
||||
font-size: 12px;
|
||||
color: var(--text-muted);
|
||||
}
|
||||
.lol-detail-row:hover { background: var(--bg-secondary); }
|
||||
.lol-detail-row.me { background: rgba(255,255,255,0.04); font-weight: 600; }
|
||||
|
||||
.lol-detail-champ {
|
||||
width: 24px; height: 24px; border-radius: 50%;
|
||||
}
|
||||
.lol-detail-name {
|
||||
width: 110px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
color: var(--text-normal);
|
||||
}
|
||||
.lol-detail-kda { width: 70px; text-align: center; }
|
||||
.lol-detail-cs { width: 45px; text-align: center; }
|
||||
.lol-detail-dmg { width: 55px; text-align: center; }
|
||||
.lol-detail-gold { width: 55px; text-align: center; }
|
||||
.lol-detail-items {
|
||||
display: flex; gap: 1px;
|
||||
}
|
||||
.lol-detail-items img {
|
||||
width: 20px; height: 20px; border-radius: 3px;
|
||||
}
|
||||
|
||||
/* ── Loading / Error / Empty ── */
|
||||
.lol-loading {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: 10px;
|
||||
padding: 40px;
|
||||
color: var(--text-muted);
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.lol-spinner {
|
||||
width: 20px; height: 20px;
|
||||
border: 2px solid var(--bg-tertiary);
|
||||
border-top-color: var(--accent);
|
||||
border-radius: 50%;
|
||||
animation: lol-spin 0.8s linear infinite;
|
||||
}
|
||||
@keyframes lol-spin { to { transform: rotate(360deg); } }
|
||||
|
||||
.lol-error {
|
||||
padding: 16px;
|
||||
border-radius: 8px;
|
||||
background: rgba(231,76,60,0.1);
|
||||
color: #e74c3c;
|
||||
font-size: 13px;
|
||||
text-align: center;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
|
||||
.lol-empty {
|
||||
text-align: center;
|
||||
padding: 60px 20px;
|
||||
color: var(--text-faint);
|
||||
}
|
||||
.lol-empty-icon {
|
||||
font-size: 48px;
|
||||
margin-bottom: 12px;
|
||||
}
|
||||
.lol-empty h3 {
|
||||
margin: 0 0 8px;
|
||||
color: var(--text-muted);
|
||||
font-size: 16px;
|
||||
}
|
||||
.lol-empty p {
|
||||
margin: 0;
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
/* ── Load more ── */
|
||||
.lol-load-more {
|
||||
display: block;
|
||||
width: 100%;
|
||||
padding: 10px;
|
||||
margin-top: 8px;
|
||||
border: 1px solid var(--bg-tertiary);
|
||||
border-radius: 8px;
|
||||
background: transparent;
|
||||
color: var(--text-muted);
|
||||
font-size: 13px;
|
||||
cursor: pointer;
|
||||
transition: border-color 0.2s, color 0.2s;
|
||||
}
|
||||
.lol-load-more:hover { border-color: var(--accent); color: var(--text-normal); }
|
||||
|
||||
/* ── Responsive ── */
|
||||
@media (max-width: 640px) {
|
||||
.lol-search { flex-wrap: wrap; }
|
||||
.lol-search-input { width: 100%; }
|
||||
.lol-match { flex-wrap: wrap; gap: 6px; }
|
||||
.lol-match-meta { margin-left: 0; text-align: left; }
|
||||
.lol-match-items { flex-wrap: wrap; }
|
||||
.lol-profile { flex-wrap: wrap; }
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue