feat: add first version of TougliGui with same features as on google sheet
This commit is contained in:
1
src/App.css
Normal file
1
src/App.css
Normal file
@ -0,0 +1 @@
|
||||
/* Overridden by index.css — kept empty */
|
||||
89
src/App.tsx
Normal file
89
src/App.tsx
Normal file
@ -0,0 +1,89 @@
|
||||
import { useEffect, useState } from "react";
|
||||
import { invoke } from "@tauri-apps/api/core";
|
||||
import { useStore } from "./store";
|
||||
import TitleBar from "./components/TitleBar";
|
||||
import Sidebar from "./components/Sidebar";
|
||||
import HomeView from "./components/HomeView";
|
||||
import GuideView from "./components/GuideView";
|
||||
import ProfileModal from "./components/ProfileModal";
|
||||
import SyncOverlay from "./components/SyncOverlay";
|
||||
|
||||
export default function App() {
|
||||
const { loadProfiles, loadGuides, view, syncing, syncGuides } = useStore();
|
||||
const [showProfileModal, setShowProfileModal] = useState(false);
|
||||
const [needsSync, setNeedsSync] = useState(false);
|
||||
|
||||
useEffect(() => {
|
||||
async function init() {
|
||||
await loadProfiles();
|
||||
const has = await invoke<boolean>("has_guides");
|
||||
if (!has) {
|
||||
setNeedsSync(true);
|
||||
} else {
|
||||
await loadGuides();
|
||||
}
|
||||
}
|
||||
init();
|
||||
}, []);
|
||||
|
||||
async function handleInitialSync() {
|
||||
setNeedsSync(false);
|
||||
await syncGuides();
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="app-shell">
|
||||
<TitleBar onOpenProfiles={() => setShowProfileModal(true)} />
|
||||
<div className="app-body">
|
||||
<Sidebar />
|
||||
<main className="app-main">
|
||||
{view === "home" ? <HomeView /> : <GuideView />}
|
||||
</main>
|
||||
</div>
|
||||
|
||||
{showProfileModal && <ProfileModal onClose={() => setShowProfileModal(false)} />}
|
||||
{syncing && <SyncOverlay />}
|
||||
{needsSync && (
|
||||
<div style={{
|
||||
position: "fixed", inset: 0, background: "rgba(0,0,0,0.85)",
|
||||
display: "flex", alignItems: "center", justifyContent: "center",
|
||||
zIndex: 100, borderRadius: "10px"
|
||||
}}>
|
||||
<div style={{
|
||||
background: "#161b22", border: "1px solid #f0c040", borderRadius: "12px",
|
||||
padding: "40px 48px", maxWidth: "440px", textAlign: "center",
|
||||
display: "flex", flexDirection: "column", gap: "16px"
|
||||
}}>
|
||||
<div style={{ fontSize: "40px" }}>⚔️</div>
|
||||
<h2 style={{ fontSize: "20px", fontWeight: 700, color: "#f0c040" }}>
|
||||
Bienvenue dans TougliGui
|
||||
</h2>
|
||||
<p style={{ color: "#94a3b8", fontSize: "14px", lineHeight: 1.6 }}>
|
||||
Première utilisation — synchronisation du guide Tougli depuis Google Sheets.
|
||||
<br />Cela peut prendre quelques secondes.
|
||||
</p>
|
||||
<button
|
||||
onClick={handleInitialSync}
|
||||
style={{
|
||||
background: "#f0c040", color: "#0d1117", border: "none",
|
||||
padding: "10px 24px", borderRadius: "8px", fontWeight: 700,
|
||||
fontSize: "14px", cursor: "pointer", marginTop: "8px"
|
||||
}}
|
||||
>
|
||||
Synchroniser maintenant
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<style>{`
|
||||
.app-shell {
|
||||
display: flex; flex-direction: column; height: 100vh;
|
||||
background: #0d1117; overflow: hidden;
|
||||
}
|
||||
.app-body { display: flex; flex: 1; overflow: hidden; }
|
||||
.app-main { flex: 1; overflow: hidden; display: flex; flex-direction: column; }
|
||||
`}</style>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
1
src/assets/react.svg
Normal file
1
src/assets/react.svg
Normal file
@ -0,0 +1 @@
|
||||
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--logos" width="35.93" height="32" preserveAspectRatio="xMidYMid meet" viewBox="0 0 256 228"><path fill="#00D8FF" d="M210.483 73.824a171.49 171.49 0 0 0-8.24-2.597c.465-1.9.893-3.777 1.273-5.621c6.238-30.281 2.16-54.676-11.769-62.708c-13.355-7.7-35.196.329-57.254 19.526a171.23 171.23 0 0 0-6.375 5.848a155.866 155.866 0 0 0-4.241-3.917C100.759 3.829 77.587-4.822 63.673 3.233C50.33 10.957 46.379 33.89 51.995 62.588a170.974 170.974 0 0 0 1.892 8.48c-3.28.932-6.445 1.924-9.474 2.98C17.309 83.498 0 98.307 0 113.668c0 15.865 18.582 31.778 46.812 41.427a145.52 145.52 0 0 0 6.921 2.165a167.467 167.467 0 0 0-2.01 9.138c-5.354 28.2-1.173 50.591 12.134 58.266c13.744 7.926 36.812-.22 59.273-19.855a145.567 145.567 0 0 0 5.342-4.923a168.064 168.064 0 0 0 6.92 6.314c21.758 18.722 43.246 26.282 56.54 18.586c13.731-7.949 18.194-32.003 12.4-61.268a145.016 145.016 0 0 0-1.535-6.842c1.62-.48 3.21-.974 4.76-1.488c29.348-9.723 48.443-25.443 48.443-41.52c0-15.417-17.868-30.326-45.517-39.844Zm-6.365 70.984c-1.4.463-2.836.91-4.3 1.345c-3.24-10.257-7.612-21.163-12.963-32.432c5.106-11 9.31-21.767 12.459-31.957c2.619.758 5.16 1.557 7.61 2.4c23.69 8.156 38.14 20.213 38.14 29.504c0 9.896-15.606 22.743-40.946 31.14Zm-10.514 20.834c2.562 12.94 2.927 24.64 1.23 33.787c-1.524 8.219-4.59 13.698-8.382 15.893c-8.067 4.67-25.32-1.4-43.927-17.412a156.726 156.726 0 0 1-6.437-5.87c7.214-7.889 14.423-17.06 21.459-27.246c12.376-1.098 24.068-2.894 34.671-5.345a134.17 134.17 0 0 1 1.386 6.193ZM87.276 214.515c-7.882 2.783-14.16 2.863-17.955.675c-8.075-4.657-11.432-22.636-6.853-46.752a156.923 156.923 0 0 1 1.869-8.499c10.486 2.32 22.093 3.988 34.498 4.994c7.084 9.967 14.501 19.128 21.976 27.15a134.668 134.668 0 0 1-4.877 4.492c-9.933 8.682-19.886 14.842-28.658 17.94ZM50.35 144.747c-12.483-4.267-22.792-9.812-29.858-15.863c-6.35-5.437-9.555-10.836-9.555-15.216c0-9.322 13.897-21.212 37.076-29.293c2.813-.98 5.757-1.905 8.812-2.773c3.204 10.42 7.406 21.315 12.477 32.332c-5.137 11.18-9.399 22.249-12.634 32.792a134.718 134.718 0 0 1-6.318-1.979Zm12.378-84.26c-4.811-24.587-1.616-43.134 6.425-47.789c8.564-4.958 27.502 2.111 47.463 19.835a144.318 144.318 0 0 1 3.841 3.545c-7.438 7.987-14.787 17.08-21.808 26.988c-12.04 1.116-23.565 2.908-34.161 5.309a160.342 160.342 0 0 1-1.76-7.887Zm110.427 27.268a347.8 347.8 0 0 0-7.785-12.803c8.168 1.033 15.994 2.404 23.343 4.08c-2.206 7.072-4.956 14.465-8.193 22.045a381.151 381.151 0 0 0-7.365-13.322Zm-45.032-43.861c5.044 5.465 10.096 11.566 15.065 18.186a322.04 322.04 0 0 0-30.257-.006c4.974-6.559 10.069-12.652 15.192-18.18ZM82.802 87.83a323.167 323.167 0 0 0-7.227 13.238c-3.184-7.553-5.909-14.98-8.134-22.152c7.304-1.634 15.093-2.97 23.209-3.984a321.524 321.524 0 0 0-7.848 12.897Zm8.081 65.352c-8.385-.936-16.291-2.203-23.593-3.793c2.26-7.3 5.045-14.885 8.298-22.6a321.187 321.187 0 0 0 7.257 13.246c2.594 4.48 5.28 8.868 8.038 13.147Zm37.542 31.03c-5.184-5.592-10.354-11.779-15.403-18.433c4.902.192 9.899.29 14.978.29c5.218 0 10.376-.117 15.453-.343c-4.985 6.774-10.018 12.97-15.028 18.486Zm52.198-57.817c3.422 7.8 6.306 15.345 8.596 22.52c-7.422 1.694-15.436 3.058-23.88 4.071a382.417 382.417 0 0 0 7.859-13.026a347.403 347.403 0 0 0 7.425-13.565Zm-16.898 8.101a358.557 358.557 0 0 1-12.281 19.815a329.4 329.4 0 0 1-23.444.823c-7.967 0-15.716-.248-23.178-.732a310.202 310.202 0 0 1-12.513-19.846h.001a307.41 307.41 0 0 1-10.923-20.627a310.278 310.278 0 0 1 10.89-20.637l-.001.001a307.318 307.318 0 0 1 12.413-19.761c7.613-.576 15.42-.876 23.31-.876H128c7.926 0 15.743.303 23.354.883a329.357 329.357 0 0 1 12.335 19.695a358.489 358.489 0 0 1 11.036 20.54a329.472 329.472 0 0 1-11 20.722Zm22.56-122.124c8.572 4.944 11.906 24.881 6.52 51.026c-.344 1.668-.73 3.367-1.15 5.09c-10.622-2.452-22.155-4.275-34.23-5.408c-7.034-10.017-14.323-19.124-21.64-27.008a160.789 160.789 0 0 1 5.888-5.4c18.9-16.447 36.564-22.941 44.612-18.3ZM128 90.808c12.625 0 22.86 10.235 22.86 22.86s-10.235 22.86-22.86 22.86s-22.86-10.235-22.86-22.86s10.235-22.86 22.86-22.86Z"></path></svg>
|
||||
|
After Width: | Height: | Size: 4.0 KiB |
249
src/components/GuideView.tsx
Normal file
249
src/components/GuideView.tsx
Normal file
@ -0,0 +1,249 @@
|
||||
import { openUrl } from "@tauri-apps/plugin-opener";
|
||||
import { useStore } from "../store";
|
||||
import { SectionItem, QuestItem } from "../types";
|
||||
|
||||
export default function GuideView() {
|
||||
const { activeGuideData, completedQuests, toggleQuest } = useStore();
|
||||
|
||||
if (!activeGuideData) return null;
|
||||
|
||||
const { name, effect, recommended_level, resources, sections } = activeGuideData;
|
||||
|
||||
const allQuests = collectAllQuests(sections);
|
||||
const completedCount = allQuests.filter(q => completedQuests.has(q)).length;
|
||||
const pct = allQuests.length > 0 ? Math.round((completedCount / allQuests.length) * 100) : 0;
|
||||
|
||||
return (
|
||||
<div style={{ flex: 1, display: "flex", overflow: "hidden" }}>
|
||||
{/* Main quest list */}
|
||||
<div style={{ flex: 1, overflowY: "auto", padding: "20px 24px" }}>
|
||||
{/* Guide header */}
|
||||
<div style={{ marginBottom: "20px" }}>
|
||||
<h1 style={{ fontSize: "20px", fontWeight: 700, color: "#f0c040", marginBottom: "4px" }}>
|
||||
{name}
|
||||
</h1>
|
||||
<div style={{ display: "flex", gap: "16px", alignItems: "center", marginBottom: "10px" }}>
|
||||
{recommended_level && (
|
||||
<span style={{
|
||||
fontSize: "11px", background: "rgba(74,158,255,0.15)", color: "#4a9eff",
|
||||
border: "1px solid rgba(74,158,255,0.3)", borderRadius: "4px", padding: "2px 8px",
|
||||
}}>
|
||||
Niveau recommandé : {recommended_level}
|
||||
</span>
|
||||
)}
|
||||
<span style={{ fontSize: "11px", color: "#94a3b8" }}>
|
||||
{completedCount}/{allQuests.length} quêtes · {pct}%
|
||||
</span>
|
||||
</div>
|
||||
{/* Progress bar */}
|
||||
<div style={{ height: "4px", background: "#2d3748", borderRadius: "2px", overflow: "hidden" }}>
|
||||
<div style={{
|
||||
height: "100%", width: `${pct}%`,
|
||||
background: pct === 100 ? "#4ade80" : "linear-gradient(90deg, #4a9eff, #f0c040)",
|
||||
borderRadius: "2px", transition: "width 0.3s ease",
|
||||
}} />
|
||||
</div>
|
||||
{effect && (
|
||||
<div style={{
|
||||
marginTop: "10px", background: "rgba(240,192,64,0.05)",
|
||||
border: "1px solid rgba(240,192,64,0.2)", borderRadius: "6px",
|
||||
padding: "8px 12px", fontSize: "11px", color: "#94a3b8", lineHeight: 1.5,
|
||||
}}>
|
||||
<span style={{ color: "#f0c040", fontWeight: 600 }}>Effet : </span>
|
||||
{effect}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Sections */}
|
||||
{sections.map((section, si) => (
|
||||
<div key={si} style={{ marginBottom: "20px" }}>
|
||||
<h2 style={{
|
||||
fontSize: "11px", fontWeight: 600, color: "#4a5568",
|
||||
textTransform: "uppercase", letterSpacing: "0.1em",
|
||||
marginBottom: "8px", borderBottom: "1px solid #2d3748", paddingBottom: "4px",
|
||||
}}>
|
||||
{section.name}
|
||||
</h2>
|
||||
{section.items.map((item, ii) => (
|
||||
<SectionItemView key={ii} item={item} completedQuests={completedQuests} onToggle={toggleQuest} />
|
||||
))}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{/* Resources panel */}
|
||||
{resources.length > 0 && (
|
||||
<div style={{
|
||||
width: "200px", flexShrink: 0, background: "#161b22",
|
||||
borderLeft: "1px solid #2d3748", overflowY: "auto", padding: "16px 14px",
|
||||
}}>
|
||||
<h3 style={{
|
||||
fontSize: "11px", fontWeight: 600, color: "#4a5568",
|
||||
textTransform: "uppercase", letterSpacing: "0.1em", marginBottom: "10px",
|
||||
}}>
|
||||
Ressources
|
||||
</h3>
|
||||
{resources.map((r, i) => (
|
||||
<div key={i} style={{
|
||||
display: "flex", justifyContent: "space-between", alignItems: "center",
|
||||
padding: "4px 0", borderBottom: "1px solid #1f2937",
|
||||
fontSize: "11px",
|
||||
}}>
|
||||
<span style={{ color: "#94a3b8", flex: 1, marginRight: "8px" }}>{r.name}</span>
|
||||
<span style={{ color: "#f0c040", fontWeight: 700, flexShrink: 0 }}>×{r.quantity}</span>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function SectionItemView({ item, completedQuests, onToggle }: {
|
||||
item: SectionItem;
|
||||
completedQuests: Set<string>;
|
||||
onToggle: (name: string) => void;
|
||||
}) {
|
||||
if (item.type === "Instruction") {
|
||||
if (item.text.startsWith("__ZONE__:")) {
|
||||
const zone = item.text.replace("__ZONE__:", "");
|
||||
return (
|
||||
<div style={{
|
||||
display: "flex", alignItems: "center", gap: "8px",
|
||||
padding: "8px 0 4px", marginBottom: "2px",
|
||||
}}>
|
||||
<div style={{ flex: 1, height: "1px", background: "#2d3748" }} />
|
||||
<span style={{ fontSize: "11px", color: "#4a9eff", fontWeight: 600, flexShrink: 0 }}>{zone}</span>
|
||||
<div style={{ flex: 1, height: "1px", background: "#2d3748" }} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
return (
|
||||
<div style={{
|
||||
background: "rgba(74,158,255,0.05)", border: "1px solid rgba(74,158,255,0.15)",
|
||||
borderRadius: "6px", padding: "8px 12px", marginBottom: "4px",
|
||||
fontSize: "11px", color: "#94a3b8", lineHeight: 1.5,
|
||||
}}>
|
||||
ℹ️ {item.text}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (item.type === "Group") {
|
||||
return (
|
||||
<div style={{
|
||||
background: "rgba(255,255,255,0.02)", border: "1px solid #2d3748",
|
||||
borderRadius: "6px", padding: "8px 10px", marginBottom: "6px",
|
||||
}}>
|
||||
{item.note && (
|
||||
<div style={{
|
||||
fontSize: "10px", color: "#4a9eff", marginBottom: "6px",
|
||||
fontStyle: "italic",
|
||||
}}>
|
||||
🔗 {item.note}
|
||||
</div>
|
||||
)}
|
||||
{item.quests.map((q, i) => (
|
||||
<QuestRow key={i} quest={q} indent completed={completedQuests.has(q.name)} onToggle={onToggle} />
|
||||
))}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
if (item.type === "Quest") {
|
||||
return <QuestRow quest={item} completed={completedQuests.has(item.name)} onToggle={onToggle} />;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
function QuestRow({ quest, completed, onToggle, indent }: {
|
||||
quest: QuestItem;
|
||||
completed: boolean;
|
||||
onToggle: (name: string) => void;
|
||||
indent?: boolean;
|
||||
}) {
|
||||
return (
|
||||
<div
|
||||
onClick={() => onToggle(quest.name)}
|
||||
style={{
|
||||
display: "flex", alignItems: "flex-start", gap: "8px",
|
||||
padding: indent ? "4px 0" : "5px 6px",
|
||||
borderRadius: "5px", cursor: "pointer",
|
||||
marginBottom: indent ? "2px" : "3px",
|
||||
opacity: completed ? 0.6 : 1,
|
||||
transition: "all 0.12s",
|
||||
}}
|
||||
onMouseEnter={e => {
|
||||
(e.currentTarget as HTMLElement).style.background = "rgba(255,255,255,0.04)";
|
||||
}}
|
||||
onMouseLeave={e => {
|
||||
(e.currentTarget as HTMLElement).style.background = "transparent";
|
||||
}}
|
||||
>
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={completed}
|
||||
onChange={() => onToggle(quest.name)}
|
||||
onClick={e => e.stopPropagation()}
|
||||
style={{ marginTop: "2px", flexShrink: 0 }}
|
||||
/>
|
||||
<div style={{ flex: 1, minWidth: 0 }}>
|
||||
<div style={{ display: "flex", alignItems: "center", gap: "5px", flexWrap: "wrap" }}>
|
||||
<span style={{
|
||||
fontSize: "12px", color: completed ? "#4a5568" : "#e2e8f0",
|
||||
textDecoration: completed ? "line-through" : "none",
|
||||
lineHeight: 1.4,
|
||||
}}>
|
||||
{quest.name}
|
||||
</span>
|
||||
{quest.url && (
|
||||
<span
|
||||
title="Voir sur Dofus Pour Les Noobs"
|
||||
onClick={e => { e.stopPropagation(); openUrl(quest.url!); }}
|
||||
style={{
|
||||
fontSize: "10px", color: "#4a9eff", cursor: "pointer",
|
||||
opacity: 0.7, flexShrink: 0, lineHeight: 1,
|
||||
}}
|
||||
onMouseEnter={e => (e.currentTarget as HTMLElement).style.opacity = "1"}
|
||||
onMouseLeave={e => (e.currentTarget as HTMLElement).style.opacity = "0.7"}
|
||||
>
|
||||
🔗
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
{quest.combat_indicators.length > 0 && (
|
||||
<div style={{ display: "flex", flexWrap: "wrap", gap: "3px", marginTop: "3px" }}>
|
||||
{quest.combat_indicators.map((ci, i) => (
|
||||
<span key={i} style={{
|
||||
fontSize: "9px", padding: "1px 5px",
|
||||
background: "rgba(74,158,255,0.15)", color: "#4a9eff",
|
||||
border: "1px solid rgba(74,158,255,0.25)", borderRadius: "3px",
|
||||
}}>
|
||||
{ci.combat_type} {ci.count}
|
||||
</span>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
{quest.note && (
|
||||
<div style={{ fontSize: "10px", color: "#94a3b8", marginTop: "2px", fontStyle: "italic" }}>
|
||||
→ {quest.note}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function collectAllQuests(sections: import("../types").Section[] | undefined): string[] {
|
||||
if (!sections) return [];
|
||||
const names: string[] = [];
|
||||
for (const section of sections) {
|
||||
for (const item of section.items) {
|
||||
if (item.type === "Quest") names.push(item.name);
|
||||
else if (item.type === "Group") item.quests.forEach((q: import("../types").QuestItem) => names.push(q.name));
|
||||
}
|
||||
}
|
||||
return names;
|
||||
}
|
||||
148
src/components/HomeView.tsx
Normal file
148
src/components/HomeView.tsx
Normal file
@ -0,0 +1,148 @@
|
||||
import { useStore } from "../store";
|
||||
|
||||
export default function HomeView() {
|
||||
const { guides, openGuide, profiles, activeProfileId } = useStore();
|
||||
|
||||
const activeProfile = profiles.find(p => p.id === activeProfileId);
|
||||
|
||||
const totalQuests = guides.reduce((s, g) => s + g.total_quests, 0);
|
||||
const totalCompleted = guides.reduce((s, g) => s + g.completed_quests, 0);
|
||||
const globalPct = totalQuests > 0 ? Math.round((totalCompleted / totalQuests) * 100) : 0;
|
||||
|
||||
const completedGuides = guides.filter(g => g.total_quests > 0 && g.completed_quests === g.total_quests);
|
||||
const inProgressGuides = guides.filter(g => g.completed_quests > 0 && g.completed_quests < g.total_quests);
|
||||
|
||||
return (
|
||||
<div style={{ flex: 1, overflowY: "auto", padding: "20px 24px" }}>
|
||||
{/* Header */}
|
||||
<div style={{ marginBottom: "24px" }}>
|
||||
<h1 style={{ fontSize: "18px", fontWeight: 700, color: "#f0c040", marginBottom: "4px" }}>
|
||||
Tougli — Guide Dofus
|
||||
</h1>
|
||||
{activeProfile && (
|
||||
<p style={{ fontSize: "13px", color: "#94a3b8" }}>
|
||||
Profil actif : <span style={{ color: "#e2e8f0", fontWeight: 600 }}>{activeProfile.name}</span>
|
||||
</p>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Global progress */}
|
||||
{guides.length > 0 && (
|
||||
<div style={{
|
||||
background: "#161b22", border: "1px solid #2d3748", borderRadius: "10px",
|
||||
padding: "16px 20px", marginBottom: "24px",
|
||||
}}>
|
||||
<div style={{ display: "flex", justifyContent: "space-between", marginBottom: "8px" }}>
|
||||
<span style={{ fontSize: "13px", color: "#94a3b8" }}>Progression globale</span>
|
||||
<span style={{ fontSize: "13px", fontWeight: 700, color: "#f0c040" }}>
|
||||
{totalCompleted} / {totalQuests} quêtes ({globalPct}%)
|
||||
</span>
|
||||
</div>
|
||||
<div style={{ height: "6px", background: "#2d3748", borderRadius: "3px", overflow: "hidden" }}>
|
||||
<div style={{
|
||||
height: "100%", width: `${globalPct}%`,
|
||||
background: "linear-gradient(90deg, #4a9eff, #f0c040)",
|
||||
borderRadius: "3px", transition: "width 0.4s ease",
|
||||
}} />
|
||||
</div>
|
||||
<div style={{ marginTop: "8px", display: "flex", gap: "16px" }}>
|
||||
<Stat label="Complétés" value={completedGuides.length} color="#4ade80" />
|
||||
<Stat label="En cours" value={inProgressGuides.length} color="#f0c040" />
|
||||
<Stat label="Total" value={guides.length} color="#94a3b8" />
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* In progress first */}
|
||||
{inProgressGuides.length > 0 && (
|
||||
<Section title="En cours" guides={inProgressGuides} onOpen={openGuide} />
|
||||
)}
|
||||
|
||||
{/* All guides grid */}
|
||||
<Section title="Tous les guides" guides={guides} onOpen={openGuide} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function Stat({ label, value, color }: { label: string; value: number; color: string }) {
|
||||
return (
|
||||
<div style={{ display: "flex", flexDirection: "column", gap: "2px" }}>
|
||||
<span style={{ fontSize: "16px", fontWeight: 700, color }}>{value}</span>
|
||||
<span style={{ fontSize: "11px", color: "#4a5568" }}>{label}</span>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function Section({ title, guides, onOpen }: {
|
||||
title: string;
|
||||
guides: import("../types").GuideListItem[];
|
||||
onOpen: (gid: string) => void;
|
||||
}) {
|
||||
return (
|
||||
<div style={{ marginBottom: "24px" }}>
|
||||
<h2 style={{ fontSize: "12px", fontWeight: 600, color: "#4a5568", textTransform: "uppercase", letterSpacing: "0.1em", marginBottom: "10px" }}>
|
||||
{title}
|
||||
</h2>
|
||||
<div style={{
|
||||
display: "grid", gridTemplateColumns: "repeat(auto-fill, minmax(180px, 1fr))", gap: "8px",
|
||||
}}>
|
||||
{guides.map(guide => <GuideCard key={guide.gid} guide={guide} onOpen={onOpen} />)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function GuideCard({ guide, onOpen }: {
|
||||
guide: import("../types").GuideListItem;
|
||||
onOpen: (gid: string) => void;
|
||||
}) {
|
||||
const pct = guide.total_quests > 0
|
||||
? Math.round((guide.completed_quests / guide.total_quests) * 100)
|
||||
: 0;
|
||||
const isDone = pct === 100 && guide.total_quests > 0;
|
||||
|
||||
return (
|
||||
<button
|
||||
onClick={() => onOpen(guide.gid)}
|
||||
style={{
|
||||
background: isDone ? "rgba(74,222,128,0.05)" : "#161b22",
|
||||
border: `1px solid ${isDone ? "rgba(74,222,128,0.3)" : "#2d3748"}`,
|
||||
borderRadius: "8px", padding: "12px 14px", cursor: "pointer",
|
||||
textAlign: "left", transition: "all 0.15s",
|
||||
}}
|
||||
onMouseEnter={e => {
|
||||
(e.currentTarget as HTMLElement).style.borderColor = isDone ? "rgba(74,222,128,0.6)" : "#f0c040";
|
||||
(e.currentTarget as HTMLElement).style.background = isDone ? "rgba(74,222,128,0.08)" : "#1a2233";
|
||||
}}
|
||||
onMouseLeave={e => {
|
||||
(e.currentTarget as HTMLElement).style.borderColor = isDone ? "rgba(74,222,128,0.3)" : "#2d3748";
|
||||
(e.currentTarget as HTMLElement).style.background = isDone ? "rgba(74,222,128,0.05)" : "#161b22";
|
||||
}}
|
||||
>
|
||||
<div style={{ display: "flex", justifyContent: "space-between", alignItems: "flex-start", marginBottom: "8px" }}>
|
||||
<span style={{
|
||||
fontSize: "12px", fontWeight: 600, color: isDone ? "#4ade80" : "#e2e8f0",
|
||||
lineHeight: 1.3,
|
||||
}}>
|
||||
{guide.name}
|
||||
</span>
|
||||
{isDone && <span style={{ fontSize: "14px" }}>✓</span>}
|
||||
</div>
|
||||
<div style={{ height: "3px", background: "#2d3748", borderRadius: "2px", overflow: "hidden", marginBottom: "6px" }}>
|
||||
<div style={{
|
||||
height: "100%", width: `${pct}%`,
|
||||
background: isDone ? "#4ade80" : pct > 60 ? "#f0c040" : "#4a9eff",
|
||||
borderRadius: "2px",
|
||||
}} />
|
||||
</div>
|
||||
<div style={{ display: "flex", justifyContent: "space-between" }}>
|
||||
<span style={{ fontSize: "10px", color: "#4a5568" }}>
|
||||
{guide.completed_quests}/{guide.total_quests} quêtes
|
||||
</span>
|
||||
<span style={{ fontSize: "10px", fontWeight: 700, color: isDone ? "#4ade80" : "#94a3b8" }}>
|
||||
{pct}%
|
||||
</span>
|
||||
</div>
|
||||
</button>
|
||||
);
|
||||
}
|
||||
118
src/components/ProfileModal.tsx
Normal file
118
src/components/ProfileModal.tsx
Normal file
@ -0,0 +1,118 @@
|
||||
import { useState } from "react";
|
||||
import { useStore } from "../store";
|
||||
|
||||
export default function ProfileModal({ onClose }: { onClose: () => void }) {
|
||||
const { profiles, activeProfileId, setActiveProfile, createProfile, deleteProfile } = useStore();
|
||||
const [newName, setNewName] = useState("");
|
||||
const [error, setError] = useState("");
|
||||
|
||||
async function handleCreate() {
|
||||
const name = newName.trim();
|
||||
if (!name) return;
|
||||
if (profiles.find(p => p.name === name)) {
|
||||
setError("Un profil avec ce nom existe déjà.");
|
||||
return;
|
||||
}
|
||||
await createProfile(name);
|
||||
setNewName("");
|
||||
setError("");
|
||||
}
|
||||
|
||||
async function handleDelete(id: string) {
|
||||
if (profiles.length <= 1) {
|
||||
setError("Vous ne pouvez pas supprimer le dernier profil.");
|
||||
return;
|
||||
}
|
||||
await deleteProfile(id);
|
||||
}
|
||||
|
||||
return (
|
||||
<div style={{
|
||||
position: "fixed", inset: 0, background: "rgba(0,0,0,0.7)",
|
||||
display: "flex", alignItems: "center", justifyContent: "center", zIndex: 50,
|
||||
}} onClick={e => { if (e.target === e.currentTarget) onClose(); }}>
|
||||
<div style={{
|
||||
background: "#161b22", border: "1px solid #2d3748", borderRadius: "12px",
|
||||
padding: "24px", width: "360px", maxHeight: "500px",
|
||||
display: "flex", flexDirection: "column", gap: "16px",
|
||||
}}>
|
||||
<div style={{ display: "flex", justifyContent: "space-between", alignItems: "center" }}>
|
||||
<h2 style={{ fontSize: "16px", fontWeight: 700, color: "#f0c040" }}>Profils</h2>
|
||||
<button onClick={onClose} style={{ background: "none", border: "none", color: "#94a3b8", cursor: "pointer", fontSize: "16px" }}>✕</button>
|
||||
</div>
|
||||
|
||||
{/* Profile list */}
|
||||
<div style={{ flex: 1, overflowY: "auto", display: "flex", flexDirection: "column", gap: "6px" }}>
|
||||
{profiles.map(profile => (
|
||||
<div key={profile.id} style={{
|
||||
display: "flex", alignItems: "center", gap: "8px",
|
||||
background: profile.id === activeProfileId ? "rgba(240,192,64,0.08)" : "#1a2233",
|
||||
border: `1px solid ${profile.id === activeProfileId ? "rgba(240,192,64,0.4)" : "#2d3748"}`,
|
||||
borderRadius: "8px", padding: "10px 12px",
|
||||
}}>
|
||||
<button
|
||||
onClick={() => { setActiveProfile(profile.id); onClose(); }}
|
||||
style={{
|
||||
flex: 1, background: "none", border: "none", textAlign: "left",
|
||||
cursor: "pointer",
|
||||
}}
|
||||
>
|
||||
<div style={{ fontSize: "13px", fontWeight: 600, color: profile.id === activeProfileId ? "#f0c040" : "#e2e8f0" }}>
|
||||
{profile.id === activeProfileId && "✓ "}{profile.name}
|
||||
</div>
|
||||
<div style={{ fontSize: "10px", color: "#4a5568", marginTop: "2px" }}>
|
||||
Créé le {new Date(profile.created_at).toLocaleDateString("fr-FR")}
|
||||
</div>
|
||||
</button>
|
||||
{profiles.length > 1 && (
|
||||
<button
|
||||
onClick={() => handleDelete(profile.id)}
|
||||
style={{
|
||||
background: "none", border: "none", color: "#f87171",
|
||||
cursor: "pointer", padding: "4px", borderRadius: "4px", fontSize: "12px",
|
||||
}}
|
||||
title="Supprimer ce profil"
|
||||
>
|
||||
🗑
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
|
||||
{/* Create new profile */}
|
||||
<div style={{ borderTop: "1px solid #2d3748", paddingTop: "12px" }}>
|
||||
<p style={{ fontSize: "11px", color: "#4a5568", marginBottom: "8px" }}>Nouveau profil</p>
|
||||
<div style={{ display: "flex", gap: "8px" }}>
|
||||
<input
|
||||
value={newName}
|
||||
onChange={e => { setNewName(e.target.value); setError(""); }}
|
||||
onKeyDown={e => e.key === "Enter" && handleCreate()}
|
||||
placeholder="Nom du profil…"
|
||||
style={{
|
||||
flex: 1, background: "#0d1117", border: "1px solid #2d3748",
|
||||
borderRadius: "6px", padding: "7px 10px", color: "#e2e8f0",
|
||||
fontSize: "12px", outline: "none",
|
||||
}}
|
||||
onFocus={e => (e.target.style.borderColor = "#f0c040")}
|
||||
onBlur={e => (e.target.style.borderColor = "#2d3748")}
|
||||
/>
|
||||
<button
|
||||
onClick={handleCreate}
|
||||
disabled={!newName.trim()}
|
||||
style={{
|
||||
background: "#f0c040", color: "#0d1117", border: "none",
|
||||
borderRadius: "6px", padding: "7px 14px", fontWeight: 700,
|
||||
fontSize: "12px", cursor: newName.trim() ? "pointer" : "default",
|
||||
opacity: newName.trim() ? 1 : 0.4,
|
||||
}}
|
||||
>
|
||||
Créer
|
||||
</button>
|
||||
</div>
|
||||
{error && <p style={{ fontSize: "11px", color: "#f87171", marginTop: "6px" }}>{error}</p>}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
94
src/components/Sidebar.tsx
Normal file
94
src/components/Sidebar.tsx
Normal file
@ -0,0 +1,94 @@
|
||||
import { useState } from "react";
|
||||
import { useStore } from "../store";
|
||||
|
||||
export default function Sidebar() {
|
||||
const { guides, openGuide, activeGuideGid, view } = useStore();
|
||||
const [search, setSearch] = useState("");
|
||||
|
||||
const filtered = guides.filter(g =>
|
||||
g.name.toLowerCase().includes(search.toLowerCase())
|
||||
);
|
||||
|
||||
return (
|
||||
<aside style={{
|
||||
width: "220px", flexShrink: 0,
|
||||
background: "#161b22", borderRight: "1px solid #2d3748",
|
||||
display: "flex", flexDirection: "column", overflow: "hidden",
|
||||
}}>
|
||||
<div style={{ padding: "10px 12px", borderBottom: "1px solid #2d3748" }}>
|
||||
<input
|
||||
value={search}
|
||||
onChange={e => setSearch(e.target.value)}
|
||||
placeholder="Rechercher un Dofus…"
|
||||
style={{
|
||||
width: "100%", background: "#0d1117", border: "1px solid #2d3748",
|
||||
borderRadius: "6px", padding: "6px 10px", color: "#e2e8f0",
|
||||
fontSize: "12px", outline: "none",
|
||||
}}
|
||||
onFocus={e => (e.target.style.borderColor = "#f0c040")}
|
||||
onBlur={e => (e.target.style.borderColor = "#2d3748")}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div style={{ flex: 1, overflowY: "auto", padding: "8px 0" }}>
|
||||
{filtered.length === 0 ? (
|
||||
<div style={{ padding: "16px 12px", color: "#4a5568", fontSize: "12px", textAlign: "center" }}>
|
||||
Aucun guide synchronisé
|
||||
</div>
|
||||
) : (
|
||||
filtered.map(guide => {
|
||||
const pct = guide.total_quests > 0
|
||||
? Math.round((guide.completed_quests / guide.total_quests) * 100)
|
||||
: 0;
|
||||
const isActive = guide.gid === activeGuideGid && view === "guide";
|
||||
|
||||
return (
|
||||
<button
|
||||
key={guide.gid}
|
||||
onClick={() => openGuide(guide.gid)}
|
||||
style={{
|
||||
width: "100%", textAlign: "left", background: isActive ? "rgba(240,192,64,0.08)" : "transparent",
|
||||
border: "none", borderLeft: isActive ? "2px solid #f0c040" : "2px solid transparent",
|
||||
padding: "8px 12px", cursor: "pointer", transition: "all 0.12s",
|
||||
}}
|
||||
onMouseEnter={e => {
|
||||
if (!isActive) (e.currentTarget as HTMLElement).style.background = "rgba(255,255,255,0.03)";
|
||||
}}
|
||||
onMouseLeave={e => {
|
||||
if (!isActive) (e.currentTarget as HTMLElement).style.background = "transparent";
|
||||
}}
|
||||
>
|
||||
<div style={{ display: "flex", justifyContent: "space-between", alignItems: "center" }}>
|
||||
<span style={{
|
||||
fontSize: "12px", fontWeight: isActive ? 600 : 400,
|
||||
color: isActive ? "#f0c040" : "#e2e8f0",
|
||||
whiteSpace: "nowrap", overflow: "hidden", textOverflow: "ellipsis",
|
||||
maxWidth: "140px",
|
||||
}}>
|
||||
{guide.name}
|
||||
</span>
|
||||
<span style={{
|
||||
fontSize: "10px", color: pct === 100 ? "#4ade80" : "#94a3b8",
|
||||
fontWeight: 600, flexShrink: 0,
|
||||
}}>
|
||||
{pct}%
|
||||
</span>
|
||||
</div>
|
||||
<div style={{
|
||||
marginTop: "4px", height: "2px", background: "#2d3748",
|
||||
borderRadius: "1px", overflow: "hidden",
|
||||
}}>
|
||||
<div style={{
|
||||
height: "100%", width: `${pct}%`,
|
||||
background: pct === 100 ? "#4ade80" : pct > 50 ? "#f0c040" : "#4a9eff",
|
||||
transition: "width 0.3s ease",
|
||||
}} />
|
||||
</div>
|
||||
</button>
|
||||
);
|
||||
})
|
||||
)}
|
||||
</div>
|
||||
</aside>
|
||||
);
|
||||
}
|
||||
47
src/components/SyncOverlay.tsx
Normal file
47
src/components/SyncOverlay.tsx
Normal file
@ -0,0 +1,47 @@
|
||||
import { useStore } from "../store";
|
||||
|
||||
export default function SyncOverlay() {
|
||||
const { syncProgress } = useStore();
|
||||
const { current = 0, total = 29, label = "…" } = syncProgress ?? {};
|
||||
const pct = total > 0 ? Math.round((current / total) * 100) : 0;
|
||||
|
||||
return (
|
||||
<div style={{
|
||||
position: "fixed", inset: 0, background: "rgba(0,0,0,0.6)",
|
||||
display: "flex", alignItems: "center", justifyContent: "center",
|
||||
zIndex: 200, borderRadius: "10px",
|
||||
}}>
|
||||
<div style={{
|
||||
background: "#161b22", border: "1px solid #2d3748", borderRadius: "12px",
|
||||
padding: "28px 40px", display: "flex", flexDirection: "column",
|
||||
alignItems: "center", gap: "14px", minWidth: "320px",
|
||||
}}>
|
||||
<div style={{ fontSize: "28px", animation: "spin 1s linear infinite" }}>↻</div>
|
||||
|
||||
<div style={{ width: "100%", textAlign: "center" }}>
|
||||
<p style={{ fontSize: "14px", fontWeight: 600, color: "#e2e8f0", marginBottom: "4px" }}>
|
||||
Synchronisation en cours…
|
||||
</p>
|
||||
<p style={{ fontSize: "12px", color: "#94a3b8" }}>
|
||||
{current}/{total} — <span style={{ color: "#f0c040" }}>{label}</span>
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* Progress bar */}
|
||||
<div style={{ width: "100%", height: "4px", background: "#2d3748", borderRadius: "2px", overflow: "hidden" }}>
|
||||
<div style={{
|
||||
height: "100%",
|
||||
width: `${pct}%`,
|
||||
background: "linear-gradient(90deg, #4a9eff, #f0c040)",
|
||||
borderRadius: "2px",
|
||||
transition: "width 0.3s ease",
|
||||
}} />
|
||||
</div>
|
||||
|
||||
<p style={{ fontSize: "11px", color: "#4a5568" }}>
|
||||
{pct}% — Google Sheets CSV
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
141
src/components/TitleBar.tsx
Normal file
141
src/components/TitleBar.tsx
Normal file
@ -0,0 +1,141 @@
|
||||
import { getCurrentWindow } from "@tauri-apps/api/window";
|
||||
import { useStore } from "../store";
|
||||
|
||||
interface Props {
|
||||
onOpenProfiles: () => void;
|
||||
}
|
||||
|
||||
export default function TitleBar({ onOpenProfiles }: Props) {
|
||||
const { alwaysOnTop, toggleAlwaysOnTop, syncing, syncGuides, view, closeGuide, activeGuideData } = useStore();
|
||||
|
||||
function handleDragMouseDown(e: React.MouseEvent) {
|
||||
if (e.button === 0) {
|
||||
getCurrentWindow().startDragging();
|
||||
}
|
||||
}
|
||||
|
||||
async function handleClose() {
|
||||
await getCurrentWindow().close();
|
||||
}
|
||||
|
||||
async function handleMinimize() {
|
||||
await getCurrentWindow().minimize();
|
||||
}
|
||||
|
||||
return (
|
||||
<div
|
||||
style={{
|
||||
display: "flex", alignItems: "center", height: "40px",
|
||||
background: "#0d1117", borderBottom: "1px solid #2d3748",
|
||||
padding: "0 12px", gap: "8px", flexShrink: 0,
|
||||
userSelect: "none",
|
||||
}}
|
||||
>
|
||||
{/* Zone draggable — appel direct à startDragging() */}
|
||||
<div
|
||||
onMouseDown={handleDragMouseDown}
|
||||
style={{
|
||||
display: "flex", alignItems: "center", gap: "8px", flex: 1,
|
||||
cursor: "grab", userSelect: "none",
|
||||
}}
|
||||
>
|
||||
<img src="/logo_tougli.png" style={{ pointerEvents: "none", width: "24px", height: "24px", objectFit: "contain" }} />
|
||||
<span style={{ pointerEvents: "none", fontSize: "13px", fontWeight: 700, color: "#f0c040", letterSpacing: "0.05em" }}>
|
||||
TougliGui
|
||||
</span>
|
||||
{view === "guide" && activeGuideData && (
|
||||
<>
|
||||
<span style={{ pointerEvents: "none", color: "#4a5568", fontSize: "12px" }}>›</span>
|
||||
<span style={{ pointerEvents: "none", fontSize: "12px", color: "#94a3b8" }}>{activeGuideData.name}</span>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Boutons — pas de drag, interactions normales */}
|
||||
<div style={{ display: "flex", alignItems: "center", gap: "4px" }}>
|
||||
{view === "guide" && (
|
||||
<TitleButton onClick={closeGuide} title="Retour à l'accueil">
|
||||
← Accueil
|
||||
</TitleButton>
|
||||
)}
|
||||
|
||||
<TitleButton onClick={onOpenProfiles} title="Gérer les profils">
|
||||
👤
|
||||
</TitleButton>
|
||||
|
||||
<TitleButton
|
||||
onClick={syncGuides}
|
||||
title="Synchroniser avec Google Sheets"
|
||||
disabled={syncing}
|
||||
>
|
||||
{syncing ? <SpinIcon /> : "↻"}
|
||||
</TitleButton>
|
||||
|
||||
<TitleButton
|
||||
onClick={toggleAlwaysOnTop}
|
||||
title={alwaysOnTop ? "Désactiver fenêtre flottante" : "Activer fenêtre flottante"}
|
||||
active={alwaysOnTop}
|
||||
>
|
||||
📌
|
||||
</TitleButton>
|
||||
|
||||
<div style={{ width: "1px", height: "16px", background: "#2d3748", margin: "0 4px" }} />
|
||||
|
||||
<TitleButton onClick={handleMinimize} title="Réduire">—</TitleButton>
|
||||
<TitleButton onClick={handleClose} title="Fermer" danger>✕</TitleButton>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function TitleButton({
|
||||
children, onClick, title, active, danger, disabled
|
||||
}: {
|
||||
children: React.ReactNode;
|
||||
onClick?: () => void;
|
||||
title?: string;
|
||||
active?: boolean;
|
||||
danger?: boolean;
|
||||
disabled?: boolean;
|
||||
}) {
|
||||
return (
|
||||
<button
|
||||
onClick={onClick}
|
||||
title={title}
|
||||
disabled={disabled}
|
||||
style={{
|
||||
background: active ? "rgba(240,192,64,0.15)" : "transparent",
|
||||
border: active ? "1px solid rgba(240,192,64,0.4)" : "1px solid transparent",
|
||||
color: active ? "#f0c040" : danger ? "#f87171" : "#94a3b8",
|
||||
padding: "3px 8px",
|
||||
borderRadius: "5px",
|
||||
cursor: disabled ? "default" : "pointer",
|
||||
fontSize: "12px",
|
||||
fontWeight: 500,
|
||||
transition: "all 0.15s",
|
||||
display: "flex", alignItems: "center", gap: "4px",
|
||||
opacity: disabled ? 0.5 : 1,
|
||||
}}
|
||||
onMouseEnter={e => {
|
||||
if (!disabled) {
|
||||
const el = e.currentTarget;
|
||||
el.style.background = active ? "rgba(240,192,64,0.25)" : danger ? "rgba(248,113,113,0.1)" : "rgba(255,255,255,0.05)";
|
||||
el.style.color = active ? "#f0c040" : danger ? "#f87171" : "#e2e8f0";
|
||||
}
|
||||
}}
|
||||
onMouseLeave={e => {
|
||||
const el = e.currentTarget;
|
||||
el.style.background = active ? "rgba(240,192,64,0.15)" : "transparent";
|
||||
el.style.color = active ? "#f0c040" : danger ? "#f87171" : "#94a3b8";
|
||||
}}
|
||||
>
|
||||
{children}
|
||||
</button>
|
||||
);
|
||||
}
|
||||
|
||||
function SpinIcon() {
|
||||
return (
|
||||
<span style={{ display: "inline-block", animation: "spin 1s linear infinite" }}>↻</span>
|
||||
);
|
||||
}
|
||||
108
src/index.css
Normal file
108
src/index.css
Normal file
@ -0,0 +1,108 @@
|
||||
@import "tailwindcss";
|
||||
|
||||
@theme {
|
||||
--color-bg-deep: #0d1117;
|
||||
--color-bg-surface: #161b22;
|
||||
--color-bg-elevated: #1f2937;
|
||||
--color-bg-card: #1a2233;
|
||||
--color-border: #2d3748;
|
||||
--color-border-bright: #4a5568;
|
||||
|
||||
--color-gold: #f0c040;
|
||||
--color-gold-dim: #b8922e;
|
||||
--color-gold-bg: #2a1f00;
|
||||
|
||||
--color-blue-dofus: #4a9eff;
|
||||
--color-blue-dim: #2563eb;
|
||||
|
||||
--color-green: #4ade80;
|
||||
--color-green-dim: #166534;
|
||||
|
||||
--color-red: #f87171;
|
||||
--color-red-dim: #7f1d1d;
|
||||
|
||||
--color-text-primary: #e2e8f0;
|
||||
--color-text-secondary: #94a3b8;
|
||||
--color-text-muted: #4a5568;
|
||||
}
|
||||
|
||||
* {
|
||||
box-sizing: border-box;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
html, body, #root {
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
overflow: hidden;
|
||||
font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
|
||||
}
|
||||
|
||||
body {
|
||||
background: transparent;
|
||||
color: var(--color-text-primary);
|
||||
user-select: none;
|
||||
}
|
||||
|
||||
/* Custom scrollbar */
|
||||
::-webkit-scrollbar {
|
||||
width: 6px;
|
||||
height: 6px;
|
||||
}
|
||||
::-webkit-scrollbar-track {
|
||||
background: var(--color-bg-deep);
|
||||
}
|
||||
::-webkit-scrollbar-thumb {
|
||||
background: var(--color-border-bright);
|
||||
border-radius: 3px;
|
||||
}
|
||||
::-webkit-scrollbar-thumb:hover {
|
||||
background: var(--color-gold-dim);
|
||||
}
|
||||
|
||||
/* Checkbox custom */
|
||||
input[type="checkbox"] {
|
||||
accent-color: var(--color-gold);
|
||||
width: 14px;
|
||||
height: 14px;
|
||||
cursor: pointer;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
/* Selection */
|
||||
::selection {
|
||||
background: rgba(240, 192, 64, 0.3);
|
||||
color: var(--color-text-primary);
|
||||
}
|
||||
|
||||
/* Animations */
|
||||
@keyframes fadeIn {
|
||||
from { opacity: 0; transform: translateY(4px); }
|
||||
to { opacity: 1; transform: translateY(0); }
|
||||
}
|
||||
|
||||
@keyframes spin {
|
||||
to { transform: rotate(360deg); }
|
||||
}
|
||||
|
||||
.animate-fade-in {
|
||||
animation: fadeIn 0.2s ease-out;
|
||||
}
|
||||
|
||||
.animate-spin {
|
||||
animation: spin 1s linear infinite;
|
||||
}
|
||||
|
||||
/* Drag region : Tauri gère ça via data-tauri-drag-region en JS natif */
|
||||
[data-tauri-drag-region] {
|
||||
cursor: grab;
|
||||
}
|
||||
|
||||
/* Gold gradient text */
|
||||
.text-gold-gradient {
|
||||
background: linear-gradient(135deg, #f0c040, #d4a017);
|
||||
-webkit-background-clip: text;
|
||||
-webkit-text-fill-color: transparent;
|
||||
background-clip: text;
|
||||
}
|
||||
9
src/main.tsx
Normal file
9
src/main.tsx
Normal file
@ -0,0 +1,9 @@
|
||||
import React from "react";
|
||||
import ReactDOM from "react-dom/client";
|
||||
import App from "./App";
|
||||
|
||||
ReactDOM.createRoot(document.getElementById("root") as HTMLElement).render(
|
||||
<React.StrictMode>
|
||||
<App />
|
||||
</React.StrictMode>,
|
||||
);
|
||||
142
src/store.ts
Normal file
142
src/store.ts
Normal file
@ -0,0 +1,142 @@
|
||||
import { create } from "zustand";
|
||||
import { invoke } from "@tauri-apps/api/core";
|
||||
import { Profile, GuideListItem, GuideData, SyncResult } from "./types";
|
||||
|
||||
interface AppState {
|
||||
profiles: Profile[];
|
||||
activeProfileId: string | null;
|
||||
guides: GuideListItem[];
|
||||
activeGuideGid: string | null;
|
||||
activeGuideData: GuideData | null;
|
||||
completedQuests: Set<string>;
|
||||
alwaysOnTop: boolean;
|
||||
syncing: boolean;
|
||||
syncProgress: { current: number; total: number; label: string } | null;
|
||||
view: "home" | "guide";
|
||||
|
||||
loadProfiles: () => Promise<void>;
|
||||
setActiveProfile: (id: string) => Promise<void>;
|
||||
createProfile: (name: string) => Promise<void>;
|
||||
deleteProfile: (id: string) => Promise<void>;
|
||||
|
||||
loadGuides: () => Promise<void>;
|
||||
openGuide: (gid: string) => Promise<void>;
|
||||
closeGuide: () => void;
|
||||
|
||||
toggleQuest: (questName: string) => Promise<void>;
|
||||
|
||||
syncGuides: () => Promise<SyncResult>;
|
||||
syncSingleGuide: (gid: string, name: string) => Promise<void>;
|
||||
toggleAlwaysOnTop: () => Promise<void>;
|
||||
}
|
||||
|
||||
export const useStore = create<AppState>((set, get) => ({
|
||||
profiles: [],
|
||||
activeProfileId: null,
|
||||
guides: [],
|
||||
activeGuideGid: null,
|
||||
activeGuideData: null,
|
||||
completedQuests: new Set(),
|
||||
alwaysOnTop: true,
|
||||
syncing: false,
|
||||
syncProgress: null,
|
||||
view: "home",
|
||||
|
||||
loadProfiles: async () => {
|
||||
const profiles = await invoke<Profile[]>("get_profiles");
|
||||
const saved = await invoke<string | null>("get_setting", { key: "active_profile" });
|
||||
const activeId = saved && profiles.find(p => p.id === saved) ? saved : profiles[0]?.id ?? null;
|
||||
set({ profiles, activeProfileId: activeId });
|
||||
if (activeId) {
|
||||
const completed = await invoke<string[]>("get_completed_quests", { profileId: activeId });
|
||||
set({ completedQuests: new Set(completed) });
|
||||
}
|
||||
},
|
||||
|
||||
setActiveProfile: async (id) => {
|
||||
await invoke("set_setting", { key: "active_profile", value: id });
|
||||
const completed = await invoke<string[]>("get_completed_quests", { profileId: id });
|
||||
set({ activeProfileId: id, completedQuests: new Set(completed) });
|
||||
await get().loadGuides();
|
||||
},
|
||||
|
||||
createProfile: async (name) => {
|
||||
const profile = await invoke<Profile>("create_profile", { name });
|
||||
set(state => ({ profiles: [...state.profiles, profile] }));
|
||||
await get().setActiveProfile(profile.id);
|
||||
},
|
||||
|
||||
deleteProfile: async (id) => {
|
||||
await invoke("delete_profile", { profileId: id });
|
||||
const { profiles, activeProfileId } = get();
|
||||
const remaining = profiles.filter(p => p.id !== id);
|
||||
const newActive = activeProfileId === id ? remaining[0]?.id ?? null : activeProfileId;
|
||||
set({ profiles: remaining, activeProfileId: newActive });
|
||||
if (newActive) await get().setActiveProfile(newActive);
|
||||
},
|
||||
|
||||
loadGuides: async () => {
|
||||
const { activeProfileId } = get();
|
||||
if (!activeProfileId) return;
|
||||
const guides = await invoke<GuideListItem[]>("get_guides_list", { profileId: activeProfileId });
|
||||
set({ guides });
|
||||
},
|
||||
|
||||
openGuide: async (gid) => {
|
||||
const data = await invoke<GuideData>("get_guide", { gid });
|
||||
set({ activeGuideGid: gid, activeGuideData: data, view: "guide" });
|
||||
},
|
||||
|
||||
closeGuide: () => {
|
||||
set({ activeGuideGid: null, activeGuideData: null, view: "home" });
|
||||
},
|
||||
|
||||
toggleQuest: async (questName) => {
|
||||
const { activeProfileId, completedQuests } = get();
|
||||
if (!activeProfileId) return;
|
||||
const isNowCompleted = await invoke<boolean>("toggle_quest", {
|
||||
profileId: activeProfileId,
|
||||
questName,
|
||||
});
|
||||
const next = new Set(completedQuests);
|
||||
if (isNowCompleted) next.add(questName);
|
||||
else next.delete(questName);
|
||||
set({ completedQuests: next });
|
||||
|
||||
// Refresh guide list progress counts
|
||||
await get().loadGuides();
|
||||
},
|
||||
|
||||
syncGuides: async () => {
|
||||
const tabs = await invoke<{ gid: string; name: string }[]>("get_tabs_list");
|
||||
const total = tabs.length;
|
||||
const errors: string[] = [];
|
||||
let synced = 0;
|
||||
|
||||
set({ syncing: true, syncProgress: { current: 0, total, label: "Démarrage…" } });
|
||||
|
||||
for (const tab of tabs) {
|
||||
set({ syncProgress: { current: synced, total, label: tab.name } });
|
||||
try {
|
||||
await invoke("sync_single_guide", { gid: tab.gid, name: tab.name });
|
||||
synced++;
|
||||
} catch (e) {
|
||||
errors.push(`${tab.name}: ${e}`);
|
||||
}
|
||||
}
|
||||
|
||||
set({ syncing: false, syncProgress: null });
|
||||
await get().loadGuides();
|
||||
return { synced, errors };
|
||||
},
|
||||
|
||||
syncSingleGuide: async (gid, name) => {
|
||||
await invoke("sync_single_guide", { gid, name });
|
||||
},
|
||||
|
||||
toggleAlwaysOnTop: async () => {
|
||||
const next = !get().alwaysOnTop;
|
||||
await invoke("set_always_on_top", { value: next });
|
||||
set({ alwaysOnTop: next });
|
||||
},
|
||||
}));
|
||||
70
src/types.ts
Normal file
70
src/types.ts
Normal file
@ -0,0 +1,70 @@
|
||||
export interface Profile {
|
||||
id: string;
|
||||
name: string;
|
||||
created_at: string;
|
||||
}
|
||||
|
||||
export interface GuideListItem {
|
||||
gid: string;
|
||||
name: string;
|
||||
last_synced_at: string | null;
|
||||
total_quests: number;
|
||||
completed_quests: number;
|
||||
}
|
||||
|
||||
export interface CombatType {
|
||||
name: string;
|
||||
column: number;
|
||||
}
|
||||
|
||||
export interface Resource {
|
||||
quantity: number;
|
||||
name: string;
|
||||
}
|
||||
|
||||
export interface CombatIndicator {
|
||||
combat_type: string;
|
||||
count: string;
|
||||
}
|
||||
|
||||
export interface QuestItem {
|
||||
name: string;
|
||||
completed: boolean;
|
||||
combat_indicators: CombatIndicator[];
|
||||
note: string | null;
|
||||
url: string | null;
|
||||
}
|
||||
|
||||
export interface InstructionItem {
|
||||
text: string;
|
||||
}
|
||||
|
||||
export interface GroupItem {
|
||||
note: string | null;
|
||||
quests: QuestItem[];
|
||||
}
|
||||
|
||||
export type SectionItem =
|
||||
| { type: "Quest"; name: string; completed: boolean; combat_indicators: CombatIndicator[]; note: string | null; url: string | null }
|
||||
| { type: "Instruction"; text: string }
|
||||
| { type: "Group"; note: string | null; quests: QuestItem[] };
|
||||
|
||||
export interface Section {
|
||||
name: string;
|
||||
items: SectionItem[];
|
||||
}
|
||||
|
||||
export interface GuideData {
|
||||
name: string;
|
||||
gid: string;
|
||||
effect: string;
|
||||
recommended_level: number | null;
|
||||
combat_legend: CombatType[];
|
||||
resources: Resource[];
|
||||
sections: Section[];
|
||||
}
|
||||
|
||||
export interface SyncResult {
|
||||
synced: number;
|
||||
errors: string[];
|
||||
}
|
||||
1
src/vite-env.d.ts
vendored
Normal file
1
src/vite-env.d.ts
vendored
Normal file
@ -0,0 +1 @@
|
||||
/// <reference types="vite/client" />
|
||||
Reference in New Issue
Block a user