mirror of
https://github.com/R0m1k3/TodoFlow.git
synced 2026-10-11 17:28:17 +02:00
Implement click to expand long tasks, a custom glassmorphic delete confirmation modal, and background transparency slider in settings
This commit is contained in:
1 parent
8214b2e9ac
commit
891782515d
3 files changed
+214
-5
No files matched your search
+58
-3
@@ -11,6 +11,7 @@ let state = {
|
||||
apiKey: "widget-token-secure-789",
|
||||
alwaysOnTop: false,
|
||||
autostart: false,
|
||||
opacity: 70,
|
||||
tasks: [],
|
||||
pollingInterval: null
|
||||
};
|
||||
@@ -38,6 +39,10 @@ const inputAutostart = document.getElementById("setting-autostart");
|
||||
const btnMinimize = document.getElementById("btn-minimize");
|
||||
const btnClose = document.getElementById("btn-close");
|
||||
|
||||
const inputOpacity = document.getElementById("setting-opacity");
|
||||
const opacityValue = document.getElementById("opacity-value");
|
||||
let taskToDeleteId = null;
|
||||
|
||||
// --- INITIALISATION ---
|
||||
|
||||
document.addEventListener("DOMContentLoaded", async () => {
|
||||
@@ -48,6 +53,33 @@ document.addEventListener("DOMContentLoaded", async () => {
|
||||
inputApiUrl.value = state.apiUrl;
|
||||
inputApiKey.value = state.apiKey;
|
||||
inputAlwaysOnTop.checked = state.alwaysOnTop;
|
||||
inputOpacity.value = state.opacity;
|
||||
opacityValue.textContent = state.opacity;
|
||||
|
||||
// Real-time opacity slider updates
|
||||
inputOpacity.addEventListener("input", () => {
|
||||
const val = inputOpacity.value;
|
||||
opacityValue.textContent = val;
|
||||
document.documentElement.style.setProperty("--widget-opacity", val / 100);
|
||||
});
|
||||
|
||||
// Modal de confirmation de suppression personnalisé
|
||||
const confirmModal = document.getElementById("confirm-modal");
|
||||
const btnConfirmCancel = document.getElementById("btn-confirm-cancel");
|
||||
const btnConfirmDelete = document.getElementById("btn-confirm-delete");
|
||||
|
||||
btnConfirmCancel.addEventListener("click", () => {
|
||||
confirmModal.classList.remove("open");
|
||||
taskToDeleteId = null;
|
||||
});
|
||||
|
||||
btnConfirmDelete.addEventListener("click", async () => {
|
||||
if (taskToDeleteId) {
|
||||
confirmModal.classList.remove("open");
|
||||
await executeDeleteTask(taskToDeleteId);
|
||||
taskToDeleteId = null;
|
||||
}
|
||||
});
|
||||
|
||||
// Événements d'ouverture/fermeture des paramètres
|
||||
btnSettings.addEventListener("click", () => settingsPanel.classList.add("open"));
|
||||
@@ -88,6 +120,7 @@ function loadSettingsFromStorage() {
|
||||
const storedApiUrl = localStorage.getItem("todoflow_api_url");
|
||||
const storedApiKey = localStorage.getItem("todoflow_api_key");
|
||||
const storedAlwaysOnTop = localStorage.getItem("todoflow_always_on_top");
|
||||
const storedOpacity = localStorage.getItem("todoflow_opacity");
|
||||
|
||||
if (storedApiUrl) state.apiUrl = storedApiUrl;
|
||||
if (storedApiKey) state.apiKey = storedApiKey;
|
||||
@@ -98,6 +131,13 @@ function loadSettingsFromStorage() {
|
||||
invoke("toggle_always_on_top", { enabled: state.alwaysOnTop }).catch(console.error);
|
||||
}
|
||||
}
|
||||
if (storedOpacity) {
|
||||
state.opacity = parseInt(storedOpacity);
|
||||
document.documentElement.style.setProperty("--widget-opacity", state.opacity / 100);
|
||||
} else {
|
||||
state.opacity = 70;
|
||||
document.documentElement.style.setProperty("--widget-opacity", 0.70);
|
||||
}
|
||||
}
|
||||
|
||||
async function saveSettings() {
|
||||
@@ -105,14 +145,17 @@ async function saveSettings() {
|
||||
const newKey = inputApiKey.value.trim();
|
||||
const newAlwaysOnTop = inputAlwaysOnTop.checked;
|
||||
const newAutostart = inputAutostart.checked;
|
||||
const newOpacity = inputOpacity.value;
|
||||
|
||||
state.apiUrl = newUrl;
|
||||
state.apiKey = newKey;
|
||||
state.alwaysOnTop = newAlwaysOnTop;
|
||||
state.opacity = parseInt(newOpacity);
|
||||
|
||||
localStorage.setItem("todoflow_api_url", newUrl);
|
||||
localStorage.setItem("todoflow_api_key", newKey);
|
||||
localStorage.setItem("todoflow_always_on_top", newAlwaysOnTop.toString());
|
||||
localStorage.setItem("todoflow_opacity", newOpacity.toString());
|
||||
|
||||
// Appel des fonctions système Windows natives via Tauri
|
||||
if (appWindow && invoke) {
|
||||
@@ -265,6 +308,14 @@ function renderTasksList() {
|
||||
const card = document.createElement("div");
|
||||
card.className = `task-card ${isCompleted ? 'completed' : ''}`;
|
||||
|
||||
// Clic pour étendre/réduire le titre si long
|
||||
card.addEventListener("click", (e) => {
|
||||
if (e.target.closest(".custom-checkbox") || e.target.closest(".btn-task-action") || e.target.closest(".task-edit-input")) {
|
||||
return;
|
||||
}
|
||||
card.classList.toggle("expanded");
|
||||
});
|
||||
|
||||
// Checkbox personnalisée cochable
|
||||
const checkbox = document.createElement("div");
|
||||
checkbox.className = `custom-checkbox ${isCompleted ? 'checked' : ''}`;
|
||||
@@ -437,9 +488,13 @@ async function updateTaskTitle(taskId, newTitle) {
|
||||
}
|
||||
}
|
||||
|
||||
async function deleteTask(taskId) {
|
||||
if (!confirm("Voulez-vous vraiment supprimer cette tâche ?")) return;
|
||||
|
||||
function deleteTask(taskId) {
|
||||
taskToDeleteId = taskId;
|
||||
const modal = document.getElementById("confirm-modal");
|
||||
modal.classList.add("open");
|
||||
}
|
||||
|
||||
async function executeDeleteTask(taskId) {
|
||||
try {
|
||||
const response = await fetch(`${state.apiUrl}/api/v1/tasks/${taskId}`, {
|
||||
method: "DELETE",
|
||||
|
||||
@@ -84,6 +84,11 @@
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="setting-group">
|
||||
<label for="setting-opacity">Transparence du fond (<span id="opacity-value">70</span>%)</label>
|
||||
<input type="range" id="setting-opacity" min="20" max="100" value="70" class="slider-opacity">
|
||||
</div>
|
||||
|
||||
<div class="setting-toggle">
|
||||
<label class="switch-container">
|
||||
<span class="switch-label">Lancer au démarrage</span>
|
||||
@@ -102,6 +107,18 @@
|
||||
// Import dynamique pour supporter l'exécution dans le navigateur pendant le dév
|
||||
window.__TAURI__ = window.__TAURI__ || null;
|
||||
</script>
|
||||
<!-- Modal de confirmation de suppression personnalisé (Thème Glassmorphism) -->
|
||||
<div class="confirm-modal-overlay" id="confirm-modal">
|
||||
<div class="confirm-modal-box">
|
||||
<h3>Supprimer la tâche ?</h3>
|
||||
<p>Cette action est irréversible et supprimera définitivement la tâche de la base SaaS.</p>
|
||||
<div class="confirm-modal-actions">
|
||||
<button class="btn-confirm-cancel" id="btn-confirm-cancel">Annuler</button>
|
||||
<button class="btn-confirm-delete" id="btn-confirm-delete">Supprimer</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="app.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
+139
-2
@@ -1,6 +1,6 @@
|
||||
/* --- SYSTÈME DE DESIGN & TOKENS --- */
|
||||
:root {
|
||||
--bg-widget: rgba(18, 22, 33, 0.70);
|
||||
--widget-opacity: 0.70;
|
||||
--bg-widget: rgba(18, 22, 33, var(--widget-opacity));
|
||||
--bg-card: rgba(255, 255, 255, 0.03);
|
||||
--bg-card-hover: rgba(255, 255, 255, 0.07);
|
||||
--border-widget: 1px solid rgba(255, 255, 255, 0.09);
|
||||
@@ -628,3 +628,140 @@ body {
|
||||
outline: none;
|
||||
box-shadow: 0 0 8px var(--accent-indigo-glow);
|
||||
}
|
||||
|
||||
/* --- ACCORDION / EXPANDED STATE --- */
|
||||
.task-card {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.task-card.expanded {
|
||||
background: var(--bg-card-hover);
|
||||
border-color: rgba(99, 102, 241, 0.3);
|
||||
}
|
||||
|
||||
.task-card.expanded .task-title {
|
||||
white-space: normal;
|
||||
overflow: visible;
|
||||
text-overflow: unset;
|
||||
display: block;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
/* --- RANGE SLIDER STYLING --- */
|
||||
.slider-opacity {
|
||||
-webkit-appearance: none;
|
||||
width: 100%;
|
||||
height: 6px;
|
||||
border-radius: 5px;
|
||||
background: rgba(255, 255, 255, 0.1);
|
||||
outline: none;
|
||||
transition: background 0.3s;
|
||||
margin: 6px 0;
|
||||
}
|
||||
|
||||
.slider-opacity::-webkit-slider-thumb {
|
||||
-webkit-appearance: none;
|
||||
appearance: none;
|
||||
width: 16px;
|
||||
height: 16px;
|
||||
border-radius: 50%;
|
||||
background: var(--accent-indigo);
|
||||
cursor: pointer;
|
||||
box-shadow: 0 0 10px var(--accent-indigo-glow);
|
||||
transition: transform 0.1s;
|
||||
}
|
||||
|
||||
.slider-opacity::-webkit-slider-thumb:hover {
|
||||
transform: scale(1.2);
|
||||
}
|
||||
|
||||
/* --- CUSTOM CONFIRMATION MODAL OVERLAY --- */
|
||||
.confirm-modal-overlay {
|
||||
position: absolute;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
background: rgba(0, 0, 0, 0.45);
|
||||
backdrop-filter: blur(8px);
|
||||
-webkit-backdrop-filter: blur(8px);
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
z-index: 1000;
|
||||
opacity: 0;
|
||||
pointer-events: none;
|
||||
transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1);
|
||||
}
|
||||
|
||||
.confirm-modal-overlay.open {
|
||||
opacity: 1;
|
||||
pointer-events: auto;
|
||||
}
|
||||
|
||||
.confirm-modal-box {
|
||||
width: 290px;
|
||||
background: rgba(18, 22, 33, 0.95);
|
||||
border: 1px solid rgba(255, 255, 255, 0.1);
|
||||
border-radius: 14px;
|
||||
padding: 20px;
|
||||
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
|
||||
transform: scale(0.9);
|
||||
transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.confirm-modal-overlay.open .confirm-modal-box {
|
||||
transform: scale(1);
|
||||
}
|
||||
|
||||
.confirm-modal-box h3 {
|
||||
font-size: 15px;
|
||||
font-weight: 700;
|
||||
color: var(--text-primary);
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
|
||||
.confirm-modal-box p {
|
||||
font-size: 11.5px;
|
||||
color: var(--text-secondary);
|
||||
line-height: 1.5;
|
||||
margin-bottom: 20px;
|
||||
}
|
||||
|
||||
.confirm-modal-actions {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.confirm-modal-actions button {
|
||||
padding: 8px 16px;
|
||||
font-size: 12px;
|
||||
font-weight: 600;
|
||||
border-radius: 8px;
|
||||
border: none;
|
||||
cursor: pointer;
|
||||
transition: all 0.2s;
|
||||
flex: 1;
|
||||
}
|
||||
|
||||
.btn-confirm-cancel {
|
||||
background: rgba(255, 255, 255, 0.08);
|
||||
color: var(--text-primary);
|
||||
}
|
||||
|
||||
.btn-confirm-cancel:hover {
|
||||
background: rgba(255, 255, 255, 0.15);
|
||||
}
|
||||
|
||||
.btn-confirm-delete {
|
||||
background: hsl(0, 75%, 50%);
|
||||
color: white;
|
||||
box-shadow: 0 0 12px rgba(239, 68, 68, 0.3);
|
||||
}
|
||||
|
||||
.btn-confirm-delete:hover {
|
||||
background: hsl(0, 75%, 45%);
|
||||
box-shadow: 0 0 16px rgba(239, 68, 68, 0.5);
|
||||
}
|
||||
Reference in new issue
Block a user