Skip to content

Commit 563e3a9

Browse files
authored
Merge pull request #8396 from sagemathinc/vbutton-hide-text
frontend/vbar: toggle icon descriptions
2 parents 22a1564 + 2cab4ef commit 563e3a9

40 files changed

+240
-123
lines changed

src/packages/frontend/_colors.sass

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,20 +34,26 @@ $COL_BS_RED: #dc3545
3434
$COL_BG_RED: #d9534f
3535
$COL_FG_RED: #c9302c
3636
$COL_FG_BLUE: #428bca
37+
$COL_BG_WARNING: #f0ad4e
3738
$COL_ANTD_LINK_BLUE: #1677ff
3839
$COL_ANTD_LINK_BLUE_DARK: #003eb3
39-
$COL_ATND_BG_RED_M: #ff7875
40-
$COL_ATND_BG_RED_L: #fff2f0
40+
$COL_ANTD_BG_RED_M: #ff7875
41+
$COL_ANTD_BG_RED_L: #fff2f0
4142
$COL_ANTD_BG_BLUE_L: #e6f4ff
4243
$COL_ANTD_RED_WARN: #f5222d
4344
$COL_ANTD_YELL_M: #fadb14
45+
$COL_STAR: #FFD700
4446
$COL_ANTD_RED: #f5222d
4547
$COL_ANTD_ORANGE: #ffbb96
4648
$COL_ANTD_GREEN: #87d068
4749
$COL_ANTD_GREEN_D: #237804
4850
$COL_COCALC_BLUE: #4474c0
4951
$COL_COCALC_ORANGE: #fcc861
5052
$COL_ORANGE_WARN: #FFA500
53+
$COL_AI_ASSISTANT_BG: #f6bf61
54+
$COL_AI_ASSISTANT_TXT: #303030
55+
$COL_AI_ASSISTANT_FONT: #f0a11d
56+
$COL_RUN: #389e0d
5157
$COL_TOP_BAR_BG: #eeeeee
5258
$COL_TOP_BAR_HOVER: #f5f5f5
5359
$COL_TOP_BAR_ACTIVE: white

src/packages/frontend/account/actions.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ export class AccountActions extends Actions<AccountState> {
184184
};
185185

186186
public set_show_purchase_form(show: boolean) {
187-
// this controlls the default state of the "buy a license" purchase form in account → licenses
187+
// this controls the default state of the "buy a license" purchase form in account → licenses
188188
// by default, it's not showing up
189189
this.setState({ show_purchase_form: show });
190190
}

src/packages/frontend/account/other-settings.tsx

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import { Card, InputNumber } from "antd";
77
import { Map } from "immutable";
88
import { FormattedMessage, useIntl } from "react-intl";
9+
910
import { Checkbox, Panel } from "@cocalc/frontend/antd-bootstrap";
1011
import { Rendered, redux, useTypedRedux } from "@cocalc/frontend/app-framework";
1112
import { useLocalizationCtx } from "@cocalc/frontend/app/localize";
@@ -18,28 +19,33 @@ import {
1819
NumberInput,
1920
Paragraph,
2021
SelectorInput,
22+
Text,
2123
} from "@cocalc/frontend/components";
2224
import AIAvatar from "@cocalc/frontend/components/ai-avatar";
2325
import { IS_MOBILE, IS_TOUCH } from "@cocalc/frontend/feature";
2426
import LLMSelector from "@cocalc/frontend/frame-editors/llm/llm-selector";
2527
import { LOCALIZATIONS, labels } from "@cocalc/frontend/i18n";
28+
import { getValidVBAROption } from "@cocalc/frontend/project/page/vbar";
2629
import {
2730
VBAR_EXPLANATION,
2831
VBAR_KEY,
32+
VBAR_LABELS,
33+
VBAR_LABELS_DEFAULT,
2934
VBAR_OPTIONS,
30-
getValidVBAROption,
31-
} from "@cocalc/frontend/project/page/vbar";
35+
VBAR_TOGGLE_LABELS,
36+
VBAR_TOGGLE_LABELS_DESCRIPTION,
37+
} from "@cocalc/frontend/project/page/vbar-consts";
3238
import { NewFilenameFamilies } from "@cocalc/frontend/project/utils";
3339
import track from "@cocalc/frontend/user-tracking";
3440
import { webapp_client } from "@cocalc/frontend/webapp-client";
3541
import { DEFAULT_NEW_FILENAMES, NEW_FILENAMES } from "@cocalc/util/db-schema";
3642
import { OTHER_SETTINGS_REPLY_ENGLISH_KEY } from "@cocalc/util/i18n/const";
3743
import { dark_mode_mins, get_dark_mode_config } from "./dark-mode";
3844
import { I18NSelector, I18N_MESSAGE, I18N_TITLE } from "./i18n-selector";
45+
import Messages from "./messages";
46+
import Tours from "./tours";
3947
import { useLanguageModelSetting } from "./useLanguageModelSetting";
4048
import { UserDefinedLLMComponent } from "./user-defined-llm";
41-
import Tours from "./tours";
42-
import Messages from "./messages";
4349

