From f5688ce0a9a11a95ed7d50b6343b3ccd3b60b138 Mon Sep 17 00:00:00 2001 From: lukascobit Date: Sat, 17 Aug 2024 14:51:16 +0200 Subject: [PATCH] save into .env --- app/globals.css | 53 ++++++++++++++++++++++++++++++++++++++++++- app/page.tsx | 25 ++++++++++++++++---- src-tauri/src/main.rs | 28 +++++++++++++++++++---- src-tauri/src/term.rs | 6 +++-- todo.todo | 1 + 5 files changed, 102 insertions(+), 11 deletions(-) diff --git a/app/globals.css b/app/globals.css index 88c0c07..5a88902 100644 --- a/app/globals.css +++ b/app/globals.css @@ -2,6 +2,9 @@ @tailwind components; @tailwind utilities; +:root { + --bg: #0a647c; +} body { color: white !important; margin: 0; @@ -48,7 +51,7 @@ input { } button { cursor: pointer; - background-color: #0a647c; + background-color: var(--bg); border: none; font-size: 2rem; border-radius: 0.5vw; @@ -122,3 +125,51 @@ button { display: flex; background: white; } + +.custom-checkbox { + margin: 0; + display: flex; + align-items: center; + cursor: pointer; + font-size: 1rem; + text-align: center; +} + +.custom-checkbox input { + position: absolute; + opacity: 0; + cursor: pointer; + height: 0; + width: 0; +} + +.checkmark { + position: relative; + height: 20px; + width: 20px; + background-color: #ccc; + border-radius: 4px; + margin-right: 8px; + transition: background-color 0.3s; +} + +.custom-checkbox input:checked ~ .checkmark { + background-color: var(--bg); +} + +.checkmark:after { + content: ""; + position: absolute; + display: none; + left: 7px; + top: 3px; + width: 5px; + height: 10px; + border: solid white; + border-width: 0 2px 2px 0; + transform: rotate(45deg); +} + +.custom-checkbox input:checked ~ .checkmark:after { + display: block; +} diff --git a/app/page.tsx b/app/page.tsx index 55eb53c..b62635b 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -2,7 +2,7 @@ // import Image from "next/image"; import { invoke } from "@tauri-apps/api/tauri"; // import logo from "../public/vercel.svg"; -import { useState } from "react"; +import { useState, useEffect } from "react"; export default function Home() { const [error, setError] = useState(""); @@ -18,6 +18,16 @@ export default function Home() { const [chosenShowGrades, setChosenShowGrades] = useState(); const [chosenValues, setChosenValues] = useState(); const [showPass, setShowPass] = useState(false); + const [isSave, setIsSave] = useState(false); + + console.log(); + useEffect(() => { + if (process.env.NEXT_PUBLIC_USERNAME && process.env.NEXT_PUBLIC_PASSWORD) { + setUsername(process.env.NEXT_PUBLIC_USERNAME); + setPassword(process.env.NEXT_PUBLIC_PASSWORD); + setIsSave(true); + } + }, []); function signin(e: any) { e.preventDefault(); @@ -25,7 +35,7 @@ export default function Home() { setError("You have to fill all fields!"); return; } - invoke("subjects", { username, password }) + invoke("subjects", { username, password, isSave }) .then((result) => { console.log(result); if (result[0] == "could not get subjects") { @@ -120,10 +130,17 @@ export default function Home() { {showPass ? "👁" : "🔒"} -