Skip to content

Commit a3e7b82

Browse files
authored
Preliminary fixes for dark mode rendering (#39)
1 parent 88c0458 commit a3e7b82

File tree

6 files changed

+43
-13
lines changed

6 files changed

+43
-13
lines changed

motifstudio-web/src/app/Appbar.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,13 @@ import Image from "next/image";
33
export function Appbar() {
44
return (
55
<div className="w-full items-center justify-between font-mono text-sm lg:flex p-4">
6-
<div className="flex flex-col justify-center w-full h-full p-4 bg-white rounded-lg shadow-lg">
7-
<Image src={motifStudioLogo} alt="Motif Studio" className="object-contain h-8 object-left" />
6+
<div className="flex flex-col justify-center w-full h-full p-4 bg-white rounded-lg shadow-lg dark:bg-gray-800">
7+
<Image
8+
src={motifStudioLogo}
9+
alt="Motif Studio"
10+
// In dark mode, invert the logo colors. (Check theme with tailwind)
11+
className="object-contain h-8 object-left w-auto dark:filter dark:invert"
12+
/>
813
</div>
914
</div>
1015
);

motifstudio-web/src/app/GraphForm.tsx

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export function GraphForm({
4040

4141
// Return the dropdown with the filtered graphs as the options.
4242
return (
43-
<div className="h-full bg-white p-4 rounded-lg shadow-lg">
43+
<div className="h-full bg-white p-4 rounded-lg shadow-lg dark:bg-gray-800">
4444
<h2 className="text-xl font-mono">Host Graph</h2>
4545
<hr className="my-2" />
4646

@@ -60,19 +60,22 @@ export function GraphForm({
6060
<div className="relative">
6161
<Combobox.Input
6262
onChange={(event) => setQuery(event.target.value)}
63-
className="w-full p-4 rounded-lg shadow-lg border border-gray-200 focus:outline-none focus:ring-2 focus:ring-blue-400 focus:border-transparent font-bold"
63+
className="w-full p-4 rounded-lg shadow-lg border border-gray-200 focus:outline-none focus:ring-2 focus:ring-blue-400 focus:border-transparent font-bold dark:bg-gray-900 dark:text-gray-200"
6464
placeholder="Start typing or press the down arrow to choose a host graph..."
6565
displayValue={(graph: HostListing) => graph?.name}
6666
/>
67-
<Combobox.Options className="p-3 rounded-lg shadow-lg border border-gray-200 z-10 bg-white overflow-y-scroll max-h-64 absolute w-full">
67+
<Combobox.Options className="p-3 rounded-lg shadow-lg border overflow-y-scroll max-h-64 absolute w-full">
6868
{filteredGraphs.map((graph) => (
6969
<Combobox.Option
7070
key={graph.id}
7171
value={graph}
7272
className={({ active }) => `${
73-
active ? "text-white bg-blue-400" : "text-gray-900"
73+
active
74+
? "text-white bg-blue-400 dark:bg-blue-400 dark:text-white"
75+
: "text-gray-900 dark:text-gray-200"
7476
}
75-
cursor-default select-none relative py-2 pl-10 pr-4 hover:bg-blue-400 hover:text-white flex items-center justify-between`}
77+
cursor-default select-none relative py-2 pl-10 pr-4 hover:bg-blue-400 hover:text-white flex items-center justify-between text-sm
78+
`}
7679
>
7780
<b className="font-bold">{graph.name}</b>{" "}
7881
<div className="text-xs inline font-mono ml-4">{graph.id}</div>

motifstudio-web/src/app/GraphStats.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ export function GraphStats({
101101

102102
// Render the attributes and statistics.
103103
return graph ? (
104-
<div className="flex w-full h-full p-4 bg-white rounded-lg shadow-lg">
104+
<div className="flex w-full h-full p-4 bg-white rounded-lg shadow-lg dark:bg-gray-800">
105105
<div className="flex flex-col gap-2 w-full">
106106
<h2 className="text-xl font-mono w-full">Graph Properties for {graph.name}</h2>
107107
<hr className="my-2 w-full" />

motifstudio-web/src/app/ResultsFetcher.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -121,13 +121,13 @@ export function ResultsFetcher({ graph, query }: { graph: HostListing | null; qu
121121
</div>
122122
<div className="w-full flex gap-2">
123123
<button
124-
className="bg-blue-500 hover:bg-blue-700 text-white font-bold px-4 rounded"
124+
className="bg-blue-500 hover:bg-blue-700 text-white font-bold px-4 rounded"
125125
onClick={() => downloadResults("json")}
126126
>
127127
JSON
128128
</button>
129129
<button
130-
className="bg-blue-500 hover:bg-blue-700 text-white font-bold px-4 rounded"
130+
className="bg-blue-500 hover:bg-blue-700 text-white font-bold px-4 rounded"
131131
onClick={() => downloadResults("csv")}
132132
>
133133
CSV
@@ -153,7 +153,7 @@ export function ResultsFetcher({ graph, query }: { graph: HostListing | null; qu
153153
<tbody className="border-b-2">
154154
{queryData?.motif_results?.length ? (
155155
queryData.motif_results.slice(0, 10000).map((result: any, i: number) => (
156-
<tr key={i} className="border-b-2 hover:bg-gray-100">
156+
<tr key={i} className="border-b-2 hover:bg-gray-100 dark:hover:bg-gray-700">
157157
<a
158158
href={neuroglancerUrlFromHostVolumetricData(
159159
queryData?.host_volumetric_data?.uri,

motifstudio-web/src/app/ResultsWrapper.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export function ResultsWrapper({ graph, query }: { graph: HostListing | null; qu
1313
}, [graph, query]);
1414

1515
return (
16-
<div className="flex flex-col gap-2 w-full h-full p-4 bg-white rounded-lg shadow-lg">
16+
<div className="flex flex-col gap-2 w-full h-full p-4 bg-white rounded-lg shadow-lg dark:bg-gray-800">
1717
{!trigger ? (
1818
<button
1919
className="bg-blue-500 hover:bg-blue-700 text-white font-bold py-2 px-4 rounded"

motifstudio-web/src/app/WrappedEditor.tsx

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,28 @@ export function WrappedEditor({
6262
"editor.foreground": "#888888",
6363
},
6464
});
65+
monaco.editor.defineTheme("motiftheme-dark", {
66+
base: "vs-dark",
67+
inherit: false,
68+
rules: [
69+
{
70+
token: "operator",
71+
foreground: "ff0000",
72+
fontStyle: "bold",
73+
},
74+
{
75+
token: "edge",
76+
foreground: "0066dd",
77+
fontStyle: "bold",
78+
},
79+
{ token: "entity", foreground: "008800" },
80+
{ token: "macro", foreground: "888800" },
81+
],
82+
colors: {
83+
"editor.foreground": "#888888",
84+
"editor.background": "#1f2937",
85+
},
86+
});
6587

6688
// Set of variable entity names that can be auto-completed:
6789
// const variableEntityNames = ["A", "B"];
@@ -81,7 +103,7 @@ export function WrappedEditor({
81103
return (
82104
<Editor
83105
height="40vh"
84-
theme="motiftheme"
106+
theme={window.matchMedia("(prefers-color-scheme: dark)").matches ? "motiftheme-dark" : "motiftheme"}
85107
beforeMount={handleEditorWillMount}
86108
onChange={(value, event) => {
87109
if (onChange) {

0 commit comments

Comments
 (0)