Add setting for page zoom (#1835)

* add setting for page zoom

* parse integer in zoom change listener

* fix zoom input width

* fix null gets saved as page zoom
This commit is contained in:
Ajay Bura 2024-07-23 19:22:53 +05:30 committed by GitHub
parent 3110505b21
commit b387370aaf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 341 additions and 155 deletions

View file

@ -26,6 +26,30 @@ import { getMxIdLocalPart } from '../../utils/matrix';
import { useSelectedRoom } from '../../hooks/router/useSelectedRoom';
import { useInboxNotificationsSelected } from '../../hooks/router/useInbox';
function SystemEmojiFeature() {
const [twitterEmoji] = useSetting(settingsAtom, 'twitterEmoji');
if (twitterEmoji) {
document.documentElement.style.setProperty('--font-emoji', 'Twemoji');
} else {
document.documentElement.style.setProperty('--font-emoji', 'Twemoji_DISABLED');
}
return null;
}
function PageZoomFeature() {
const [pageZoom] = useSetting(settingsAtom, 'pageZoom');
if (pageZoom === 100) {
document.documentElement.style.removeProperty('font-size');
} else {
document.documentElement.style.setProperty('font-size', `calc(1em * ${pageZoom / 100})`);
}
return null;
}
function FaviconUpdater() {
const roomToUnread = useAtomValue(roomToUnreadAtom);
@ -233,6 +257,8 @@ type ClientNonUIFeaturesProps = {
export function ClientNonUIFeatures({ children }: ClientNonUIFeaturesProps) {
return (
<>
<SystemEmojiFeature />
<PageZoomFeature />
<FaviconUpdater />
<InviteNotifications />
<MessageNotifications />