Skip to content

Commit

Permalink
Revisit ThemeSelect.tsx
Browse files Browse the repository at this point in the history
  • Loading branch information
0x1eef committed Oct 13, 2024
1 parent 8f409c4 commit ebd4bb3
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 11 deletions.
6 changes: 6 additions & 0 deletions share/al-quran.reflectslight.io/CHANGELOG.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions src/css/base/_select.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

Expand Down
6 changes: 4 additions & 2 deletions src/js/components/AudioControl.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand All @@ -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);
Expand Down
3 changes: 2 additions & 1 deletion src/js/components/Select/Option.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ type Props = {
};

export function Option({ children, href, className, onClick }: Props) {
const ref = createRef();

Check failure on line 12 in src/js/components/Select/Option.tsx

View workflow job for this annotation

GitHub Actions / ci

Cannot find name 'createRef'.
return (
<a href={href} className={className} onClick={onClick}>
<a href={href} className={className} onClick={onClick} ref={ref}>
{children as string}
</a>
);
Expand Down
4 changes: 2 additions & 2 deletions src/js/components/Select/ThemeSelect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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>
);
})}
Expand Down
7 changes: 6 additions & 1 deletion src/js/components/Select/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
3 changes: 2 additions & 1 deletion src/js/main/vendor.ts
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -10,6 +10,7 @@ const exports = {
useEffect,
useMemo,
useRef,
createRef,
classNames,
};
Object.assign(window, exports);

0 comments on commit ebd4bb3

Please sign in to comment.