Skip to content

Commit

Permalink
Fix secondary button in dark mode
Browse files Browse the repository at this point in the history
  • Loading branch information
kubk committed Nov 15, 2023
1 parent 6677a73 commit f9c7c7e
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/lib/color-scheme/is-dark-theme.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export const isDarkTheme = () => {
return window.matchMedia("(prefers-color-scheme: dark)").matches;
};
1 change: 1 addition & 0 deletions src/screens/deck-review/deck-preview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { Button } from "../../ui/button.tsx";
import { ShareDeckButton } from "./share-deck-button.tsx";
import { useBackButton } from "../../lib/telegram/use-back-button.tsx";
import { useMainButton } from "../../lib/telegram/use-main-button.tsx";
import { isDarkTheme } from "../../lib/color-scheme/is-dark-theme.tsx";

Check failure on line 14 in src/screens/deck-review/deck-preview.tsx

View workflow job for this annotation

GitHub Actions / build (18.x)

'isDarkTheme' is defined but never used

export const DeckPreview = observer(() => {
const reviewStore = useReviewStore();
Expand Down
1 change: 1 addition & 0 deletions src/screens/deck-review/review.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import { useReviewStore } from "../../store/review-store-context.tsx";
import { Button } from "../../ui/button.tsx";
import { useBackButton } from "../../lib/telegram/use-back-button.tsx";
import { useHotkeys } from "react-hotkeys-hook";
import { isDarkTheme } from "../../lib/color-scheme/is-dark-theme.tsx";

Check failure on line 14 in src/screens/deck-review/review.tsx

View workflow job for this annotation

GitHub Actions / build (18.x)

'isDarkTheme' is defined but never used

const rotateBorder = 80;

Expand Down
2 changes: 2 additions & 0 deletions src/screens/deck-review/share-deck-button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ import { assert } from "../../lib/typescript/assert.ts";
import { trimEnd } from "../../lib/string/trim.ts";
import WebApp from "@twa-dev/sdk";
import { Button } from "../../ui/button.tsx";
import { theme } from "../../ui/theme.tsx";

Check failure on line 6 in src/screens/deck-review/share-deck-button.tsx

View workflow job for this annotation

GitHub Actions / build (18.x)

'theme' is defined but never used
import { isDarkTheme } from "../../lib/color-scheme/is-dark-theme.tsx";

Check failure on line 7 in src/screens/deck-review/share-deck-button.tsx

View workflow job for this annotation

GitHub Actions / build (18.x)

'isDarkTheme' is defined but never used

type Props = {
deckId: number;
Expand Down
5 changes: 4 additions & 1 deletion src/ui/button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import React, { useMemo } from "react";
import { colord } from "colord";
import { reset } from "./reset.ts";
import { theme } from "./theme.tsx";
import { isDarkTheme } from "../lib/color-scheme/is-dark-theme.tsx";

type Props = {
mainColor?: string;
Expand Down Expand Up @@ -70,7 +71,9 @@ export const Button = (props: Props) => {
}),
outline &&
css({
backgroundColor: parsedColor.lighten(0.4).toHex(),
backgroundColor: parsedColor
.lighten(isDarkTheme() ? 0.2 : 0.4)
.toHex(),
color: mainColor,
":hover": noPseudoClasses
? undefined
Expand Down

0 comments on commit f9c7c7e

Please sign in to comment.