Skip to content

Commit 484e736

Browse files
authored
fix: remove dark theme from blabsy (#449)
1 parent 8b5682c commit 484e736

5 files changed

Lines changed: 37 additions & 55 deletions

File tree

platforms/blabsy/src/components/common/seo.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { useRouter } from 'next/router';
22
import Head from 'next/head';
33
import { siteURL } from '@lib/env';
44

5-
type MainLayoutProps = {
5+
type SEOProps = {
66
title: string;
77
image?: string;
88
description?: string;
@@ -12,7 +12,7 @@ export function SEO({
1212
title,
1313
image,
1414
description
15-
}: MainLayoutProps): JSX.Element {
15+
}: SEOProps): JSX.Element {
1616
const { asPath } = useRouter();
1717

1818
return (

platforms/blabsy/src/components/modal/display-modal.tsx

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,13 @@
11
import { UserAvatar } from '@components/user/user-avatar';
22
import { UserName } from '@components/user/user-name';
3-
import { InputThemeRadio } from '@components/input/input-theme-radio';
43
import { Button } from '@components/ui/button';
54
import { InputAccentRadio } from '@components/input/input-accent-radio';
6-
import type { Theme, Accent } from '@lib/types/theme';
5+
import type { Accent } from '@lib/types/theme';
76

87
type DisplayModalProps = {
98
closeModal: () => void;
109
};
1110

12-
const themes: Readonly<[Theme, string][]> = [
13-
['light', 'Default'],
14-
['dim', 'Dim'],
15-
['dark', 'Lights out']
16-
];
17-
1811
const accentsColor: Readonly<Accent[]> = [
1912
'blue',
2013
'yellow',
@@ -77,23 +70,7 @@ export function DisplayModal({ closeModal }: DisplayModalProps): JSX.Element {
7770
))}
7871
</div>
7972
</div>
80-
<div className='flex w-full flex-col gap-1'>
81-
<p className='text-sm font-bold text-light-secondary dark:text-dark-secondary'>
82-
Background
83-
</p>
84-
<div
85-
className='hover-animation grid grid-rows-3 gap-3 rounded-2xl bg-main-sidebar-background
86-
px-4 py-3 xs:grid-cols-3 xs:grid-rows-none'
87-
>
88-
{themes.map(([themeType, label]) => (
89-
<InputThemeRadio
90-
type={themeType}
91-
label={label}
92-
key={themeType}
93-
/>
94-
))}
95-
</div>
96-
</div>
73+
{/* Theme selection removed - always dark mode */}
9774
<Button
9875
className='bg-main-accent px-4 py-1.5 font-bold
9976
text-white hover:bg-main-accent/90 active:bg-main-accent/75'

platforms/blabsy/src/lib/context/theme-context.tsx

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,8 @@ type ThemeContextProviderProps = {
2222
};
2323

2424
function setInitialTheme(): Theme {
25-
if (typeof window === 'undefined') return 'dark';
26-
27-
const savedTheme = localStorage.getItem('theme') as Theme | null;
28-
const prefersDark = window.matchMedia(
29-
'(prefers-color-scheme: dark)'
30-
).matches;
31-
32-
return savedTheme ?? (prefersDark ? 'dark' : 'light');
25+
// Always return dark theme - no light mode option
26+
return 'dark';
3327
}
3428

3529
function setInitialAccent(): Accent {
@@ -50,50 +44,60 @@ export function ThemeContextProvider({
5044
const { id: userId, theme: userTheme, accent: userAccent } = user ?? {};
5145

5246
useEffect(() => {
53-
if (user && userTheme) setTheme(userTheme);
47+
// Always force dark theme, ignore user theme preference
48+
setTheme('dark');
5449
}, [userId, userTheme]);
5550

5651
useEffect(() => {
5752
if (user && userAccent) setAccent(userAccent);
5853
}, [userId, userAccent]);
5954

6055
useEffect(() => {
61-
const flipTheme = (theme: Theme): NodeJS.Timeout | undefined => {
56+
const flipTheme = (): NodeJS.Timeout | undefined => {
6257
const root = document.documentElement;
63-
const targetTheme = theme === 'dim' ? 'dark' : theme;
64-
65-
if (targetTheme === 'dark') root.classList.add('dark');
66-
else root.classList.remove('dark');
58+
// Always use dark theme
59+
const forcedTheme: Theme = 'dark';
60+
61+
// Always ensure dark class is present and never remove it
62+
root.classList.add('dark');
63+
// Prevent any accidental removal
64+
if (!root.classList.contains('dark')) {
65+
root.classList.add('dark');
66+
}
6767

6868
root.style.setProperty(
6969
'--main-background',
70-
`var(--${theme}-background)`
70+
`var(--${forcedTheme}-background)`
7171
);
7272

7373
root.style.setProperty(
7474
'--main-search-background',
75-
`var(--${theme}-search-background)`
75+
`var(--${forcedTheme}-search-background)`
7676
);
7777

7878
root.style.setProperty(
7979
'--main-sidebar-background',
80-
`var(--${theme}-sidebar-background)`
80+
`var(--${forcedTheme}-sidebar-background)`
8181
);
8282

8383
if (user) {
84-
localStorage.setItem('theme', theme);
84+
localStorage.setItem('theme', forcedTheme);
8585
return setTimeout(
86-
() => void updateUserTheme(user.id, { theme }),
86+
() => void updateUserTheme(user.id, { theme: forcedTheme }),
8787
500
8888
);
8989
}
9090

9191
return undefined;
9292
};
9393

94-
const timeoutId = flipTheme(theme);
94+
const timeoutId = flipTheme();
95+
// Ensure dark class is always applied on mount and updates
96+
const root = document.documentElement;
97+
root.classList.add('dark');
98+
9599
return () => clearTimeout(timeoutId);
96-
}, [userId, theme]);
100+
}, [userId]);
97101

98102
useEffect(() => {
99103
const flipAccent = (accent: Accent): NodeJS.Timeout | undefined => {
@@ -118,7 +122,10 @@ export function ThemeContextProvider({
118122

119123
const changeTheme = ({
120124
target: { value }
121-
}: ChangeEvent<HTMLInputElement>): void => setTheme(value as Theme);
125+
}: ChangeEvent<HTMLInputElement>): void => {
126+
// Ignore theme changes - always keep dark mode
127+
setTheme('dark');
128+
};
122129

123130
const changeAccent = ({
124131
target: { value }

platforms/blabsy/src/pages/404.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
import Error from 'next/error';
2-
import { useTheme } from '@lib/context/theme-context';
32
import { SEO } from '@components/common/seo';
43

54
export default function NotFound(): JSX.Element {
6-
const { theme } = useTheme();
7-
8-
const isDarkMode = ['dim', 'dark'].includes(theme);
5+
// Always use dark mode
6+
const isDarkMode = true;
97

108
return (
119
<>
1210
<SEO
1311
title='Page not found / Blabsy'
14-
description='Sorry we couldn’t find the page you were looking for.'
12+
description='Sorry we could not find the page you were looking for.'
1513
image='/404.png'
1614
/>
1715
<Error statusCode={404} withDarkMode={isDarkMode} />

platforms/blabsy/src/pages/_document.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { Html, Head, Main, NextScript } from 'next/document';
22

33
export default function Document(): JSX.Element {
44
return (
5-
<Html lang='en'>
5+
<Html lang='en' className='dark'>
66
<Head />
77
<body>
88
<Main />

0 commit comments

Comments
 (0)