Skip to content

Commit be1518c

Browse files
authored
Merge pull request #8420 from sagemathinc/symbol-icons-configurable
symbols-bar: optionally show labels and slightly tweak margins
2 parents 08b40db + 190a01b commit be1518c

File tree

21 files changed

+138
-29
lines changed

21 files changed

+138
-29
lines changed

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,21 @@ export function OtherSettings(props: Readonly<Props>): React.JSX.Element {
248248
);
249249
}
250250

251+
function render_show_symbol_bar_labels(): Rendered {
252+
return (
253+
<Checkbox
254+
checked={!!props.other_settings.get("show_symbol_bar_labels")}
255+
onChange={(e) => on_change("show_symbol_bar_labels", e.target.checked)}
256+
>
257+
<FormattedMessage
258+
id="account.other-settings.symbol_bar_labels"
259+
defaultMessage={`<strong>Show Symbol Bar Labels:</strong>
260+
show labels in the frame editor symbol bar`}
261+
/>
262+
</Checkbox>
263+
);
264+
}
265+
251266
function render_default_file_sort(): Rendered {
252267
return (
253268
<LabeledRow
@@ -672,6 +687,7 @@ export function OtherSettings(props: Readonly<Props>): React.JSX.Element {
672687
{render_hide_project_popovers()}
673688
{render_hide_file_popovers()}
674689
{render_hide_button_tooltips()}
690+
{render_show_symbol_bar_labels()}
675691
<Checkbox
676692
checked={!!props.other_settings.get("hide_navbar_balance")}
677693
onChange={(e) => on_change("hide_navbar_balance", e.target.checked)}

src/packages/frontend/account/store.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,10 @@ export class AccountStore extends Store<AccountState> {
143143
if (!tours) return false;
144144
return tours.includes(tour) || tours.includes("all");
145145
}
146+
147+
showSymbolBarLabels(): boolean {
148+
return this.getIn(["other_settings", "show_symbol_bar_labels"], false);
149+
}
146150
}
147151

148152
// A user is anonymous if they have not provided a way to sign

src/packages/frontend/account/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ export interface AccountState {
5858
[OTHER_SETTINGS_REPLY_ENGLISH_KEY]?: string;
5959
no_email_new_messages?: boolean;
6060
use_balance_toward_subscriptions?: boolean;
61+
show_symbol_bar_labels?: boolean; // whether to show labels on the menu buttons
6162
[ACTIVITY_BAR_LABELS]?: boolean; // whether to show labels on the vertical activity bar
6263
}>;
6364
stripe_customer?: TypedMap<{

src/packages/frontend/frame-editors/frame-tree/commands/manage.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { Icon, IconName, isIconName } from "@cocalc/frontend/components/icon";
1515
import { IS_MOBILE } from "@cocalc/frontend/feature";
1616
import { IntlMessage, isIntlMessage } from "@cocalc/frontend/i18n";
1717
import { cmp, filename_extension, trunc_middle } from "@cocalc/util/misc";
18-
// import { FrameTitleBarProps } from "../title-bar";
18+
import { COLORS } from "@cocalc/util/theme";
1919
import { EditorDescription } from "../types";
2020
import { COMMANDS } from "./commands";
2121
import { APPLICATION_MENU, SEARCH_COMMANDS } from "./const";
@@ -26,8 +26,6 @@ const MAX_TITLE_WIDTH = 20;
2626
const MAX_SEARCH_RESULTS = 10;
2727
const ICON_WIDTH = "28px";
2828

29-
const BUTTON_LABELS = false;
30-
3129
export class ManageCommands {
3230
// TODO: setting this to FrameTitleBarProps causes type issues in frame-editors/jupyter-editor/editor.ts
3331
// So, there is probably a fundamental problem with that mapping into "AllActions"
@@ -445,6 +443,11 @@ export class ManageCommands {
445443
});
446444
};
447445

446+
showSymbolBarLabels = (): boolean => {
447+
const account = redux.getStore("account");
448+
return account.showSymbolBarLabels();
449+
};
450+
448451
commandToMenuItem = ({
449452
name = "",
450453
key,
@@ -482,11 +485,11 @@ export class ManageCommands {
482485
label = (
483486
<>
484487
{icon ?? <Icon name="square" />}
485-
{BUTTON_LABELS && (
488+
{this.showSymbolBarLabels() && (
486489
<div
487490
style={{
488491
fontSize: "11px",
489-
color: "#666",
492+
color: COLORS.GRAY_M,
490493
marginTop: "-10px",
491494
// special case: button='' explicitly means no label
492495
width: cmd.button === "" ? undefined : "50px",

src/packages/frontend/frame-editors/frame-tree/title-bar.tsx

Lines changed: 77 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,13 @@
88
FrameTitleBar - title bar in a frame, in the frame tree
99
*/
1010

11-
import { Button, Input, InputNumber, Popover, Tooltip } from "antd";
11+
import { ButtonGroup } from "@cocalc/frontend/antd-bootstrap";
12+
import { Button, Dropdown, Input, InputNumber, Popover, Tooltip } from "antd";
13+
import type { MenuProps } from "antd/lib";
1214
import { List } from "immutable";
1315
import { useMemo, useRef } from "react";
1416
import { useIntl } from "react-intl";
15-
import { ButtonGroup } from "@cocalc/frontend/antd-bootstrap";
17+
1618
import {
1719
CSS,
1820
redux,
@@ -38,6 +40,7 @@ import { excludeFromComputeServer } from "@cocalc/frontend/file-associations";
3840
import { NotebookFrameActions } from "@cocalc/frontend/frame-editors/jupyter-editor/cell-notebook/actions";
3941
import { IntlMessage, isIntlMessage, labels } from "@cocalc/frontend/i18n";
4042
import { JupyterActions } from "@cocalc/frontend/jupyter/browser-actions";
43+
import { ACTIVITY_BAR_TOGGLE_LABELS } from "@cocalc/frontend/project/page/activity-bar-consts";
4144
import { AIGenerateDocumentModal } from "@cocalc/frontend/project/page/home-page/ai-generate-document";
4245
import { isSupportedExtension } from "@cocalc/frontend/project/page/home-page/ai-generate-examples";
4346
import { AvailableFeatures } from "@cocalc/frontend/project_configuration";
@@ -270,6 +273,10 @@ export function FrameTitleBar(props: FrameTitleBarProps) {
270273
const otherSettings = useRedux(["account", "other_settings"]);
271274
// const hideButtonTooltips = otherSettings.get("hide_button_tooltips");
272275
const darkMode = otherSettings.get("dark_mode");
276+
const showSymbolBarLabels = otherSettings.get(
277+
"show_symbol_bar_labels",
278+
false,
279+
);
273280
const disableTourRefs = useRef<boolean>(false);
274281
const tourRefs = useRef<{ [name: string]: { current: any } }>({});
275282
const getTourRef = (name: string) => {
@@ -710,8 +717,8 @@ export function FrameTitleBar(props: FrameTitleBarProps) {
710717
label === APPLICATION_MENU
711718
? manageCommands.applicationMenuTitle()
712719
: isIntlMessage(label)
713-
? intl.formatMessage(label)
714-
: label
720+
? intl.formatMessage(label)
721+
: label
715722
}
716723
items={v}
717724
/>
@@ -1060,6 +1067,11 @@ export function FrameTitleBar(props: FrameTitleBarProps) {
10601067
return null;
10611068
}
10621069
const { disabled, label, key, children, onClick } = item;
1070+
const style: CSS = {
1071+
color: "#333",
1072+
padding: showSymbolBarLabels ? "0" : "7.5px 0 0 0",
1073+
height: showSymbolBarLabels ? "36px" : undefined,
1074+
} as const;
10631075
if (children != null) {
10641076
return (
10651077
<DropdownMenu
@@ -1068,7 +1080,7 @@ export function FrameTitleBar(props: FrameTitleBarProps) {
10681080
title={label}
10691081
items={children}
10701082
button={false}
1071-
style={{ color: "#333", padding: "7.5px 0 0 0" }}
1083+
style={style}
10721084
/>
10731085
);
10741086
} else {
@@ -1079,14 +1091,53 @@ export function FrameTitleBar(props: FrameTitleBarProps) {
10791091
key={key}
10801092
disabled={disabled}
10811093
onClick={onClick}
1082-
style={{ color: "#333", padding: "7.5px 0 0 0" }}
1094+
style={style}
10831095
>
10841096
{label}
10851097
</Button>
10861098
);
10871099
}
10881100
}
10891101

1102+
function wrapButtonBarContextMenu(bar: React.JSX.Element) {
1103+
const showSymbolLabel = (
1104+
<>
1105+
<Tooltip
1106+
title={intl.formatMessage({
1107+
id: "frame_editors.frame_tree.title_bar.symbols.label.explanation",
1108+
defaultMessage:
1109+
"If labels are shown, the symbol bar is placed in its own row beneath the menu – otherwise it is smaller and next to the menu.",
1110+
})}
1111+
>
1112+
<Icon name="signature-outlined" />{" "}
1113+
{intl.formatMessage(ACTIVITY_BAR_TOGGLE_LABELS, {
1114+
show: showSymbolBarLabels,
1115+
})}
1116+
</Tooltip>
1117+
</>
1118+
);
1119+
const items: MenuProps["items"] = [
1120+
{
1121+
key: "toggle-labels",
1122+
label: showSymbolLabel,
1123+
onClick: () => {
1124+
redux
1125+
.getActions("account")
1126+
.set_other_settings("show_symbol_bar_labels", !showSymbolBarLabels);
1127+
},
1128+
},
1129+
];
1130+
return (
1131+
<Dropdown
1132+
trigger={["contextMenu"]}
1133+
menu={{ items }}
1134+
overlayStyle={{ maxWidth: "400px" }}
1135+
>
1136+
{bar}
1137+
</Dropdown>
1138+
);
1139+
}
1140+
10901141
function renderButtonBar(popup = false) {
10911142
if (!is_active) {
10921143
return null;
@@ -1105,7 +1156,24 @@ export function FrameTitleBar(props: FrameTitleBarProps) {
11051156
if (v.length == 0) {
11061157
return null;
11071158
}
1108-
return <div style={{ marginTop: "5px" }}>{v}</div>;
1159+
// if labels are shown, we render two rows – otherwise symbols are next to the menu and frame controls
1160+
if (showSymbolBarLabels) {
1161+
return wrapButtonBarContextMenu(
1162+
<div
1163+
style={{
1164+
borderBottom: popup ? undefined : "1px solid #ccc",
1165+
background: "#fafafa",
1166+
opacity: is_active ? undefined : 0.3,
1167+
}}
1168+
>
1169+
<div style={{ marginBottom: "-1px", marginTop: "1px" }}>{v}</div>
1170+
</div>,
1171+
);
1172+
} else {
1173+
return wrapButtonBarContextMenu(
1174+
<div style={{ marginTop: "3px" }}>{v}</div>,
1175+
);
1176+
}
11091177
}
11101178

11111179
function renderComputeServerDocStatus() {
@@ -1253,9 +1321,10 @@ export function FrameTitleBar(props: FrameTitleBarProps) {
12531321
{renderMainMenusAndButtons()}
12541322
{is_active && renderConnectionStatus()}
12551323
{is_active && allButtonsPopover()}
1256-
{renderButtonBar()}
1324+
{!showSymbolBarLabels ? renderButtonBar() : undefined}
12571325
{renderFrameControls()}
12581326
</div>
1327+
{showSymbolBarLabels ? renderButtonBar() : undefined}
12591328
{renderConfirmBar()}
12601329
{hasTour && props.is_visible && props.tab_is_visible && (
12611330
<TitleBarTour refs={tourRefs} />

src/packages/frontend/i18n/trans/ar_EG.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
"account.other-settings.mask_files": "<strong>إخفاء الملفات:</strong> تظليل الملفات في عارض الملفات التي ربما لا تريد فتحها",
8282
"account.other-settings.project_popovers": "<strong>إخفاء النوافذ المنبثقة لعلامات التبويب في المشروع:</strong> لا تعرض النوافذ المنبثقة فوق علامات تبويب المشروع",
8383
"account.other-settings.standby_timeout": "مهلة الانتظار",
84+
"account.other-settings.symbol_bar_labels": "<strong>إظهار تسميات شريط الرموز:</strong> إظهار التسميات في شريط رموز محرر الإطار",
8485
"account.other-settings.theme": "السمة",
8586
"account.other-settings.theme.antd.animations": "<b>الرسوم المتحركة</b>: تحريك بعض العناصر بإيجاز، مثل الأزرار",
8687
"account.other-settings.theme.antd.color_scheme": "مخطط الألوان: استخدم ألوان العلامة التجارية بدلاً من الألوان الافتراضية",
@@ -597,6 +598,7 @@
597598
"frame_editors.frame_tree.title_bar.close": "أغلق هذا الإطار",
598599
"frame_editors.frame_tree.title_bar.maximize": "عرض هذا الإطار فقط",
599600
"frame_editors.frame_tree.title_bar.minimize": "عرض كافة الإطارات",
601+
"frame_editors.frame_tree.title_bar.symbols.label.explanation": "إذا تم عرض التسميات، يتم وضع شريط الرموز في صف خاص به تحت القائمة – وإلا فإنه يكون أصغر ويكون بجانب القائمة.",
600602
"frame-editors.frame-tree.add_remove_icon_button_bar.tooltip": "{isOnButtonBar, select, true {انقر على الأيقونة لإزالتها من شريط الأدوات} other {انقر على الأيقونة لإضافتها إلى شريط الأدوات}}",
601603
"i18n.localization.lang.arabic": "العربية",
602604
"i18n.localization.lang.chinese": "الصينية",
@@ -1257,7 +1259,6 @@
12571259
"project.page.flyouts.new.header_location": "الموقع:",
12581260
"project.page.project-licenses.header": "الحصص و{upgrades}",
12591261
"project.page.project-licenses.intro": "التراخيص والترقيات حسب الاستخدام تغير الحصص والميزات المتاحة للمشروع",
1260-
"project.page.vertical-fixed-tabs.toggle-labels": "{show, select, true {إخفاء التسميات} other {إظهار التسميات}}",
12611262
"project.servers.project-servers.description": "يمكنك تشغيل خوادم دفتر ملاحظات مختلفة داخل هذا المشروع بنقرة واحدة. تعمل في نفس البيئة، وتصل إلى نفس الملفات، وتتوقف عندما يتوقف المشروع. يمكنك أيضًا <A>تشغيل خوادمك الخاصة</A>.",
12621263
"project.settings.about-box.description.label": "الوصف (ماركداون)",
12631264
"project.settings.about-box.image.label": "صورة (اختياري)",

src/packages/frontend/i18n/trans/de_DE.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
"account.other-settings.mask_files": "<strong>Dateien maskieren:</strong> Dateien im Dateibetrachter ausgrauen, die Sie wahrscheinlich nicht öffnen möchten",
8282
"account.other-settings.project_popovers": "<strong>Projekt-Tab-Popovers ausblenden:</strong> die Popovers über den Projekt-Tabs nicht anzeigen",
8383
"account.other-settings.standby_timeout": "Standby-Timeout",
84+
"account.other-settings.symbol_bar_labels": "<strong>Symbolleistensymbol-Beschriftungen anzeigen:</strong> Beschriftungen in der Symbolleiste des Rahmeneditors anzeigen",
8485
"account.other-settings.theme": "Thema",
8586
"account.other-settings.theme.antd.animations": "<b>Animationen</b>: einige Aspekte kurz animieren, z. B. Schaltflächen",
8687
"account.other-settings.theme.antd.color_scheme": "<b>Farbschema</b>: Verwenden Sie Markenfarben anstelle der Standardfarben",
@@ -597,6 +598,7 @@
597598
"frame_editors.frame_tree.title_bar.close": "Schließe dieses Fenster",
598599
"frame_editors.frame_tree.title_bar.maximize": "Nur dieses Fenster anzeigen",
599600
"frame_editors.frame_tree.title_bar.minimize": "Alle Fenster anzeigen",
601+
"frame_editors.frame_tree.title_bar.symbols.label.explanation": "Wenn Beschriftungen angezeigt werden, befindet sich die Symbolleiste in einer eigenen Zeile unterhalb des Menüs – andernfalls ist sie kleiner und neben dem Menü.",
600602
"frame-editors.frame-tree.add_remove_icon_button_bar.tooltip": "{isOnButtonBar, select, true {Klicken Sie auf das Symbol, um es aus der Symbolleiste zu entfernen} other {Klicken Sie auf das Symbol, um es zur Symbolleiste hinzuzufügen}}",
601603
"i18n.localization.lang.arabic": "Arabisch",
602604
"i18n.localization.lang.chinese": "Chinesisch",
@@ -1257,7 +1259,6 @@
12571259
"project.page.flyouts.new.header_location": "Verzeichnis:",
12581260
"project.page.project-licenses.header": "Quoten und {upgrades}",
12591261
"project.page.project-licenses.intro": "Lizenzen und Pay-as-you-go-Upgrades ändern die Quoten und Funktionen, die einem Projekt zur Verfügung stehen.",
1260-
"project.page.vertical-fixed-tabs.toggle-labels": "{show, select, true {Beschriftungen ausblenden} other {Beschriftungen anzeigen}}",
12611262
"project.servers.project-servers.description": "Sie können verschiedene Notebook-Server in diesem Projekt mit einem Klick starten. Sie laufen in derselben Umgebung, haben Zugriff auf dieselben Dateien und stoppen, wenn das Projekt stoppt. Sie können auch <A>Ihren eigenen Server starten</A>.",
12621263
"project.settings.about-box.description.label": "Beschreibung (Markdown)",
12631264
"project.settings.about-box.image.label": "Bild (optional)",

src/packages/frontend/i18n/trans/es_ES.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
"account.other-settings.mask_files": "<strong>Archivos ocultos:</strong> atenuar archivos en el visor de archivos que probablemente no desees abrir",
8282
"account.other-settings.project_popovers": "<strong>Ocultar los Popovers de Pestañas de Proyecto:</strong> no mostrar los popovers sobre las pestañas del proyecto",
8383
"account.other-settings.standby_timeout": "Tiempo de espera en espera",
84+
"account.other-settings.symbol_bar_labels": "<strong>Mostrar etiquetas de la barra de símbolos:</strong> mostrar etiquetas en la barra de símbolos del editor de marcos",
8485
"account.other-settings.theme": "Tema",
8586
"account.other-settings.theme.antd.animations": "<b>Animaciones</b>: animar brevemente algunos aspectos, p. ej., botones",
8687
"account.other-settings.theme.antd.color_scheme": "<b>Esquema de Color</b>: usar colores de marca en lugar de colores predeterminados",
@@ -597,6 +598,7 @@
597598
"frame_editors.frame_tree.title_bar.close": "Cerrar este marco",
598599
"frame_editors.frame_tree.title_bar.maximize": "Mostrar solo este marco",
599600
"frame_editors.frame_tree.title_bar.minimize": "Mostrar todos los marcos",
601+
"frame_editors.frame_tree.title_bar.symbols.label.explanation": "Si se muestran las etiquetas, la barra de símbolos se coloca en su propia fila debajo del menú; de lo contrario, es más pequeña y está al lado del menú.",
600602
"frame-editors.frame-tree.add_remove_icon_button_bar.tooltip": "{isOnButtonBar, select, true {Haga clic en el icono para quitar de la barra de herramientas} other {Haga clic en el icono para añadir a la barra de herramientas}}",
601603
"i18n.localization.lang.arabic": "Árabe",
602604
"i18n.localization.lang.chinese": "Chino",
@@ -1257,7 +1259,6 @@
12571259
"project.page.flyouts.new.header_location": "Ubicación:",
12581260
"project.page.project-licenses.header": "Cuotas y {upgrades}",
12591261
"project.page.project-licenses.intro": "Las licencias y las actualizaciones de pago por uso cambian las cuotas y características disponibles para un proyecto",
1260-
"project.page.vertical-fixed-tabs.toggle-labels": "{show, select, true {Ocultar etiquetas} other {Mostrar etiquetas}}",
12611262
"project.servers.project-servers.description": "Puedes ejecutar varios servidores de cuadernos dentro de este proyecto con un solo clic. Se ejecutan en el mismo entorno, tienen acceso a los mismos archivos y se detienen cuando el proyecto se detiene. También puedes <A>ejecutar tus propios servidores</A>.",
12621263
"project.settings.about-box.description.label": "Descripción (markdown)",
12631264
"project.settings.about-box.image.label": "Imagen (opcional)",

src/packages/frontend/i18n/trans/fr_FR.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
"account.other-settings.mask_files": "<strong>Masquer les fichiers :</strong> griser les fichiers dans le visualiseur de fichiers que vous ne souhaitez probablement pas ouvrir",
8282
"account.other-settings.project_popovers": "<strong>Masquer les popovers des onglets de projet :</strong> ne pas afficher les popovers au-dessus des onglets de projet",
8383
"account.other-settings.standby_timeout": "Délai d'attente en veille",
84+
"account.other-settings.symbol_bar_labels": "<strong>Afficher les étiquettes de la barre de symboles :</strong> afficher les étiquettes dans la barre de symboles de l'éditeur de cadre",
8485
"account.other-settings.theme": "Thème",
8586
"account.other-settings.theme.antd.animations": "<b>Animations</b> : animer brièvement certains aspects, par exemple les boutons",
8687
"account.other-settings.theme.antd.color_scheme": "<b>Schéma de couleurs</b> : utiliser les couleurs de marque au lieu des couleurs par défaut",
@@ -597,6 +598,7 @@
597598
"frame_editors.frame_tree.title_bar.close": "Fermer ce cadre",
598599
"frame_editors.frame_tree.title_bar.maximize": "Afficher seulement ce cadre",
599600
"frame_editors.frame_tree.title_bar.minimize": "Afficher tous les cadres",
601+
"frame_editors.frame_tree.title_bar.symbols.label.explanation": "Si les étiquettes sont affichées, la barre de symboles est placée sur sa propre ligne sous le menu – sinon elle est plus petite et à côté du menu.",
600602
"frame-editors.frame-tree.add_remove_icon_button_bar.tooltip": "{isOnButtonBar, select, true {Cliquez sur l'icône pour retirer de la barre d'outils} other {Cliquez sur l'icône pour ajouter à la barre d'outils}}",
601603
"i18n.localization.lang.arabic": "Arabe",
602604
"i18n.localization.lang.chinese": "Chinois",
@@ -1257,7 +1259,6 @@
12571259
"project.page.flyouts.new.header_location": "Emplacement :",
12581260
"project.page.project-licenses.header": "Quotas et {upgrades}",
12591261
"project.page.project-licenses.intro": "Les licences et les mises à niveau à la carte modifient les quotas et les fonctionnalités disponibles pour un projet.",
1260-
"project.page.vertical-fixed-tabs.toggle-labels": "{show, select, true {Masquer les étiquettes} other {Afficher les étiquettes}}",
12611262
"project.servers.project-servers.description": "Vous pouvez exécuter divers serveurs de notebooks à l'intérieur de ce projet en un clic. Ils fonctionnent dans le même environnement, ont accès aux mêmes fichiers et s'arrêtent lorsque le projet s'arrête. Vous pouvez également <A>exécuter vos propres serveurs</A>.",
12621263
"project.settings.about-box.description.label": "Description (markdown)",
12631264
"project.settings.about-box.image.label": "Image (optionnel)",

0 commit comments

Comments
 (0)