Skip to content

Commit fe7a57f

Browse files
committed
fix: theme toggle to use classname instead of pressable state
1 parent 048df88 commit fe7a57f

File tree

2 files changed

+14
-30
lines changed

2 files changed

+14
-30
lines changed

apps/showcase/components/ThemeToggle.tsx

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { setAndroidNavigationBar } from '~/lib/android-navigation-bar';
33
import { MoonStar } from '~/lib/icons/MoonStar';
44
import { Sun } from '~/lib/icons/Sun';
55
import { useColorScheme } from '~/lib/useColorScheme';
6-
import { cn } from '~/lib/utils';
76

87
export function ThemeToggle() {
98
const { isDarkColorScheme, setColorScheme } = useColorScheme();
@@ -19,20 +18,13 @@ export function ThemeToggle() {
1918
onPress={toggleColorScheme}
2019
className='web:ring-offset-background web:transition-colors web:focus-visible:outline-none web:focus-visible:ring-2 web:focus-visible:ring-ring web:focus-visible:ring-offset-2'
2120
>
22-
{({ pressed }) => (
23-
<View
24-
className={cn(
25-
'flex-1 aspect-square pt-0.5 justify-center items-start web:px-5',
26-
pressed && 'opacity-70'
27-
)}
28-
>
29-
{isDarkColorScheme ? (
30-
<MoonStar className='text-foreground' size={23} strokeWidth={1.25} />
31-
) : (
32-
<Sun className='text-foreground' size={24} strokeWidth={1.25} />
33-
)}
34-
</View>
35-
)}
21+
<View className='flex-1 aspect-square pt-0.5 justify-center items-start web:px-5 active:opacity-70'>
22+
{isDarkColorScheme ? (
23+
<MoonStar className='text-foreground' size={23} strokeWidth={1.25} />
24+
) : (
25+
<Sun className='text-foreground' size={24} strokeWidth={1.25} />
26+
)}
27+
</View>
3628
</Pressable>
3729
);
3830
}

packages/templates/starter-base/components/ThemeToggle.tsx

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import { setAndroidNavigationBar } from '~/lib/android-navigation-bar';
33
import { MoonStar } from '~/lib/icons/MoonStar';
44
import { Sun } from '~/lib/icons/Sun';
55
import { useColorScheme } from '~/lib/useColorScheme';
6-
import { cn } from '~/lib/utils';
76

87
export function ThemeToggle() {
98
const { isDarkColorScheme, setColorScheme } = useColorScheme();
@@ -19,20 +18,13 @@ export function ThemeToggle() {
1918
onPress={toggleColorScheme}
2019
className='web:ring-offset-background web:transition-colors web:focus-visible:outline-none web:focus-visible:ring-2 web:focus-visible:ring-ring web:focus-visible:ring-offset-2'
2120
>
22-
{({ pressed }) => (
23-
<View
24-
className={cn(
25-
'flex-1 aspect-square pt-0.5 justify-center items-start web:px-5',
26-
pressed && 'opacity-70'
27-
)}
28-
>
29-
{isDarkColorScheme ? (
30-
<MoonStar className='text-foreground' size={23} strokeWidth={1.25} />
31-
) : (
32-
<Sun className='text-foreground' size={24} strokeWidth={1.25} />
33-
)}
34-
</View>
35-
)}
21+
<View className='flex-1 aspect-square pt-0.5 justify-center items-start web:px-5 active:opacity-70'>
22+
{isDarkColorScheme ? (
23+
<MoonStar className='text-foreground' size={23} strokeWidth={1.25} />
24+
) : (
25+
<Sun className='text-foreground' size={24} strokeWidth={1.25} />
26+
)}
27+
</View>
3628
</Pressable>
3729
);
3830
}

0 commit comments

Comments
 (0)