diff --git a/messages/bn.json b/messages/bn.json index 39f2a512..534c8f7b 100644 --- a/messages/bn.json +++ b/messages/bn.json @@ -23,14 +23,8 @@ }, "SolvesPage": { "title": "সমাধান", - "archive": "আর্কাইভ", - "unarchive": "আনআর্কাইভ", - "copy": "কপি", - "remove": "অপসারণ", - "enter-a-comment": "একটি মন্তব্য প্রবেশ করুন", "session": "সেশন", - "all": "সব", - "no-cube-selection": "কোনও কিউব নির্বাচিত হয়নি, একটি বেছে নিন..." + "all": "সব" }, "StatsPage": { "title": "পরিসংখ্যান", diff --git a/messages/cs.json b/messages/cs.json index 21daa6d1..ecbe4c70 100644 --- a/messages/cs.json +++ b/messages/cs.json @@ -23,14 +23,8 @@ }, "SolvesPage": { "title": "Řešení", - "archive": "Archivovat", - "unarchive": "Zrušit archivaci", - "copy": "Kopírovat", - "remove": "Odstranit", - "enter-a-comment": "Zadejte komentář", "session": "Relace", - "all": "Vše", - "no-cube-selection": "Není vybrána žádná kostka, vyberte jednu..." + "all": "Vše" }, "StatsPage": { "title": "Statistiky", diff --git a/messages/de.json b/messages/de.json index 6e3827e5..7a2bb4e9 100644 --- a/messages/de.json +++ b/messages/de.json @@ -23,14 +23,8 @@ }, "SolvesPage": { "title": "Lösungen", - "archive": "Archivieren", - "unarchive": "Archivierung aufheben", - "copy": "Kopieren", - "remove": "Entfernen", - "enter-a-comment": "Kommentar eingeben", "session": "Sitzung", - "all": "Alle", - "no-cube-selection": "Kein Würfel ausgewählt, wählen Sie einen..." + "all": "Alle" }, "StatsPage": { "title": "Statistiken", diff --git a/messages/en.json b/messages/en.json index 029e4250..ea54bb96 100644 --- a/messages/en.json +++ b/messages/en.json @@ -161,7 +161,7 @@ "max-file-size": "Maximum file size allowed is", "data": "App Data", "preferences": "Preferences", - "default-cube": "Default cube", + "auto-select": "Auto-select at startup", "import-from-file": "Import from file", "export-to-file": "Export to file", "about": "About", diff --git a/messages/es.json b/messages/es.json index 20cfd7e1..641213fb 100644 --- a/messages/es.json +++ b/messages/es.json @@ -23,18 +23,11 @@ }, "SolvesPage": { "title": "Soluciones", - "archive": "Archivar", - "unarchive": "Desarchivar", - "copy": "Copiar", - "remove": "Eliminar", - "enter-a-comment": "Introduce un comentario", "session": "Sesión", "all": "Todos", - "no-cube-selection": "No se ha seleccionado ningún cubo, elige uno...", "ascending": "Ascendente", "date": "Fecha", "descending": "Descendente", - "sort-by": "Ordenar por...", "time": "Tiempo", "share": "Compartir...", "last": "Último" diff --git a/messages/et.json b/messages/et.json index 8555cbdc..6552f04b 100644 --- a/messages/et.json +++ b/messages/et.json @@ -23,18 +23,11 @@ }, "SolvesPage": { "title": "Lahendused", - "archive": "Arhiveeri", - "unarchive": "Arhiivita", - "copy": "Kopeeri", - "remove": "Eemalda", - "enter-a-comment": "Sisesta kommentaar", "session": "Sessioon", "all": "Kõik", - "no-cube-selection": "Kuupi pole valitud, valige üks...", "ascending": "Kasvav", "date": "Kuupäev", "descending": "Langevad", - "sort-by": "Sorteerima...", "time": "Aeg" }, "StatsPage": { diff --git a/messages/fi.json b/messages/fi.json index c48d10c4..80452ed4 100644 --- a/messages/fi.json +++ b/messages/fi.json @@ -23,18 +23,11 @@ }, "SolvesPage": { "title": "Ratkaisut", - "archive": "Arkistoi", - "unarchive": "Poista arkisto", - "copy": "Kopioi", - "remove": "Poista", - "enter-a-comment": "Kirjoita kommentti", "session": "Istunto", "all": "Kaikki", - "no-cube-selection": "Ei valittua kuutiota, valitse yksi...", "ascending": "Nouseva", "date": "Päivämäärä", "descending": "Laskeva", - "sort-by": "Järjestä...", "time": "Aika" }, "StatsPage": { diff --git a/messages/fr.json b/messages/fr.json index ddbfb979..d582b454 100644 --- a/messages/fr.json +++ b/messages/fr.json @@ -23,18 +23,11 @@ }, "SolvesPage": { "title": "Résolutions", - "archive": "Archiver", - "unarchive": "Désarchiver", - "copy": "Copier", - "remove": "Supprimer", - "enter-a-comment": "Saisissez un commentaire", "session": "Session", "all": "Tout", - "no-cube-selection": "Aucun cube sélectionné, choisissez-en un...", "ascending": "Ascendant", "date": "Date", "descending": "Descendant", - "sort-by": "Trier par...", "time": "Temps" }, "StatsPage": { diff --git a/messages/hi.json b/messages/hi.json index cd7f6ee9..578bf20b 100644 --- a/messages/hi.json +++ b/messages/hi.json @@ -23,18 +23,11 @@ }, "SolvesPage": { "title": "समाधान", - "archive": "संग्रहीत", - "unarchive": "संग्रह रद्द करें", - "copy": "प्रतिलिपि", - "remove": "हटाएं", - "enter-a-comment": "एक टिप्पणी दर्ज करें", "session": "सत्र", "all": "सभी", - "no-cube-selection": "कोई क्यूब चयनित नहीं है, कोई एक चुनें...", "ascending": "आरोही", "date": "तारीख", "descending": "अवरोही", - "sort-by": "इसके अनुसार क्रमबद्ध करें...", "time": "समय" }, "StatsPage": { diff --git a/messages/hu.json b/messages/hu.json index fdc98eb0..2a152edd 100644 --- a/messages/hu.json +++ b/messages/hu.json @@ -23,18 +23,11 @@ }, "SolvesPage": { "title": "Megoldások", - "archive": "Archiválás", - "unarchive": "Archiválás megszüntetése", - "copy": "Másolás", - "remove": "Eltávolítás", - "enter-a-comment": "Adjon meg egy megjegyzést", "session": "Munkamenet", "all": "Mind", - "no-cube-selection": "Nincs kiválasztott kocka, válasszon egyet...", "ascending": "Emelkedő", "date": "Dátum", "descending": "Csökkenő", - "sort-by": "Rendezés...", "time": "Idő" }, "StatsPage": { diff --git a/messages/id.json b/messages/id.json index bc92875a..2e4e8ef7 100644 --- a/messages/id.json +++ b/messages/id.json @@ -23,16 +23,9 @@ }, "SolvesPage": { "title": "Penyelesaian", - "archive": "Arsip", - "unarchive": "Buka arsip", - "copy": "Salin", - "remove": "Hapus", - "enter-a-comment": "Masukkan komentar", "session": "Sesi", "all": "Semua", - "no-cube-selection": "Tidak ada kubus yang dipilih, pilih satu...", "time": "Waktu", - "sort-by": "Sortir dengan...", "descending": "Menurun", "ascending": "Naik", "date": "Tanggal" diff --git a/messages/it.json b/messages/it.json index 4588d9b8..54da51f7 100644 --- a/messages/it.json +++ b/messages/it.json @@ -23,16 +23,9 @@ }, "SolvesPage": { "title": "Risoluzioni", - "archive": "Archivia", - "unarchive": "Rimuovi dall'archivio", - "copy": "Copia", - "remove": "Rimuovi", - "enter-a-comment": "Inserisci un commento", "session": "Sessione", "all": "Tutto", - "no-cube-selection": "Nessun cubo selezionato, scegline uno...", "time": "Tempo", - "sort-by": "Ordina per...", "descending": "Discendente", "date": "Data", "ascending": "Ascendente" diff --git a/messages/ja.json b/messages/ja.json index 17e4692c..99ebf7ce 100644 --- a/messages/ja.json +++ b/messages/ja.json @@ -23,16 +23,9 @@ }, "SolvesPage": { "title": "解答", - "archive": "アーカイブ", - "unarchive": "アーカイブ解除", - "copy": "コピー", - "remove": "削除", - "enter-a-comment": "コメントを入力", "session": "セッション", "all": "すべて", - "no-cube-selection": "キューブが選択されていません。選択してください...", "time": "時間", - "sort-by": "並べ替え...", "descending": "降順", "date": "日付", "ascending": "上昇" diff --git a/messages/ko.json b/messages/ko.json index 84627dc2..914e2b79 100644 --- a/messages/ko.json +++ b/messages/ko.json @@ -23,15 +23,8 @@ }, "SolvesPage": { "title": "해결", - "archive": "아카이브", - "unarchive": "아카이브 해제", - "copy": "복사", - "remove": "제거", - "enter-a-comment": "코멘트 입력", "session": "세션", "all": "모두", - "no-cube-selection": "큐브가 선택되지 않았습니다. 하나를 선택하세요...", - "sort-by": "정렬 기준...", "descending": "내림차순", "date": "날짜", "ascending": "오름차순", diff --git a/messages/ms.json b/messages/ms.json index 22e46943..0a623a5c 100644 --- a/messages/ms.json +++ b/messages/ms.json @@ -23,16 +23,9 @@ }, "SolvesPage": { "title": "Penyelesaian", - "archive": "Arkib", - "unarchive": "Buka arkib", - "copy": "Salin", - "remove": "Alih keluar", - "enter-a-comment": "Masukkan komen", "session": "Sesi", "all": "Semua", - "no-cube-selection": "Tiada pemilihan kubus, pilih satu...", "time": "Masa", - "sort-by": "Disusun mengikut...", "descending": "Menurun", "date": "Tarikh", "ascending": "Menaik" diff --git a/messages/nl.json b/messages/nl.json index 627af7b7..4fa513db 100644 --- a/messages/nl.json +++ b/messages/nl.json @@ -23,16 +23,9 @@ }, "SolvesPage": { "title": "Oplossingen", - "archive": "Archiveren", - "unarchive": "De-archiveren", - "copy": "Kopiëren", - "remove": "Verwijderen", - "enter-a-comment": "Voer een opmerking in", "session": "Sessie", "all": "Alle", - "no-cube-selection": "Geen kubus geselecteerd, kies er een...", "time": "Tijd", - "sort-by": "Sorteer op...", "descending": "Aflopend", "date": "Datum", "ascending": "Oplopend" diff --git a/messages/no.json b/messages/no.json index c53dcc7b..3098e90e 100644 --- a/messages/no.json +++ b/messages/no.json @@ -23,16 +23,9 @@ }, "SolvesPage": { "title": "Løsninger", - "archive": "Arkiv", - "unarchive": "Avarkiv", - "copy": "Kopiere", - "remove": "Fjerne", - "enter-a-comment": "Skriv en kommentar", "session": "Økt", "all": "Alle", - "no-cube-selection": "Ingen kube valgt, velg en...", "time": "Tid", - "sort-by": "Sorter etter...", "descending": "Synkende", "date": "Dato", "ascending": "Stigende" diff --git a/messages/pl.json b/messages/pl.json index ece057f2..2e7e4a2f 100644 --- a/messages/pl.json +++ b/messages/pl.json @@ -23,19 +23,12 @@ }, "SolvesPage": { "title": "Rozwiązania", - "archive": "Archiwum", - "unarchive": "Usuń z archiwum", - "copy": "Kopiuj", - "remove": "Usuń", - "enter-a-comment": "Wprowadź komentarz", "session": "Sesja", "all": "Wszystkie", - "no-cube-selection": "Nie wybrano kostki, wybierz jedną...", "time": "Czas", "descending": "Malejąco", "date": "Data", - "ascending": "Rosnąco", - "sort-by": "Sortuj według..." + "ascending": "Rosnąco" }, "StatsPage": { "title": "Statystyki", diff --git a/messages/pt.json b/messages/pt.json index 0bc0a547..052b181f 100644 --- a/messages/pt.json +++ b/messages/pt.json @@ -23,16 +23,9 @@ }, "SolvesPage": { "title": "Soluções", - "archive": "Arquivar", - "unarchive": "Desarquivar", - "copy": "Copiar", - "remove": "Remover", - "enter-a-comment": "Digite um comentário", "session": "Sessão", "all": "Todos", - "no-cube-selection": "Nenhum cubo selecionado, escolha um...", "time": "Tempo", - "sort-by": "Ordenar por...", "descending": "descendente", "date": "Data", "ascending": "Ascendente" diff --git a/messages/ro.json b/messages/ro.json index 9fac89f0..9a83252c 100644 --- a/messages/ro.json +++ b/messages/ro.json @@ -23,16 +23,9 @@ }, "SolvesPage": { "title": "Soluții", - "archive": "Arhivă", - "unarchive": "Dezarhivare", - "copy": "Copiere", - "remove": "Eliminare", - "enter-a-comment": "Introduceți un comentariu", "session": "Sesiune", "all": "Toate", - "no-cube-selection": "Niciun cub selectat, alegeți unul...", "time": "Timp", - "sort-by": "Filtrează după...", "descending": "Descendentă", "date": "Data", "ascending": "Ascendent" diff --git a/messages/ru.json b/messages/ru.json index 14b70b60..560e1ae1 100644 --- a/messages/ru.json +++ b/messages/ru.json @@ -23,18 +23,11 @@ }, "SolvesPage": { "title": "Решения", - "archive": "Архивировать", - "unarchive": "Разархивировать", - "copy": "Копировать", - "remove": "Удалить", - "enter-a-comment": "Введите комментарий", "session": "Сессия", "all": "Все", - "no-cube-selection": "Куб не выбран, выберите один...", "ascending": "Восходящий", "date": "Дата", "descending": "По убыванию", - "sort-by": "Сортировать по...", "time": "Время", "share": "Поделиться...", "last": "Последнее" @@ -98,7 +91,6 @@ "theme": "Тема", "data": "Данные приложения", "preferences": "Предпочтения", - "default-cube": "Кубик по умолчанию", "import-from-file": "Импорт из файла", "export-to-file": "Экспорт в файл", "custom-background-image": "Пользовательское фоновое изображение", diff --git a/messages/sk.json b/messages/sk.json index 50fe96fd..2abfd320 100644 --- a/messages/sk.json +++ b/messages/sk.json @@ -23,18 +23,11 @@ }, "SolvesPage": { "title": "Riešenia", - "archive": "Archív", - "unarchive": "Obnoviť archív", - "copy": "Kopírovať", - "remove": "Odstrániť", - "enter-a-comment": "Vložiť komentár", "session": "Relácia", "all": "Všetky", - "no-cube-selection": "Nevybrali ste kocku, vyberte jednu...", "ascending": "Vzostupne", "date": "Dátum", "descending": "Zostupne", - "sort-by": "Triediť podľa...", "time": "Čas" }, "StatsPage": { diff --git a/messages/sv.json b/messages/sv.json index 0708df62..014bf129 100644 --- a/messages/sv.json +++ b/messages/sv.json @@ -23,18 +23,11 @@ }, "SolvesPage": { "title": "Lösningar", - "archive": "Arkiv", - "unarchive": "Avarkivera", - "copy": "Kopiera", - "remove": "Ta bort", - "enter-a-comment": "Ange en kommentar", "session": "Session", "all": "Alla", - "no-cube-selection": "Ingen kub vald, välj en...", "descending": "Nedåtgående", "date": "Datum", "ascending": "Stigande", - "sort-by": "Sortera efter...", "time": "Tid" }, "StatsPage": { diff --git a/messages/tr.json b/messages/tr.json index f2a65395..58d3a651 100644 --- a/messages/tr.json +++ b/messages/tr.json @@ -23,18 +23,11 @@ }, "SolvesPage": { "title": "Çözümler", - "archive": "Arşiv", - "unarchive": "Arşivden çıkar", - "copy": "Kopyala", - "remove": "Kaldır", - "enter-a-comment": "Bir yorum girin", "session": "Oturum", "all": "Tümü", - "no-cube-selection": "Hiçbir küp seçilmedi, bir tane seçin...", "descending": "Azalan", "ascending": "Artan", "date": "Tarih", - "sort-by": "Göre sırala...", "time": "Zaman" }, "StatsPage": { diff --git a/messages/uk.json b/messages/uk.json index 8cfcf3a6..7af2c078 100644 --- a/messages/uk.json +++ b/messages/uk.json @@ -23,18 +23,11 @@ }, "SolvesPage": { "title": "Розв'язки", - "archive": "Архівувати", - "unarchive": "Розархівувати", - "copy": "Копіювати", - "remove": "Видалити", - "enter-a-comment": "Введіть коментар", "session": "Сеанс", "all": "Bci", - "no-cube-selection": "Ky6 не вибрано, виберіть один...", "ascending": "Висхідний", "date": "Дата", "descending": "Спускається", - "sort-by": "Сортувати за...", "time": "час" }, "StatsPage": { diff --git a/messages/vi.json b/messages/vi.json index ba32d0e5..6fb0856b 100644 --- a/messages/vi.json +++ b/messages/vi.json @@ -23,18 +23,11 @@ }, "SolvesPage": { "title": "Giải quyết", - "archive": "Lưu trữ", - "unarchive": "Bỏ lưu trữ", - "copy": "Sao chép", - "remove": "Xóa bỏ", - "enter-a-comment": "Nhập bình luận", "session": "Phiên", "all": "Tất cả", - "no-cube-selection": "Không có khối nào được chọn, hãy chọn một...", "ascending": "Tăng dần", "date": "Ngày", "descending": "Giảm dần", - "sort-by": "Sắp xếp theo...", "time": "Thời gian" }, "StatsPage": { diff --git a/messages/zh.json b/messages/zh.json index 1d84ce6a..632e598d 100644 --- a/messages/zh.json +++ b/messages/zh.json @@ -23,18 +23,11 @@ }, "SolvesPage": { "title": "解决方案", - "archive": "存档", - "unarchive": "取消存档", - "copy": "复制", - "remove": "移除", - "enter-a-comment": "输入评论", "session": "会话", "all": "全部", - "no-cube-selection": "未选择魔方,请选择一个...", "ascending": "上升", "date": "日期", "descending": "降序", - "sort-by": "排序方式...", "time": "时间" }, "StatsPage": { diff --git a/src/components/MainCubeSelector.tsx b/src/components/MainCubeSelector.tsx index 1eb2e61e..c648a676 100644 --- a/src/components/MainCubeSelector.tsx +++ b/src/components/MainCubeSelector.tsx @@ -23,7 +23,11 @@ export default function MainCubeSelector() { }; return ( <> - diff --git a/src/components/menu-settings/CustomTheme.tsx b/src/components/menu-settings/CustomTheme.tsx index c2b611dc..0dcafbb1 100644 --- a/src/components/menu-settings/CustomTheme.tsx +++ b/src/components/menu-settings/CustomTheme.tsx @@ -1,8 +1,8 @@ import { ChangeEvent, useRef } from "react"; -import { Button } from "../button"; import { useBackgroundImageStore } from "@/store/BackgroundThemeStore"; import { useTranslations } from "next-intl"; -import { GifIcon, PhotoIcon } from "@heroicons/react/24/solid"; +import { Button } from "../ui/button"; +import { ImageIcon } from "@radix-ui/react-icons"; export default function CustomTheme() { const dataInputRef = useRef(null); @@ -62,12 +62,13 @@ export default function CustomTheme() { onChange={handleImageChange} />
{t("format")} .png .jpg .gif
diff --git a/src/components/menu-settings/DataImportExport.tsx b/src/components/menu-settings/DataImportExport.tsx index 1d6c37ee..e06355be 100644 --- a/src/components/menu-settings/DataImportExport.tsx +++ b/src/components/menu-settings/DataImportExport.tsx @@ -1,8 +1,8 @@ import exportDataToFile from "@/lib/exportDataToFile"; -import { Button } from "@/components/button"; import { useSettingsModalStore } from "@/store/SettingsModalStore"; import { useTranslations } from "next-intl"; -import { BarsArrowDownIcon, BarsArrowUpIcon } from "@heroicons/react/24/solid"; +import { Button } from "../ui/button"; +import { DownloadIcon, UploadIcon } from "@radix-ui/react-icons"; export function DataImportExport() { const t = useTranslations("Index.Settings-menu"); @@ -10,19 +10,20 @@ export function DataImportExport() { return (
); } diff --git a/src/components/menu-settings/Menu.tsx b/src/components/menu-settings/Menu.tsx index bd7d16b5..4469c462 100644 --- a/src/components/menu-settings/Menu.tsx +++ b/src/components/menu-settings/Menu.tsx @@ -22,6 +22,9 @@ import { ViewColumnsIcon, } from "@heroicons/react/24/solid"; import MenuSelectDefaultStartCube from "./MenuSelectDefaultStartCube"; +import { ScrollArea } from "../ui/scroll-area"; +import { Button } from "../ui/button"; +import { ExternalLinkIcon } from "@radix-ui/react-icons"; export default function MenuSettings() { const { settingsOpen, setSettingsOpen, settings } = useSettingsModalStore(); @@ -35,152 +38,163 @@ export default function MenuSettings() { <> {settingsOpen && !isSolving ? ( -
+
-
- setSettingsOpen(false)} - className="flex items-center cursor-pointer ms-3" - > - - -
- {t("title")} + +
+ setSettingsOpen(false)} + className="flex items-center cursor-pointer ms-3" + > + + +
+ {t("title")} +
-
- - - - } - title={t("timer")} - > - - - - - - - } - title={t("features")} - > - - - - - - - - } - title={t("alerts")} - > - - - - - - - } - title={t("theme")} - > - - - - - } - title={t("data")} - > - - - - } - title={t("preferences")} - > - - - - } - title={t("about")} - > -
- logo + + } + title={t("timer")} + > + + + + + -
- ”{t("legend")}” -
+ } + title={t("features")} + > + + + + + + + + } + title={t("alerts")} + > + + + + + + + } + title={t("theme")} + > + + + + + } + title={t("data")} + > + + + + } + title={t("preferences")} + > + + + + } + title={t("about")} + > +
+ logo + +
+ ”{t("legend")}” +
-
- - {t("suggest")} - - - {t("report-bug")} - +
+ + + + + + + +
-
-
+ + {/* Area to the right -> Its a transparent layer next to menu */} { + const currentSettings = loadSettings(); + + Object.values(currentSettings.timer).forEach((setting: any) => { + if (setting.key === id) { + setting.status = !setting.status; + } + }); + + Object.values(currentSettings.alerts).forEach((setting: any) => { + if (setting.key === id) { + setting.status = !setting.status; + } + }); + Object.values(currentSettings.features).forEach((setting: any) => { + if (setting.key === id) { + setting.status = !setting.status; + } + }); + + window.localStorage.setItem("settings", JSON.stringify(currentSettings)); + setSettings(currentSettings); + }; + return (
{label}
- +
); diff --git a/src/components/menu-settings/MenuSection.tsx b/src/components/menu-settings/MenuSection.tsx index 48a30bf0..def6b62e 100644 --- a/src/components/menu-settings/MenuSection.tsx +++ b/src/components/menu-settings/MenuSection.tsx @@ -8,7 +8,7 @@ export function MenuSection({ children, icon, title }: MenuSection) { return ( <>
-
+
{icon}
{title} diff --git a/src/components/menu-settings/MenuSelectDefaultStartCube.tsx b/src/components/menu-settings/MenuSelectDefaultStartCube.tsx index 08ed4a86..b5a3b403 100644 --- a/src/components/menu-settings/MenuSelectDefaultStartCube.tsx +++ b/src/components/menu-settings/MenuSelectDefaultStartCube.tsx @@ -1,93 +1,66 @@ import { useTranslations } from "next-intl"; -import { useRef, useState } from "react"; +import { useState } from "react"; import { useSettingsModalStore } from "@/store/SettingsModalStore"; -import useClickOutside from "@/hooks/useClickOutside"; import { useTimerStore } from "@/store/timerStore"; -import { AnimatePresence, motion } from "framer-motion"; import loadSettings from "@/lib/loadSettings"; import { Cube } from "@/interfaces/Cube"; +import { + Select, + SelectContent, + SelectItem, + SelectTrigger, + SelectValue, +} from "@/components/ui/select"; export default function MenuSelectDefaultStartCube() { const { settings, setSettings } = useSettingsModalStore(); const t = useTranslations("Index"); - - const [open, setOpen] = useState(false); const { cubes } = useTimerStore(); - const componentRef = useRef(null); - const handleClose = () => { - setOpen(false); - }; + const handleCubeSelect = (cubeId: string) => { + // if selected no cube at start + if (cubeId === "none") { + const currentSettings = loadSettings(); + currentSettings.preferences.defaultCube.cube = null; + setSettings(currentSettings); + window.localStorage.setItem("settings", JSON.stringify(currentSettings)); + return; + } - const handleCubeSelect = (cube: Cube | null) => { + // if selected a cube for start + const selection = cubes?.find((i) => i.id === cubeId); + if (!selection) return; const currentSettings = loadSettings(); - currentSettings.preferences.defaultCube.cube = cube; + currentSettings.preferences.defaultCube.cube = selection; setSettings(currentSettings); window.localStorage.setItem("settings", JSON.stringify(currentSettings)); - handleClose(); }; - const defaultCube = settings.preferences.defaultCube.cube; - - useClickOutside(componentRef, handleClose); + const defaultCube = settings.preferences.defaultCube.cube?.id; return (
-
{t("Settings-menu.default-cube")}
+
{t("Settings-menu.auto-select")}
-
); diff --git a/src/components/menu-settings/MenuSelectLanguage.tsx b/src/components/menu-settings/MenuSelectLanguage.tsx index 6e1f6527..9a3d1b91 100644 --- a/src/components/menu-settings/MenuSelectLanguage.tsx +++ b/src/components/menu-settings/MenuSelectLanguage.tsx @@ -10,6 +10,13 @@ import { GlobeAltIcon } from "@heroicons/react/24/solid"; import { Button } from "../button"; import useClickOutside from "@/hooks/useClickOutside"; import useOpenClose from "@/hooks/useOpenClose"; +import { + Select, + SelectContent, + SelectItem, + SelectTrigger, + SelectValue, +} from "@/components/ui/select"; export default function MenuSelectLanguage() { const { isOpen, close, toggle } = useOpenClose(false); @@ -20,8 +27,8 @@ export default function MenuSelectLanguage() { const router = useRouter(); const locale = useLocale(); - function onSelectChange(event: any) { - const nextLocale = event.target.id; + function handleLanguageChange(event: any) { + const nextLocale = event; setSettingsOpen(false); router.replace(`${window.location.origin}/${nextLocale}`); } @@ -42,36 +49,20 @@ export default function MenuSelectLanguage() {
{t("language")}
-
diff --git a/src/components/menu-settings/ThemeSelect.tsx b/src/components/menu-settings/ThemeSelect.tsx index 3f2b2098..405f43c2 100644 --- a/src/components/menu-settings/ThemeSelect.tsx +++ b/src/components/menu-settings/ThemeSelect.tsx @@ -2,6 +2,7 @@ import { Themes } from "@/interfaces/types/Themes"; import loadSettings from "@/lib/loadSettings"; import { useBackgroundImageStore } from "@/store/BackgroundThemeStore"; import { useSettingsModalStore } from "@/store/SettingsModalStore"; +import { useTheme } from "next-themes"; interface Variation { bg: string; @@ -13,6 +14,7 @@ interface Variation { export default function ThemeSelect() { const { settings, setSettings } = useSettingsModalStore(); const { backgroundImage, deleteBackgroundImage } = useBackgroundImageStore(); + const { setTheme } = useTheme(); const variation: Variation[] = [ { bg: "bg-neutral-100", @@ -45,30 +47,30 @@ export default function ThemeSelect() { currentSettings.theme.background.color = theme; window.localStorage.setItem("settings", JSON.stringify(currentSettings)); setSettings(currentSettings); + setTheme(themeKey); }; return ( -
+
{variation.map((item) => ( -
+
handleSelectTheme(item.key)} + className="flex flex-col items-center justify-center" + >
handleSelectTheme(item.key)} - className="flex flex-col items-center justify-center" - > -
-
{item.name}
-
+ className={`cursor-pointer size-20 rounded-full ${item.bg} ${ + item.key === settings.theme.background.color + ? "outline outline-blue-600" + : "border border-neutral-400" + }`} + >
+
{item.name}
))} {backgroundImage && (
X
diff --git a/src/components/select/Select.tsx b/src/components/select/Select.tsx deleted file mode 100644 index 3e2f21d2..00000000 --- a/src/components/select/Select.tsx +++ /dev/null @@ -1,62 +0,0 @@ -import useOpenClose from "@/hooks/useOpenClose"; -import useSelect from "@/hooks/useSelect"; -import genId from "@/lib/genId"; -import { SelectContainer } from "@/components/select/SelectContainer"; -import { SelectToggleButton } from "@/components/select/SelectToggleButton"; -import { SelectOptionList } from "@/components/select/SelectOptionList"; -import { SelectOption } from "@/components/select/SelectOption"; - -interface SelectProps { - list: Item[]; - defaultLabel: string; - className?: string; - onChange: (selectedValue: string) => void; -} - -interface Item { - name: string; - id: string; -} - -export default function Select({ - list, - defaultLabel, - className, - onChange, -}: SelectProps) { - const { isOpen, close, toggle } = useOpenClose(false); - const { selectedValue, handleSelect } = useSelect(defaultLabel); - - const handleOptionSelect = (item: Item) => { - handleSelect(item.name); - close(); - onChange(item.name); - }; - - return ( - <> - { - close(); - }} - > - - - {list.map((item: Item) => ( - handleOptionSelect(item)} - /> - ))} - - - - ); -} diff --git a/src/components/select/SelectContainer.tsx b/src/components/select/SelectContainer.tsx deleted file mode 100644 index ffec8dfd..00000000 --- a/src/components/select/SelectContainer.tsx +++ /dev/null @@ -1,24 +0,0 @@ -import { useRef } from "react"; -import useClickOutside from "@/hooks/useClickOutside"; - -interface SelectContainer { - handleClickOutside: () => void; - children: React.ReactNode; - className?: string; -} - -export function SelectContainer({ - handleClickOutside, - children, - className, -}: SelectContainer) { - const componentRef = useRef(null); - useClickOutside(componentRef, handleClickOutside); - return ( - <> -
- {children} -
- - ); -} diff --git a/src/components/select/SelectOption.tsx b/src/components/select/SelectOption.tsx deleted file mode 100644 index 191f2cd3..00000000 --- a/src/components/select/SelectOption.tsx +++ /dev/null @@ -1,23 +0,0 @@ -interface SelectOption { - label: string; - selected: string; - onSelect: () => void; -} - -export function SelectOption({ label, selected, onSelect }: SelectOption) { - const active = label === selected; - return ( - <> -
-
{label}
-
- - ); -} diff --git a/src/components/select/SelectOptionList.tsx b/src/components/select/SelectOptionList.tsx deleted file mode 100644 index 64c5220a..00000000 --- a/src/components/select/SelectOptionList.tsx +++ /dev/null @@ -1,25 +0,0 @@ -import { AnimatePresence, motion } from "framer-motion"; - -interface SelectOptionList { - isOpen: boolean; - children: React.ReactNode; -} - -export function SelectOptionList({ isOpen, children }: SelectOptionList) { - return ( - <> - - {isOpen ? ( - - {children} - - ) : null} - - - ); -} diff --git a/src/components/select/SelectToggleButton.tsx b/src/components/select/SelectToggleButton.tsx deleted file mode 100644 index dcc68db4..00000000 --- a/src/components/select/SelectToggleButton.tsx +++ /dev/null @@ -1,31 +0,0 @@ -import { ChevronUpDownIcon } from "@heroicons/react/16/solid"; - -interface SelectToggleButton { - text: string; - handleClick: () => void; - isOpen: boolean; -} - -export function SelectToggleButton({ - text, - handleClick, - isOpen, -}: SelectToggleButton) { - return ( - <> - - - ); -} diff --git a/src/components/select/index.ts b/src/components/select/index.ts deleted file mode 100644 index df583fc7..00000000 --- a/src/components/select/index.ts +++ /dev/null @@ -1 +0,0 @@ -export { default as Select } from "./Select";