4450
// See https://github.com/sagemathinc/cocalc/issues/5620
4551
// There are weird bugs with relying only on mathjax, whereas our
@@ -519,6 +525,23 @@ export function OtherSettings(props: Readonly<Props>): React.JSX.Element {
519525
>
520526
{intl.formatMessage(VBAR_EXPLANATION)}
521527
</Paragraph>
528+
<Checkbox
529+
checked={
530+
props.other_settings.get(VBAR_LABELS) ?? VBAR_LABELS_DEFAULT
531+
}
532+
onChange={(e) => {
533+
on_change(VBAR_LABELS, e.target.checked);
534+
}}
535+
>
536+
<Paragraph
537+
type="secondary"
538+
style={{ marginBottom: 0 }}
539+
ellipsis={{ expandable: true, symbol: "more" }}
540+
>
541+
<Text strong>{intl.formatMessage(VBAR_TOGGLE_LABELS)}</Text>:{" "}
542+
{intl.formatMessage(VBAR_TOGGLE_LABELS_DESCRIPTION)}
543+
</Paragraph>
544+
</Checkbox>
522545
</div>
523546
</LabeledRow>
524547
);

src/packages/frontend/account/store.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import { List, Map } from "immutable";
77
import { reduce } from "lodash";
8+
89
import { store as customizeStore } from "@cocalc/frontend/customize";
910
import { make_valid_name } from "@cocalc/util/misc";
1011
import { Store } from "@cocalc/util/redux/Store";

src/packages/frontend/account/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import { OTHER_SETTINGS_REPLY_ENGLISH_KEY } from "@cocalc/util/i18n/const";
1717
import { PassportStrategyFrontend } from "@cocalc/util/types/passport-types";
1818
import { SETTINGS_LANGUAGE_MODEL_KEY } from "./useLanguageModelSetting";
1919
import { type AutoBalance } from "@cocalc/util/db-schema/accounts";
20+
import { VBAR_LABELS } from "../project/page/vbar-consts";
2021

2122
// this is incomplete...
2223

