Revisit ThemeSelect.tsx
Some checks are pending
The Quran / ci (push) Waiting to run

This commit is contained in:
0x1eef 2024-10-13 10:57:30 -03:00
parent 8f409c4d68
commit ebd4bb36ca
7 changed files with 26 additions and 11 deletions

View file

@ -2,6 +2,12 @@
* vNEXT
** Revisit ~ThemeSelect.tsx~ for touch devices
On touch devices it is now easier to change themes thanks to
a container that has a larger height and width than the theme
icon it contains. Along with this change, the theme icons have
become larger and less circular
** Reduce default width
The look and feel of the website has changed to be more like
a book that could fit in the palm of your hand

View file

@ -13,12 +13,12 @@
}
.react-select.theme-select {
ul li,
ul li a {
-webkit-tap-highlight-color: transparent;
}
.circle {
width: 16px;
height: 16px;
border-radius: 12px;
background: var(--primary-color);
border-radius: 10px;
}
}

View file

@ -32,7 +32,9 @@ export function AudioControl({
return;
}
if (enabled) {
audio.src = [audioBaseUrl, surah.id, `${ayah.id}.mp3?v=${commitId}`].join("/");
audio.src = [audioBaseUrl, surah.id, `${ayah.id}.mp3?v=${commitId}`].join(
"/",
);
play(audio);
}
}, [hidden, enabled, ayah?.id, audioBaseUrl]);
@ -42,7 +44,7 @@ export function AudioControl({
"[data-audio-base-url]",
);
const url = el?.dataset?.audioBaseUrl;
const commit = el?.dataset?.commitId
const commit = el?.dataset?.commitId;
if (url?.length) {
setAudioBaseUrl(url);
setCommitId(commit);

View file

@ -9,8 +9,9 @@ type Props = {
};
export function Option({ children, href, className, onClick }: Props) {
const ref = createRef();
return (
<a href={href} className={className} onClick={onClick}>
<a href={href} className={className} onClick={onClick} ref={ref}>
{children as string}
</a>
);

View file

@ -15,10 +15,10 @@ export function ThemeSelect({ theme, setTheme }: Props) {
<Select.Option
key={i}
onClick={() => setTheme(t)}
className={classNames("block circle mb-1", t)}
className="flex justify-end w-10 h-6"
value={t}
>
<span className="block w-full h-full" />
<span className={classNames("rounded w-5 h-5", t)} />
</Select.Option>
);
})}

View file

@ -37,7 +37,12 @@ function Select({ value, children: options, className }: Props) {
<li
key={key}
className={classNames({ hidden: isHidden })}
onClick={(e) => [e.stopPropagation(), setOpen(!isOpen)]}
onClick={(e) => {
e.stopPropagation();
const { ref } = n.props;
setOpen(!isOpen);
ref.current?.click();
}}
>
{n}
</li>

View file

@ -1,4 +1,4 @@
import { render } from "preact";
import { render, createRef } from "preact";
import { useState, useEffect, useMemo, useRef } from "preact/hooks";
import * as React from "preact/compat";
import classNames from "classnames";
@ -10,6 +10,7 @@ const exports = {
useEffect,
useMemo,
useRef,
createRef,
classNames,
};
Object.assign(window, exports);