Skip to content

Commit f8e9e17

Browse files
authored
[ENG-1025] Integrate subtle controls css styling into plugin (#540)
* current prog * improve some styling * cleanup + fix
1 parent b7f1af9 commit f8e9e17

File tree

4 files changed

+131
-0
lines changed

4 files changed

+131
-0
lines changed

apps/roam/src/components/settings/HomePersonalSettings.tsx

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import React from "react";
22
import { OnloadArgs } from "roamjs-components/types";
33
import { Label, Checkbox } from "@blueprintjs/core";
44
import Description from "roamjs-components/components/Description";
5+
import { addStyle } from "roamjs-components/dom";
56
import { NodeMenuTriggerComponent } from "~/components/DiscourseNodeMenu";
67
import {
78
getOverlayHandler,
@@ -18,9 +19,11 @@ import {
1819
AUTO_CANVAS_RELATIONS_KEY,
1920
DISCOURSE_CONTEXT_OVERLAY_IN_CANVAS_KEY,
2021
DISCOURSE_TOOL_SHORTCUT_KEY,
22+
STREAMLINE_STYLING_KEY,
2123
} from "~/data/userSettings";
2224
import KeyboardShortcutInput from "./KeyboardShortcutInput";
2325
import { getSetting, setSetting } from "~/utils/extensionSettings";
26+
import streamlineStyling from "~/styles/streamlineStyling";
2427

2528
const HomePersonalSettings = ({ onloadArgs }: { onloadArgs: OnloadArgs }) => {
2629
const extensionAPI = onloadArgs.extensionAPI;
@@ -225,6 +228,36 @@ const HomePersonalSettings = ({ onloadArgs }: { onloadArgs: OnloadArgs }) => {
225228
</>
226229
}
227230
/>
231+
<Checkbox
232+
defaultChecked={getSetting(STREAMLINE_STYLING_KEY, false)}
233+
onChange={(e) => {
234+
const target = e.target as HTMLInputElement;
235+
setSetting(STREAMLINE_STYLING_KEY, target.checked);
236+
237+
// Load or unload the streamline styling
238+
const existingStyleElement =
239+
document.getElementById("streamline-styling");
240+
241+
if (target.checked && !existingStyleElement) {
242+
// Load the styles
243+
const styleElement = addStyle(streamlineStyling);
244+
styleElement.id = "streamline-styling";
245+
} else if (!target.checked && existingStyleElement) {
246+
// Unload the styles
247+
existingStyleElement.remove();
248+
}
249+
}}
250+
labelElement={
251+
<>
252+
Streamline Styling
253+
<Description
254+
description={
255+
"Apply streamlined styling to your personal graph for a cleaner appearance."
256+
}
257+
/>
258+
</>
259+
}
260+
/>
228261
</div>
229262
);
230263
};

apps/roam/src/data/userSettings.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,4 @@ export const AUTO_CANVAS_RELATIONS_KEY = "auto-canvas-relations";
77
export const DISCOURSE_TOOL_SHORTCUT_KEY = "discourse-tool-shortcut";
88
export const DISCOURSE_CONTEXT_OVERLAY_IN_CANVAS_KEY =
99
"discourse-context-overlay-in-canvas";
10+
export const STREAMLINE_STYLING_KEY = "streamline-styling";

apps/roam/src/index.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import styles from "./styles/styles.css";
2020
import discourseFloatingMenuStyles from "./styles/discourseFloatingMenuStyles.css";
2121
import settingsStyles from "./styles/settingsStyles.css";
2222
import discourseGraphStyles from "./styles/discourseGraphStyles.css";
23+
import streamlineStyling from "./styles/streamlineStyling";
2324
import posthog from "posthog-js";
2425
import getDiscourseNodes from "./utils/getDiscourseNodes";
2526
import { initFeedbackWidget } from "./components/BirdEatsBugs";
@@ -36,6 +37,8 @@ import { getUidAndBooleanSetting } from "./utils/getExportSettings";
3637
import getBasicTreeByParentUid from "roamjs-components/queries/getBasicTreeByParentUid";
3738
import getPageUidByPageTitle from "roamjs-components/queries/getPageUidByPageTitle";
3839
import { DISCOURSE_CONFIG_PAGE_TITLE } from "./utils/renderNodeConfigPage";
40+
import { getSetting } from "./utils/extensionSettings";
41+
import { STREAMLINE_STYLING_KEY } from "./data/userSettings";
3942

4043
const initPostHog = () => {
4144
posthog.init("phc_SNMmBqwNfcEpNduQ41dBUjtGNEUEKAy6jTn63Fzsrax", {
@@ -116,6 +119,14 @@ export default runExtension(async (onloadArgs) => {
116119
const settingsStyle = addStyle(settingsStyles);
117120
const discourseFloatingMenuStyle = addStyle(discourseFloatingMenuStyles);
118121

122+
// Add streamline styling only if enabled
123+
const isStreamlineStylingEnabled = getSetting(STREAMLINE_STYLING_KEY, false);
124+
let streamlineStyleElement: HTMLStyleElement | null = null;
125+
if (isStreamlineStylingEnabled) {
126+
streamlineStyleElement = addStyle(streamlineStyling);
127+
streamlineStyleElement.id = "streamline-styling";
128+
}
129+
119130
const { observers, listeners } = await initObservers({ onloadArgs });
120131
const {
121132
pageActionListener,
@@ -179,6 +190,7 @@ export default runExtension(async (onloadArgs) => {
179190
settingsStyle,
180191
discourseGraphStyle,
181192
discourseFloatingMenuStyle,
193+
...(streamlineStyleElement ? [streamlineStyleElement] : []),
182194
],
183195
observers: observers,
184196
unload: () => {
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
export default /* css */ `
2+
/* 1) Page links: gray text with an underline simulated via bottom border */
3+
.rm-page-ref {
4+
color: #666;
5+
border-bottom: 3px solid #ddd;
6+
text-decoration: none;
7+
}
8+
.rm-page-ref:hover {
9+
color: #666;
10+
border-bottom-color: #ddd;
11+
text-decoration: none;
12+
}
13+
14+
/* 2) Todo boxes: gray */
15+
.check-container .checkmark {
16+
background: transparent;
17+
border: 2px solid #bbb;
18+
border-radius: 3px;
19+
}
20+
.check-container input:checked ~ .checkmark {
21+
background: #eee;
22+
border-color: #aaa;
23+
}
24+
/* Checkmark tick color (optional) */
25+
.check-container .checkmark:after {
26+
border-right: 2px solid #333;
27+
border-bottom: 2px solid #333;
28+
}
29+
30+
/* 3) Right sidebar: white background */
31+
#right-sidebar {
32+
background-color: white;
33+
}
34+
35+
.roam-main {
36+
border: 1px solid rgba(171, 171, 171, 0.5) ;
37+
}
38+
39+
/* 4) Tables: no row/body background */
40+
table.bp3-html-table.bp3-html-table-striped tbody tr:nth-child(odd) td {
41+
background: transparent;
42+
}
43+
table.bp3-html-table.bp3-html-table-striped tbody tr:nth-child(even) td {
44+
background: transparent;
45+
}
46+
47+
/* Subtle Controls */
48+
49+
.rm-block .rm-bullet {
50+
opacity: 0.2;
51+
transition: opacity 120ms ease;
52+
}
53+
54+
.rm-block:hover > .rm-block-main > .controls > .rm-bullet,
55+
.rm-focused > .rm-block-main > .controls > .rm-bullet {
56+
opacity: 1;
57+
}
58+
59+
/* optional: change focused bullet inner color, using fallback if var not defined */
60+
.rm-focused > .rm-block-main > .controls > .rm-bullet > .bp3-popover-wrapper .rm-bullet__inner {
61+
background-color: var(--accent-color, #9E2B0E);
62+
}
63+
64+
.rm-block .rm-multibar {
65+
opacity: 0.2;
66+
transition: opacity 120ms ease;
67+
}
68+
69+
.rm-block:hover > .rm-block-children > .rm-multibar,
70+
.rm-focused > .rm-block-children > .rm-multibar {
71+
opacity: 1;
72+
}
73+
74+
/* caret in reference page view */
75+
.rm-ref-page-view .rm-title-arrow-wrapper > .rm-caret {
76+
opacity: 0.2;
77+
transition: opacity 120ms ease;
78+
}
79+
80+
.rm-ref-page-view:hover .rm-title-arrow-wrapper > .rm-caret {
81+
opacity: 1;
82+
}
83+
84+
`;
85+

0 commit comments

Comments
 (0)