Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changes/fix-dark-mode.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"algohub": patch:fix
---

Fix dark mode selector for fronted
3 changes: 3 additions & 0 deletions .cspell.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
"words": [
"algohub",
"covector",
"persistedstate",
"pinia",
"primeicons",
"primevue",
"SWPU",
"tailwindcss",
Expand Down
19 changes: 11 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,27 @@
"dependencies": {
"@primevue/forms": "^4.2.2",
"@primevue/themes": "^4.2.2",
"@tauri-apps/api": "^2",
"@tauri-apps/plugin-shell": "^2",
"@tauri-apps/api": "^2.1.1",
"@tauri-apps/plugin-shell": "^2.0.1",
"axios": "^1.7.7",
"pinia": "^2.2.6",
"pinia-plugin-persistedstate": "^4.1.3",
"primeicons": "^7.0.0",
"primevue": "^4.2.2",
"vue": "^3.3.4",
"vue": "^3.5.13",
"vue-router": "^4.4.5",
"zod": "^3.23.8"
},
"devDependencies": {
"@primevue/auto-import-resolver": "^4.2.2",
"@tauri-apps/cli": "^2",
"@tauri-apps/cli": "^2.1.0",
"@types/node": "^22.9.0",
"@vitejs/plugin-vue": "^5.0.5",
"@vitejs/plugin-vue": "^5.2.0",
"covector": "^0.12.3",
"tailwindcss": "^3.4.15",
"typescript": "^5.2.2",
"typescript": "^5.6.3",
"unplugin-vue-components": "^0.27.4",
"vite": "^5.3.1",
"vue-tsc": "^2.0.22"
"vite": "^5.4.11",
"vue-tsc": "^2.1.10"
}
}
1,025 changes: 909 additions & 116 deletions pnpm-lock.yaml

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/App.vue
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
<script setup lang="ts">
import { useThemeStore } from './scripts/store';

const themeStore = useThemeStore();

themeStore.init();
</script>

<template>
Expand Down
154 changes: 58 additions & 96 deletions src/assets/tailwind.css
Original file line number Diff line number Diff line change
Expand Up @@ -554,66 +554,12 @@ video {
display: none;
}

.container {
width: 100%;
}

@media (min-width: 640px) {
.container {
max-width: 640px;
}
}

@media (min-width: 768px) {
.container {
max-width: 768px;
}
}

@media (min-width: 1024px) {
.container {
max-width: 1024px;
}
}

@media (min-width: 1280px) {
.container {
max-width: 1280px;
}
}

@media (min-width: 1536px) {
.container {
max-width: 1536px;
}
}

.m-10 {
margin: 2.5rem;
}

.m-8 {
margin: 2rem;
}

.m-0 {
margin: 0px;
}

.m-6 {
margin: 1.5rem;
}

.m-3 {
margin: 0.75rem;
}

.mb-10 {
margin-bottom: 2.5rem;
}

.mt-3 {
margin-top: 0.75rem;
.m-auto {
margin: auto;
}

.mt-6 {
Expand Down Expand Up @@ -644,34 +590,54 @@ video {
max-height: 100%;
}

.max-h-screen {
max-height: 100vh;
}

.w-full {
width: 100%;
}

.grid-cols-2 {
grid-template-columns: repeat(2, minmax(0, 1fr));
.flex-1 {
flex: 1 1 0%;
}

.grid-cols-4 {
grid-template-columns: repeat(4, minmax(0, 1fr));
.flex-shrink {
flex-shrink: 1;
}

.grid-rows-2 {
grid-template-rows: repeat(2, minmax(0, 1fr));
.flex-row {
flex-direction: row;
}

.flex-col {
flex-direction: column;
}

.flex-col-reverse {
flex-direction: column-reverse;
}

.items-start {
align-items: flex-start;
}

.items-center {
align-items: center;
}

.justify-start {
justify-content: flex-start;
}

.justify-center {
justify-content: center;
}

.justify-between {
justify-content: space-between;
}

.gap-1 {
gap: 0.25rem;
}
Expand All @@ -684,6 +650,10 @@ video {
gap: 1rem;
}

.overflow-hidden {
overflow: hidden;
}

.p-6 {
padding: 1.5rem;
}
Expand All @@ -708,6 +678,11 @@ video {
line-height: 1.25rem;
}

.text-3xl {
font-size: 1.875rem;
line-height: 2.25rem;
}

.font-bold {
font-weight: 700;
}
Expand All @@ -716,64 +691,51 @@ video {
text-decoration-line: underline;
}

@media (min-width: 640px) {
.sm\:grid-rows-2 {
grid-template-rows: repeat(2, minmax(0, 1fr));
}
}

@media (min-width: 768px) {
.md\:col-span-2 {
grid-column: span 2 / span 2;
}

.md\:m-2 {
margin: 0.5rem;
}

.md\:m-10 {
margin: 2.5rem;
}

.md\:m-0 {
margin: 0px;
}

.md\:block {
display: block;
}

.md\:flex {
display: flex;
}

.md\:hidden {
display: none;
}

.md\:h-full {
height: 100%;
}

.md\:flex-1 {
flex: 1 1 0%;
}

.md\:grid-cols-2 {
grid-template-columns: repeat(2, minmax(0, 1fr));
}

.md\:flex-row {
flex-direction: row;
}
}

@media (min-width: 1024px) {
.lg\:col-span-1 {
grid-column: span 1 / span 1;
.md\:flex-col {
flex-direction: column;
}

.lg\:w-full {
width: 100%;
.md\:items-center {
align-items: center;
}

.lg\:grid-rows-2 {
grid-template-rows: repeat(2, minmax(0, 1fr));
.md\:justify-center {
justify-content: center;
}

.md\:text-4xl {
font-size: 2.25rem;
line-height: 2.5rem;
}
}

@media (min-width: 1024px) {
.lg\:w-full {
width: 100%;
}
}
17 changes: 12 additions & 5 deletions src/main.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import "@/assets/base.css";
import "@/assets/tailwind.css";
import "primeicons/primeicons.css";

import { createApp } from "vue";
import App from "@/App.vue";
Expand All @@ -8,18 +9,24 @@ import Aura from "@primevue/themes/aura";
import ToastService from "primevue/toastservice";

import router from "./router";
import { createPinia } from "pinia";
import piniaPluginPersistedState from "pinia-plugin-persistedstate";

const app = createApp(App);

const pinia = createPinia();
pinia.use(piniaPluginPersistedState);

app.use(pinia);
app.use(router);
app.use(PrimeVue, {
theme: {
preset: Aura,
},
options: {
prefix: "p",
darkModeSelector: ".dark",
cssLayer: false,
options: {
prefix: "p",
darkModeSelector: ".dark",
cssLayer: false,
},
},
});
app.use(ToastService);
Expand Down
36 changes: 36 additions & 0 deletions src/scripts/store.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import { defineStore } from "pinia";
import { ref } from "vue";

const prefersDarkMode = () => {
return (
window.matchMedia &&
window.matchMedia("(prefers-color-scheme: dark)").matches
);
};

export const useThemeStore = defineStore(
"theme",
() => {
const dark = ref<boolean | null>(null);
const init = () => {
if (dark.value === null) {
dark.value = prefersDarkMode();
}
if (dark.value) {
document.documentElement.classList.add("dark");
}
};
const toggle = () => {
dark.value = !dark.value;
if (dark.value) {
document.documentElement.classList.add("dark");
} else {
document.documentElement.classList.remove("dark");
}
};
return { dark, toggle, init };
},
{
persist: true,
}
);
Loading