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
72 changes: 3 additions & 69 deletions src/components/ThemePicker.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
import { t } from '@/i18n/site'
import { useCallback, useEffect, useRef, useState } from 'react'
import { flushSync } from 'react-dom'
import { ChevronLeftIcon, ChevronRightIcon } from '@/components/icons'
import {
BrushIcon,
ChevronLeftIcon,
ChevronRightIcon,
CrossIcon,
} from '@/components/icons'
import {
HINT_KEY,
OPEN_PICKER_EVENT,
PICKER_STATE_EVENT,
SITE_THEMES,
Expand Down Expand Up @@ -45,22 +39,12 @@ export function ThemePicker() {
const portrait = useIsNarrow()
const [open, setOpen] = useState(false)
const [index, setIndex] = useState(0)
const [hint, setHint] = useState(false)
const dialogRef = useRef<HTMLDivElement>(null)
const restoreFocus = useRef<HTMLElement | null>(null)
/** Whether the trigger was wearing a focus ring when it opened the picker. */
const restoreRing = useRef(false)
const indexRef = useRef(0)

const markHintSeen = useCallback(() => {
setHint(false)
try {
localStorage.setItem(HINT_KEY, 'true')
} catch {
/* storage unavailable */
}
}, [])

const openPicker = useCallback(() => {
const current = readTheme()
const at = SITE_THEMES.findIndex((t) => t.id === current)
Expand All @@ -71,8 +55,7 @@ export function ThemePicker() {
restoreFocus.current = trigger
restoreRing.current = trigger?.matches(':focus-visible') ?? false
setOpen(true)
markHintSeen()
}, [markHintSeen])
}, [])

const close = useCallback(() => {
setOpen(false)
Expand Down Expand Up @@ -192,19 +175,6 @@ export function ThemePicker() {
if (open) warmAround(index)
}, [open, index, warmAround])

useEffect(() => {
let seen = false
try {
seen = localStorage.getItem(HINT_KEY) === 'true'
} catch {
/* storage unavailable: show nothing rather than nag every visit */
seen = true
}
if (seen) return
const timer = setTimeout(() => setHint(true), 1600)
return () => clearTimeout(timer)
}, [])

useEffect(() => {
if (!open) return
dialogRef.current?.focus()
Expand All @@ -228,43 +198,7 @@ export function ThemePicker() {
return () => window.removeEventListener('keydown', onKeyDown)
}, [open, step, close, choose])

if (!open) {
if (!hint) return null
return (
<div
role="status"
className="notice-in fixed top-[104px] right-4 z-(--z-dropdown) w-72 sm:top-[68px]"
>
<div className="ring-elevation relative bg-surface">
<button
type="button"
onClick={openPicker}
className="flex w-full items-start gap-3 p-4 pr-10 text-left transition-colors duration-150 ease-out hover:bg-surface-2"
>
<BrushIcon className="mt-0.5 size-5 shrink-0 text-brand" />
<span>
<span className="block font-sans text-sm font-medium text-text">
{t('Change the theme')}
</span>
<span className="mt-1 block text-[13px] leading-relaxed text-text-secondary">
{t(
'Press T, or tap here. Inside Omarchy it is Super + Ctrl + Shift + Space.',
)}
</span>
</span>
</button>
<button
type="button"
aria-label={t('Dismiss')}
onClick={markHintSeen}
className="absolute top-2 right-2 flex size-8 items-center justify-center text-text-muted transition-colors duration-150 ease-out hover:text-text"
>
<CrossIcon className="size-4" />
</button>
</div>
</div>
)
}
if (!open) return null

return (
<>
Expand Down
1 change: 0 additions & 1 deletion src/i18n/messages/ar.json
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@
"Omarchy on GitHub": "Omarchy على GitHub",
"Main pages": "الصفحات الرئيسية",
"Change the theme": "غيّر السمة",
"Press T, or tap here. Inside Omarchy it is Super + Ctrl + Shift + Space.": "اضغط T أو انقر هنا. داخل Omarchy الاختصار هو Super + Ctrl + Shift + Space.",
"Dismiss": "إغلاق",
"Theme picker": "منتقي السمات",
"Previous theme": "السمة السابقة",
Expand Down
1 change: 0 additions & 1 deletion src/i18n/messages/bn.json
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@
"Omarchy on GitHub": "GitHub-এ Omarchy",
"Main pages": "মূল পৃষ্ঠাগুলো",
"Change the theme": "থিম বদলান",
"Press T, or tap here. Inside Omarchy it is Super + Ctrl + Shift + Space.": "T চাপুন বা এখানে ট্যাপ করুন। Omarchy-তে শর্টকাট Super + Ctrl + Shift + Space।",
"Dismiss": "বন্ধ করুন",
"Theme picker": "থিম বাছাইকারী",
"Previous theme": "আগের থিম",
Expand Down
1 change: 0 additions & 1 deletion src/i18n/messages/ca.json
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@
"Omarchy on GitHub": "Omarchy a GitHub",
"Main pages": "Pàgines principals",
"Change the theme": "Canvia el tema",
"Press T, or tap here. Inside Omarchy it is Super + Ctrl + Shift + Space.": "Prem T o toca aquí. Dins d'Omarchy és Super + Ctrl + Shift + Space.",
"Dismiss": "Descarta",
"Theme picker": "Selector de temes",
"Previous theme": "Tema anterior",
Expand Down
1 change: 0 additions & 1 deletion src/i18n/messages/da.json
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@
"Omarchy on GitHub": "Omarchy på GitHub",
"Main pages": "Hovedsider",
"Change the theme": "Skift tema",
"Press T, or tap here. Inside Omarchy it is Super + Ctrl + Shift + Space.": "Tryk på T, eller klik her. I Omarchy er genvejen Super + Ctrl + Shift + Space.",
"Dismiss": "Luk",
"Theme picker": "Temavælger",
"Previous theme": "Forrige tema",
Expand Down
1 change: 0 additions & 1 deletion src/i18n/messages/el.json
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@
"Omarchy on GitHub": "Το Omarchy στο GitHub",
"Main pages": "Κύριες σελίδες",
"Change the theme": "Άλλαξε θέμα",
"Press T, or tap here. Inside Omarchy it is Super + Ctrl + Shift + Space.": "Πάτησε T ή άγγιξε εδώ. Στο Omarchy είναι Super + Ctrl + Shift + Space.",
"Dismiss": "Κλείσιμο",
"Theme picker": "Επιλογέας θέματος",
"Previous theme": "Προηγούμενο θέμα",
Expand Down
1 change: 0 additions & 1 deletion src/i18n/messages/es-MX.json
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@
"Omarchy on GitHub": "Omarchy en GitHub",
"Main pages": "Páginas principales",
"Change the theme": "Cambia el tema",
"Press T, or tap here. Inside Omarchy it is Super + Ctrl + Shift + Space.": "Presiona T o toca aquí. En Omarchy es Super + Ctrl + Shift + Space.",
"Dismiss": "Descartar",
"Theme picker": "Selector de temas",
"Previous theme": "Tema anterior",
Expand Down
1 change: 0 additions & 1 deletion src/i18n/messages/fi.json
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,6 @@
"Omarchy on GitHub": "Omarchy GitHubissa",
"Main pages": "Pääsivut",
"Change the theme": "Vaihda teemaa",
"Press T, or tap here. Inside Omarchy it is Super + Ctrl + Shift + Space.": "Paina T tai napauta tästä. Omarchyssa se on Super + Ctrl + Shift + Space.",
"Dismiss": "Sulje",
"Theme picker": "Teeman valitsin",
"Previous theme": "Edellinen teema",
Expand Down
1 change: 0 additions & 1 deletion src/i18n/messages/fil.json
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@
"Omarchy on GitHub": "Omarchy sa GitHub",
"Main pages": "Mga pangunahing pahina",
"Change the theme": "Palitan ang tema",
"Press T, or tap here. Inside Omarchy it is Super + Ctrl + Shift + Space.": "Pindutin ang T o i-tap dito. Sa Omarchy, Super + Ctrl + Shift + Space ang shortcut.",
"Dismiss": "Isara",
"Theme picker": "Tagapili ng tema",
"Previous theme": "Naunang tema",
Expand Down
1 change: 0 additions & 1 deletion src/i18n/messages/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@
"Omarchy on GitHub": "Omarchy sur GitHub",
"Main pages": "Pages principales",
"Change the theme": "Changer de thème",
"Press T, or tap here. Inside Omarchy it is Super + Ctrl + Shift + Space.": "Appuyez sur T ou cliquez ici. Dans Omarchy, utilisez Super + Ctrl + Shift + Space.",
"Dismiss": "Fermer",
"Theme picker": "Sélecteur de thème",
"Previous theme": "Thème précédent",
Expand Down
1 change: 0 additions & 1 deletion src/i18n/messages/ga.json
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@
"Omarchy on GitHub": "Omarchy ar GitHub",
"Main pages": "Príomhleathanaigh",
"Change the theme": "Athraigh an téama",
"Press T, or tap here. Inside Omarchy it is Super + Ctrl + Shift + Space.": "Brúigh T, nó tapáil anseo. In Omarchy is é Super + Ctrl + Shift + Space é.",
"Dismiss": "Dún",
"Theme picker": "Roghnóir téama",
"Previous theme": "An téama roimhe",
Expand Down
1 change: 0 additions & 1 deletion src/i18n/messages/hi.json
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@
"Omarchy on GitHub": "GitHub पर Omarchy",
"Main pages": "मुख्य पृष्ठ",
"Change the theme": "थीम बदलें",
"Press T, or tap here. Inside Omarchy it is Super + Ctrl + Shift + Space.": "T दबाएँ या यहाँ टैप करें। Omarchy में शॉर्टकट Super + Ctrl + Shift + Space है।",
"Dismiss": "बंद करें",
"Theme picker": "थीम चयनकर्ता",
"Previous theme": "पिछली थीम",
Expand Down
1 change: 0 additions & 1 deletion src/i18n/messages/hu.json
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@
"Omarchy on GitHub": "Omarchy a GitHubon",
"Main pages": "Főbb oldalak",
"Change the theme": "Téma váltása",
"Press T, or tap here. Inside Omarchy it is Super + Ctrl + Shift + Space.": "Nyomd meg a T-t, vagy koppints ide. Omarchyn a Super + Ctrl + Shift + Space a billentyűparancs.",
"Dismiss": "Bezárás",
"Theme picker": "Témaválasztó",
"Previous theme": "Előző téma",
Expand Down
1 change: 0 additions & 1 deletion src/i18n/messages/is.json
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@
"Omarchy on GitHub": "Omarchy á GitHub",
"Main pages": "Aðalsíður",
"Change the theme": "Breyta þema",
"Press T, or tap here. Inside Omarchy it is Super + Ctrl + Shift + Space.": "Ýttu á T eða smelltu hér. Innan Omarchy er það Super + Ctrl + Shift + Space.",
"Dismiss": "Loka",
"Theme picker": "Þemaval",
"Previous theme": "Fyrra þema",
Expand Down
1 change: 0 additions & 1 deletion src/i18n/messages/it.json
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@
"Omarchy on GitHub": "Omarchy su GitHub",
"Main pages": "Pagine principali",
"Change the theme": "Cambia tema",
"Press T, or tap here. Inside Omarchy it is Super + Ctrl + Shift + Space.": "Premi T o tocca qui. In Omarchy la scorciatoia è Super + Ctrl + Shift + Space.",
"Dismiss": "Chiudi",
"Theme picker": "Selettore dei temi",
"Previous theme": "Tema precedente",
Expand Down
1 change: 0 additions & 1 deletion src/i18n/messages/ja.json
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@
"Omarchy on GitHub": "GitHubのOmarchy",
"Main pages": "主なページ",
"Change the theme": "テーマを変更",
"Press T, or tap here. Inside Omarchy it is Super + Ctrl + Shift + Space.": "Tキーを押すか、ここをタップ。Omarchy内ではSuper + Ctrl + Shift + Spaceです。",
"Dismiss": "閉じる",
"Theme picker": "テーマ選択",
"Previous theme": "前のテーマ",
Expand Down
1 change: 0 additions & 1 deletion src/i18n/messages/ko.json
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@
"Omarchy on GitHub": "GitHub의 Omarchy",
"Main pages": "주요 페이지",
"Change the theme": "테마 바꾸기",
"Press T, or tap here. Inside Omarchy it is Super + Ctrl + Shift + Space.": "T를 누르거나 여기를 탭하세요. Omarchy에서는 Super + Ctrl + Shift + Space입니다.",
"Dismiss": "닫기",
"Theme picker": "테마 선택기",
"Previous theme": "이전 테마",
Expand Down
1 change: 0 additions & 1 deletion src/i18n/messages/lt.json
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@
"Omarchy on GitHub": "„Omarchy“ platformoje „GitHub“",
"Main pages": "Pagrindiniai puslapiai",
"Change the theme": "Keisti temą",
"Press T, or tap here. Inside Omarchy it is Super + Ctrl + Shift + Space.": "Spauskite T arba bakstelėkite čia. „Omarchy“ sistemoje — Super + Ctrl + Shift + Space.",
"Dismiss": "Užverti",
"Theme picker": "Temų parinkiklis",
"Previous theme": "Ankstesnė tema",
Expand Down
1 change: 0 additions & 1 deletion src/i18n/messages/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@
"Omarchy on GitHub": "Omarchy op GitHub",
"Main pages": "Hoofdpagina's",
"Change the theme": "Thema wijzigen",
"Press T, or tap here. Inside Omarchy it is Super + Ctrl + Shift + Space.": "Druk op T, of tik hier. In Omarchy is het Super + Ctrl + Shift + Space.",
"Dismiss": "Sluiten",
"Theme picker": "Themakiezer",
"Previous theme": "Vorig thema",
Expand Down
1 change: 0 additions & 1 deletion src/i18n/messages/no.json
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,6 @@
"Position in the track": "Posisjon i sporet",
"Posts are shown in their original language.": "Innleggene vises på originalspråket.",
"Potato PCs": "Potet-PC-er",
"Press T, or tap here. Inside Omarchy it is Super + Ctrl + Shift + Space.": "Trykk T, eller trykk her. I Omarchy er det Super + Ctrl + Shift + Space.",
"Previous meetups": "Tidligere meetups",
"Previous photo": "Forrige bilde",
"Previous theme": "Forrige tema",
Expand Down
1 change: 0 additions & 1 deletion src/i18n/messages/pl.json
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@
"Omarchy on GitHub": "Omarchy na GitHubie",
"Main pages": "Główne strony",
"Change the theme": "Zmień motyw",
"Press T, or tap here. Inside Omarchy it is Super + Ctrl + Shift + Space.": "Naciśnij T lub dotknij tutaj. W Omarchy to Super + Ctrl + Shift + Space.",
"Dismiss": "Zamknij",
"Theme picker": "Wybór motywu",
"Previous theme": "Poprzedni motyw",
Expand Down
1 change: 0 additions & 1 deletion src/i18n/messages/pt.json
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@
"Omarchy on GitHub": "Omarchy no GitHub",
"Main pages": "Páginas principais",
"Change the theme": "Mudar o tema",
"Press T, or tap here. Inside Omarchy it is Super + Ctrl + Shift + Space.": "Pressiona T ou toca aqui. No Omarchy é Super + Ctrl + Shift + Space.",
"Dismiss": "Dispensar",
"Theme picker": "Seletor de temas",
"Previous theme": "Tema anterior",
Expand Down
1 change: 0 additions & 1 deletion src/i18n/messages/si.json
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@
"Omarchy on GitHub": "GitHubහි Omarchy",
"Main pages": "ප්‍රධාන පිටු",
"Change the theme": "තේමාව වෙනස් කරන්න",
"Press T, or tap here. Inside Omarchy it is Super + Ctrl + Shift + Space.": "T ඔබන්න හෝ මෙහි තට්ටු කරන්න. Omarchy තුළ Super + Ctrl + Shift + Space භාවිත කරන්න.",
"Dismiss": "වසන්න",
"Theme picker": "තේමා තෝරනය",
"Previous theme": "පෙර තේමාව",
Expand Down
1 change: 0 additions & 1 deletion src/i18n/messages/sv.json
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@
"Omarchy on GitHub": "Omarchy på GitHub",
"Main pages": "Huvudsidor",
"Change the theme": "Byt tema",
"Press T, or tap here. Inside Omarchy it is Super + Ctrl + Shift + Space.": "Tryck på T eller klicka här. I Omarchy är det Super + Ctrl + Shift + Space.",
"Dismiss": "Stäng",
"Theme picker": "Temaväljare",
"Previous theme": "Föregående tema",
Expand Down
1 change: 0 additions & 1 deletion src/i18n/messages/ta.json
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@
"Omarchy on GitHub": "GitHub-இல் Omarchy",
"Main pages": "முதன்மைப் பக்கங்கள்",
"Change the theme": "தோற்றக்கருவை மாற்றுங்கள்",
"Press T, or tap here. Inside Omarchy it is Super + Ctrl + Shift + Space.": "T அழுத்துங்கள் அல்லது இங்கே தட்டுங்கள். Omarchy-இல் Super + Ctrl + Shift + Space.",
"Dismiss": "மூடவும்",
"Theme picker": "தோற்றக்கருத் தேர்வி",
"Previous theme": "முந்தைய தோற்றக்கரு",
Expand Down
1 change: 0 additions & 1 deletion src/i18n/messages/th.json
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@
"Omarchy on GitHub": "Omarchy บน GitHub",
"Main pages": "หน้าหลัก",
"Change the theme": "เปลี่ยนธีม",
"Press T, or tap here. Inside Omarchy it is Super + Ctrl + Shift + Space.": "กด T หรือแตะที่นี่ ใน Omarchy ใช้ Super + Ctrl + Shift + Space",
"Dismiss": "ปิด",
"Theme picker": "ตัวเลือกธีม",
"Previous theme": "ธีมก่อนหน้า",
Expand Down
1 change: 0 additions & 1 deletion src/i18n/messages/tr.json
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@
"Omarchy on GitHub": "GitHub'da Omarchy",
"Main pages": "Ana sayfalar",
"Change the theme": "Temayı değiştir",
"Press T, or tap here. Inside Omarchy it is Super + Ctrl + Shift + Space.": "T'ye basın veya buraya dokunun. Omarchy içinde kısayol Super + Ctrl + Shift + Space.",
"Dismiss": "Kapat",
"Theme picker": "Tema seçici",
"Previous theme": "Önceki tema",
Expand Down
1 change: 0 additions & 1 deletion src/i18n/messages/ur.json
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@
"Omarchy on GitHub": "GitHub پر Omarchy",
"Main pages": "مرکزی صفحات",
"Change the theme": "تھیم بدلیں",
"Press T, or tap here. Inside Omarchy it is Super + Ctrl + Shift + Space.": "T دبائیں یا یہاں ٹیپ کریں۔ Omarchy میں شارٹ کٹ Super + Ctrl + Shift + Space ہے۔",
"Dismiss": "بند کریں",
"Theme picker": "تھیم منتخب کرنے والا",
"Previous theme": "پچھلی تھیم",
Expand Down
1 change: 0 additions & 1 deletion src/i18n/messages/uz.json
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@
"Omarchy on GitHub": "Omarchy GitHub’da",
"Main pages": "Asosiy sahifalar",
"Change the theme": "Mavzuni o‘zgartirish",
"Press T, or tap here. Inside Omarchy it is Super + Ctrl + Shift + Space.": "T ni bosing yoki shu yerga teging. Omarchy’da Super + Ctrl + Shift + Space.",
"Dismiss": "Yopish",
"Theme picker": "Mavzu tanlagich",
"Previous theme": "Oldingi mavzu",
Expand Down
1 change: 0 additions & 1 deletion src/i18n/messages/vi.json
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@
"Omarchy on GitHub": "Omarchy trên GitHub",
"Main pages": "Trang chính",
"Change the theme": "Đổi giao diện",
"Press T, or tap here. Inside Omarchy it is Super + Ctrl + Shift + Space.": "Nhấn T hoặc chạm vào đây. Trong Omarchy là Super + Ctrl + Shift + Space.",
"Dismiss": "Đóng",
"Theme picker": "Bộ chọn giao diện",
"Previous theme": "Giao diện trước",
Expand Down
1 change: 0 additions & 1 deletion src/i18n/messages/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,6 @@
"Omarchy on GitHub": "GitHub 上的 Omarchy",
"Main pages": "主要页面",
"Change the theme": "更换主题",
"Press T, or tap here. Inside Omarchy it is Super + Ctrl + Shift + Space.": "按 T,或点这里。在 Omarchy 中的快捷键是 Super + Ctrl + Shift + Space。",
"Dismiss": "关闭",
"Theme picker": "主题选择器",
"Previous theme": "上一个主题",
Expand Down
4 changes: 1 addition & 3 deletions src/lib/theme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,10 @@ export const DEFAULT_THEME = 'tokyo-night'
export const THEME_KEY = 'omarchy-site-theme'
/** Fired on <window> after a theme lands, for canvas renderers to re-read. */
export const THEME_EVENT = 'omarchy-theme'
/** Ask the mounted ThemePicker to open (footer link, welcome notice). */
/** Ask the mounted ThemePicker to open (footer link, menu). */
export const OPEN_PICKER_EVENT = 'omarchy-open-picker'
/** Fired with detail { open } whenever the picker opens or closes. */
export const PICKER_STATE_EVENT = 'omarchy-picker-state'
/** Set once the user has seen the picker or dismissed the welcome notice. */
export const HINT_KEY = 'omarchy-theme-hint-seen'

/** Apply the saved palette before paint, or select one matching the system color scheme.
* The favicon is owned outside React so replacing it cannot break reconciliation. */
Expand Down
Loading