Skip to content

Commit c05e1d2

Browse files
committed
wcag/contrast: split off some of antd-theme and adjust links color
1 parent f90bf40 commit c05e1d2

File tree

3 files changed

+34
-11
lines changed

3 files changed

+34
-11
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
/*
2+
* This file is part of CoCalc: Copyright © 2025 Sagemath, Inc.
3+
* License: MS-RSL – see LICENSE.md for details
4+
*/
5+
6+
import type { ThemeConfig } from "antd";
7+
8+
import { COLORS } from "@cocalc/util/theme";
9+
10+
export function getBaseAntdTheme(): ThemeConfig {
11+
return {
12+
token: {
13+
colorLink: COLORS.BLUE_D,
14+
colorTextDescription: COLORS.GRAY_DD,
15+
},
16+
};
17+
}

src/packages/frontend/app/context.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { useTypedRedux } from "@cocalc/frontend/app-framework";
1212
import { IntlMessage, isIntlMessage } from "@cocalc/frontend/i18n";
1313
import { ACTIVITY_BAR_LABELS } from "@cocalc/frontend/project/page/activity-bar-consts";
1414
import { COLORS } from "@cocalc/util/theme";
15+
import { getBaseAntdTheme } from "./antd-base-theme";
1516
import { NARROW_THRESHOLD_PX, PageStyle } from "./top-nav-consts";
1617
import useAppContext, { AppContext, AppState, calcStyle } from "./use-context";
1718

@@ -79,6 +80,7 @@ export function useAppContextProvider(): AppState {
7980

8081
export function useAntdStyleProvider() {
8182
const other_settings = useTypedRedux("account", "other_settings");
83+
const baseTheme = getBaseAntdTheme();
8284
const rounded = other_settings?.get("antd_rounded", true);
8385
const animate = other_settings?.get("antd_animate", true);
8486
const branded = other_settings?.get("antd_brandcolors", false);
@@ -96,12 +98,11 @@ export function useAntdStyleProvider() {
9698

9799
const algorithm = compact ? { algorithm: theme.compactAlgorithm } : undefined;
98100

99-
const textColors = { colorTextDescription: COLORS.GRAY_DD };
100-
101101
const antdTheme: ThemeConfig = {
102+
...baseTheme,
102103
...algorithm,
103104
token: {
104-
...textColors,
105+
...(baseTheme.token ?? {}),
105106
...brandedColors,
106107
...borderStyle,
107108
...animationStyle,

src/packages/next/pages/_app.tsx

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import "antd/dist/reset.css";
1111
import "@ant-design/v5-patch-for-react-19";
1212

13+
import { ConfigProvider } from "antd";
1314
import { Locale } from "locales/misc";
1415

1516
// Initialize the appBasePath for the frontend codebase.
@@ -20,6 +21,7 @@ import "@cocalc/cdn/dist/codemirror/lib/codemirror.css";
2021
import "@cocalc/cdn/dist/katex/katex.min.css";
2122
import "@cocalc/frontend/editors/slate/elements/elements.css";
2223
import { AppContext, DEFAULT_CONTEXT } from "@cocalc/frontend/app/use-context";
24+
import { getBaseAntdTheme } from "@cocalc/frontend/app/antd-base-theme";
2325

2426
// The IntlProvider makes translated components from the frontend work.
2527
// It's english only, using the fallback defaultMessage.
@@ -35,16 +37,19 @@ function MyApp({
3537
pageProps,
3638
}: // router,
3739
AppProps & { locale: Locale }) {
40+
const antdTheme = getBaseAntdTheme();
3841
return (
3942
<AppContext.Provider value={{ ...DEFAULT_CONTEXT }}>
40-
<IntlProvider
41-
locale={DEFAULT_LOCALE}
42-
messages={{}}
43-
defaultLocale={DEFAULT_LOCALE}
44-
defaultRichTextElements={LOCALIZE_DEFAULT_ELEMENTS}
45-
>
46-
<Component {...pageProps} />
47-
</IntlProvider>
43+
<ConfigProvider theme={antdTheme}>
44+
<IntlProvider
45+
locale={DEFAULT_LOCALE}
46+
messages={{}}
47+
defaultLocale={DEFAULT_LOCALE}
48+
defaultRichTextElements={LOCALIZE_DEFAULT_ELEMENTS}
49+
>
50+
<Component {...pageProps} />
51+
</IntlProvider>
52+
</ConfigProvider>
4853
</AppContext.Provider>
4954
);
5055
}

0 commit comments

Comments
 (0)