@@ -57,6 +58,7 @@ export interface AccountState {
5758
[OTHER_SETTINGS_REPLY_ENGLISH_KEY]?: string;
5859
no_email_new_messages?: boolean;
5960
use_balance_toward_subscriptions?: boolean;
61+
[VBAR_LABELS]?: boolean; // whether to show labels on the vertical action bar
6062
}>;
6163
stripe_customer?: TypedMap<{
6264
subscriptions: { data: Map<string, any> };

src/packages/frontend/admin/registration-token.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -427,7 +427,7 @@ export function RegistrationToken() {
427427
props: {
428428
style: {
429429
backgroundColor:
430-
pct > 90 ? COLORS.ATND_BG_RED_L : undefined,
430+
pct > 90 ? COLORS.ANTD_BG_RED_L : undefined,
431431
},
432432
},
433433
children: `${round1(pct)}%`,

src/packages/frontend/app/context.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,20 @@ import { theme, ThemeConfig } from "antd";
77
import { debounce } from "lodash";
88
import { ReactNode, useEffect, useMemo, useState } from "react";
99
import { useIntl } from "react-intl";
10+
1011
import { useTypedRedux } from "@cocalc/frontend/app-framework";
11-
import { COLORS } from "@cocalc/util/theme";
1212
import { IntlMessage, isIntlMessage } from "@cocalc/frontend/i18n";
13+
import { VBAR_LABELS } from "@cocalc/frontend/project/page/vbar-consts";
14+
import { COLORS } from "@cocalc/util/theme";
1315
import { NARROW_THRESHOLD_PX, PageStyle } from "./top-nav-consts";
1416
import useAppContext, { AppContext, calcStyle } from "./use-context";
17+
1518
export { AppContext, useAppContext };
1619

1720
export function useAppContextProvider() {
1821
const intl = useIntl();
22+
const other_settings = useTypedRedux("account", "other_settings");
23+
const showVbarLabels = other_settings.get(VBAR_LABELS) ?? true;
1924

2025
const [pageWidthPx, setPageWidthPx] = useState<number>(window.innerWidth);
2126

@@ -57,6 +62,7 @@ export function useAppContextProvider() {
5762
formatIntl,
5863
pageWidthPx,
5964
pageStyle,
65+
showVbarLabels,
6066
};
6167
}
6268

src/packages/frontend/app/render.tsx

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* License: MS-RSL – see LICENSE.md for details
44
*/
55

6-
import { createRoot } from "react-dom/client";
76
import {
87
redux,
98
Redux,
@@ -16,6 +15,7 @@ import {
1615
OTHER_SETTINGS_LOCALE_KEY,
1716
} from "@cocalc/frontend/i18n";
1817
import { QueryParams } from "@cocalc/frontend/misc/query-params";
18+
import { createRoot } from "react-dom/client";
1919
import { AppContext, useAppContextProvider } from "./context";
2020
import { Localize, useLocalizationCtx } from "./localize";
2121

@@ -25,7 +25,7 @@ function App({ children }) {
2525
const { setLocale } = useLocalizationCtx();
2626
const other_settings = useTypedRedux("account", "other_settings");
2727

28-
// setting via ?lang=[locale] takes precedece over account settings
28+
// setting via ?lang=[locale] takes precedence over account settings
2929
// additionally ?lang_temp=[locale] temporarily changes it, used by these impersonation admin links
3030
useAsyncEffect(async () => {
3131
const lang_set = QueryParams.get("lang");
@@ -80,9 +80,7 @@ function App({ children }) {
8080
};
8181

8282
return (
83-
<AppContext.Provider
84-
value={{ ...appState, ...timeAgo }}
85-
>
83+
<AppContext.Provider value={{ ...appState, ...timeAgo }}>
8684
{children}
8785
</AppContext.Provider>
8886
);

src/packages/frontend/app/use-context.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,11 @@ This should be renderable server side, e.g., no window references, etc.
77
import { ThemeConfig } from "antd";
88
import type { SizeType } from "antd/es/config-provider/SizeContext";
99
import { createContext, ReactNode, useContext } from "react";
10+
1011
import type { IntlMessage } from "@cocalc/util/i18n/types";
1112
import { COLORS } from "@cocalc/util/theme";
1213

14+
import { VBAR_LABELS_DEFAULT } from "@cocalc/frontend/project/page/vbar-consts";
1315
import {
1416
FONT_SIZE_ICONS_NARROW,
1517
FONT_SIZE_ICONS_NORMAL,
@@ -26,12 +28,14 @@ export interface AppState {
2628
formatIntl: (msg: IntlMessage | ReactNode | string) => ReactNode | string;
2729
timeAgoAbsolute?: boolean;
2830
setTimeAgoAbsolute?: (boolean) => void;
31+
showVbarLabels?: boolean; // whether to show labels on the vertical fixed bar
2932
}
3033

3134
export const DEFAULT_CONTEXT = {
3235
pageWidthPx: 1000, // gets updated
3336
pageStyle: calcStyle(false), // gets updated
3437
formatIntl: () => "Loading…",
38+
showVbarLabels: VBAR_LABELS_DEFAULT,
3539
};
3640

3741
export const AppContext = createContext<AppState>(DEFAULT_CONTEXT);

src/packages/frontend/app/verify-email-banner.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const VERIFY_EMAIL_STYLE: CSS = {
2727
width: "100%",
2828
padding: "5px",
2929
borderBottom: `1px solid ${COLORS.GRAY_D}`,
30-
background: COLORS.ATND_BG_RED_L,
30+
background: COLORS.ANTD_BG_RED_L,
3131
} as const;
3232

3333
const DISMISSED_KEY_LS = "verify-email-dismissed";

0 commit comments

Comments
 (0)