Skip to content

Commit fe25c15

Browse files
feat: Dark theme fixes + enable theme on website + docs (#236)
* Made it possible for demos inherit website theme * Made hero demo change theme automatically and adjusted dark bg color * alternative way to pass darkmode (#239) * alternative way to pass darkmode * new isDark approached * Updated theme shades * Added dark mode sponsor logos * Fixed dark mode sponsor logos * Cleaned up sandbox dark mode implementation * Added new features gifs * Updated colors & styles * Added dark mode switching to remaining demos * Added dark mode screenshots * Fixed theme switching in home page * Adjusted features gifs * Added collaboration gifs * Fixed home page demo theme switching * Adjusted styles * Small fixes --------- Co-authored-by: Matthew Lipski <[email protected]> * fix package json --------- Co-authored-by: Yousef <[email protected]>
1 parent 88b4536 commit fe25c15

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+423
-146
lines changed

packages/core/src/editor.module.css

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,13 @@ Tippy popups that are appended to document.body directly
5656
}
5757

5858
[data-theme="light"] {
59-
background-color: #ffffff;
60-
color: #444444;
59+
background-color: #FFFFFF;
60+
color: #3F3F3F;
6161
}
6262

6363
[data-theme="dark"] {
64-
background-color: #444444;
65-
color: #dddddd;
64+
background-color: #1F1F1F;
65+
color: #CFCFCF;
6666
}
6767

6868
.dragPreview {

packages/core/src/extensions/Blocks/nodes/Block.module.css

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,14 @@ NESTED BLOCKS
6060
.blockGroup
6161
.blockGroup
6262
> .blockOuter:not([data-prev-depth-changed])::before {
63-
border-left: 1px solid #cccccc;
63+
border-left: 1px solid #AFAFAF;
6464
}
6565

6666
[data-theme="dark"]
6767
.blockGroup
6868
.blockGroup
6969
> .blockOuter:not([data-prev-depth-changed])::before {
70-
border-left: 1px solid #999999;
70+
border-left: 1px solid #7F7F7F;
7171
}
7272

7373
.blockGroup .blockGroup > .blockOuter[data-prev-depth-change="-2"]::before {
@@ -250,12 +250,12 @@ NESTED BLOCKS
250250

251251
[data-theme="light"] .isEmpty .inlineContent:before,
252252
.isFilter .inlineContent:before {
253-
color: #cccccc;
253+
color: #CFCFCF;
254254
}
255255

256256
[data-theme="dark"] .isEmpty .inlineContent:before,
257257
.isFilter .inlineContent:before {
258-
color: #999999;
258+
color: #7F7F7F;
259259
}
260260

261261
/* TODO: would be nicer if defined from code */

packages/react/src/BlockNoteTheme.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ type ColorScheme = [
1515

1616
export const blockNoteColorScheme: ColorScheme = [
1717
"#FFFFFF",
18-
"#EEEEEE",
19-
"#DDDDDD",
20-
"#CCCCCC",
21-
"#999999",
22-
"#666666",
23-
"#444444",
24-
"#333333",
25-
"#222222",
26-
"#111111",
18+
"#EFEFEF",
19+
"#CFCFCF",
20+
"#AFAFAF",
21+
"#7F7F7F",
22+
"#3F3F3F",
23+
"#1F1F1F",
24+
"#161616",
25+
"#0F0F0F",
26+
"#000000",
2727
];
2828

2929
export const getBlockNoteTheme = (
@@ -41,7 +41,7 @@ export const getBlockNoteTheme = (
4141

4242
const sideMenu = useDarkTheme
4343
? blockNoteColorScheme[4]
44-
: blockNoteColorScheme[3];
44+
: blockNoteColorScheme[2];
4545

4646
const primaryBackground = useDarkTheme
4747
? blockNoteColorScheme[6]
@@ -52,7 +52,7 @@ export const getBlockNoteTheme = (
5252

5353
const primaryText = useDarkTheme
5454
? blockNoteColorScheme[2]
55-
: blockNoteColorScheme[6];
55+
: blockNoteColorScheme[5];
5656
const secondaryText = useDarkTheme
5757
? blockNoteColorScheme[4]
5858
: blockNoteColorScheme[4];
@@ -62,11 +62,11 @@ export const getBlockNoteTheme = (
6262
: blockNoteColorScheme[1];
6363
const hoveredText = useDarkTheme
6464
? blockNoteColorScheme[2]
65-
: blockNoteColorScheme[6];
65+
: blockNoteColorScheme[5];
6666

6767
const selectedBackground = useDarkTheme
6868
? blockNoteColorScheme[8]
69-
: blockNoteColorScheme[6];
69+
: blockNoteColorScheme[5];
7070
const selectedText = useDarkTheme
7171
? blockNoteColorScheme[2]
7272
: blockNoteColorScheme[0];

packages/website/docs/.vitepress/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ const METADATA_DEFAULT = {
125125

126126
export default defineConfig({
127127
vite: {},
128-
appearance: false,
128+
appearance: true,
129129
srcDir: ".",
130130
outDir: "build",
131131

packages/website/docs/.vitepress/theme/components/Examples/BlockNote/BlockNoteElement.vue

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
<template>
2-
<BasicPure></BasicPure>
2+
<BasicPure :theme="isDark ? 'dark' : 'light'"></BasicPure>
33
</template>
44
<script>
55
import { applyPureReactInVue } from "veaury";
66
// This is a React component
77
88
import { ReactBlockNote } from "./ReactBlockNote";
9-
import { ref } from "vue";
9+
import { useData } from "vitepress";
1010
1111
export default {
1212
components: {
1313
BasicPure: applyPureReactInVue(ReactBlockNote),
1414
},
15-
setup() {
15+
data() {
1616
return {
17-
// foo: ref("Hello!"),
17+
isDark: useData().isDark,
1818
};
1919
},
2020
};

packages/website/docs/.vitepress/theme/components/Examples/BlockNote/ReactBlockNote.tsx

Lines changed: 18 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import "@blocknote/core/style.css";
22
import { BlockNoteView, useBlockNote } from "@blocknote/react";
3-
import { useEffect, useMemo, useState } from "react";
3+
import { useEffect, useMemo } from "react";
44
import YPartyKitProvider from "y-partykit/provider";
55
import * as Y from "yjs";
66
import * as styles from "./ReactBlockNote.module.css";
@@ -38,11 +38,7 @@ const getRandomElement = (list: any[]) =>
3838
const getRandomColor = () => getRandomElement(colors);
3939
const getRandomName = () => getRandomElement(names);
4040

41-
export function ReactBlockNote() {
42-
const [darkMode, setDarkMode] = useState(
43-
document.documentElement.classList.contains("dark")
44-
);
45-
41+
export function ReactBlockNote(props: { theme: "light" | "dark" }) {
4642
const [doc, provider] = useMemo(() => {
4743
console.log("create");
4844
const doc = new Y.Doc();
@@ -54,24 +50,27 @@ export function ReactBlockNote() {
5450
return [doc, provider];
5551
}, []);
5652

57-
const editor = useBlockNote({
58-
editorDOMAttributes: {
59-
class: styles.editor,
60-
},
61-
theme: darkMode ? "dark" : "light",
62-
collaboration: {
63-
provider,
64-
fragment: doc.getXmlFragment("blocknote"),
65-
user: {
66-
name: getRandomName(),
67-
color: getRandomColor(),
53+
const editor = useBlockNote(
54+
{
55+
editorDOMAttributes: {
56+
class: styles.editor,
57+
},
58+
theme: props.theme,
59+
collaboration: {
60+
provider,
61+
fragment: doc.getXmlFragment("blocknote"),
62+
user: {
63+
name: getRandomName(),
64+
color: getRandomColor(),
65+
},
6866
},
6967
},
70-
});
68+
[props.theme]
69+
);
7170

7271
useEffect(() => {
7372
let shownAlert = false;
74-
const listener = (e: any) => {
73+
const listener = () => {
7574
if (!shownAlert) {
7675
alert(
7776
"Text you enter in this demo is displayed publicly on the internet to show multiplayer features. Be kind :)"
@@ -85,25 +84,5 @@ export function ReactBlockNote() {
8584
};
8685
}, [editor?.domElement]);
8786

88-
useEffect(() => {
89-
// Create the mutation observer
90-
const observer = new MutationObserver((mutations) => {
91-
for (const mutation of mutations) {
92-
if (
93-
mutation.type === "attributes" &&
94-
mutation.attributeName === "class"
95-
) {
96-
const hasDarkClass =
97-
document.documentElement.classList.contains("dark");
98-
setDarkMode(hasDarkClass);
99-
// TODO: how to update the editor's theme?
100-
}
101-
}
102-
});
103-
104-
// Set the observer to watch for changes on the <html> element
105-
observer.observe(document.documentElement, { attributes: true });
106-
}, []);
107-
10887
return <BlockNoteView editor={editor} />;
10988
}

packages/website/docs/.vitepress/theme/components/Features/FeaturesCard.vue

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ defineProps<{ feature: FeaturesCardData }>();
1111
<div
1212
class="feature-card"
1313
:style="{
14-
backgroundImage: `url(${
15-
isDark ? feature.bgImgDark : feature.bgImgLight
16-
})`,
14+
backgroundImage: `linear-gradient(to bottom, transparent 50%, ${
15+
isDark ? '#111418' : 'white'
16+
} 70%), url(${isDark ? feature.bgImgDark : feature.bgImgLight})`,
1717
}"
1818
>
1919
<h4>{{ feature.title }}</h4>
@@ -22,6 +22,9 @@ defineProps<{ feature: FeaturesCardData }>();
2222
</Card>
2323
</template>
2424

25+
backgroundImage: `linear-gradient(to bottom, rgba(255, 255, 255, 0), rgba(255,
26+
255, 255, 1)), url(${ isDark ? feature.bgImgDark : feature.bgImgLight })`
27+
2528
<style scoped lang="scss">
2629
.feature-card {
2730
margin: 5px;
@@ -49,7 +52,7 @@ defineProps<{ feature: FeaturesCardData }>();
4952
font-weight: 600;
5053
font-size: 15px;
5154
line-height: 1.2;
52-
background: white;
55+
//background: white;
5356
}
5457
5558
p {

packages/website/docs/.vitepress/theme/components/Hero/Hero.vue

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import BlockNote from "@theme/components/Examples/BlockNote/BlockNote.vue";
2727
<div class="editor-wrapper">
2828
<ClientOnly><BlockNote /></ClientOnly>
2929
</div>
30-
<div class="try-here-image"/>
30+
<div class="try-here-image" />
3131
</div>
3232
<!-- features
3333
sponsors
@@ -100,7 +100,7 @@ header {
100100
.editor-wrapper {
101101
border-radius: 12px;
102102
box-shadow: inset 0 0 0 1px #c4d0d966, inset 0 -1px #ffffff1a,
103-
inset 0 1px #84b9f61a;
103+
inset 0 1px #84b9f61a;
104104
// background-image: radial-gradient(
105105
// 145% 110% at 46% 20%,
106106
// #fdfeff 50%,
@@ -114,6 +114,10 @@ header {
114114
overflow-y: scroll;
115115
}
116116
117+
html.dark .editor-wrapper {
118+
background: #111418;
119+
}
120+
117121
.try-here-image {
118122
position: relative;
119123
width: 250px;

packages/website/docs/.vitepress/theme/components/Home.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ defineProps<{
133133
180deg,
134134
rgba(0, 0, 0, 0) 0%,
135135
rgba(0, 0, 0, 0) 400px,
136-
rgb(0, 0, 0) 700px
136+
rgb(7, 8, 11) 700px
137137
),
138138
radial-gradient(circle at 15% 35%, #243148, rgba(34, 34, 34, 0) 25%),
139139
radial-gradient(circle at 85% 20%, #1c2e3c, rgba(34, 34, 34, 0) 25%), #222;
Lines changed: 25 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,35 @@
11
<!-- MySandbox.vue -->
22
<template>
33
<!-- 'code-options' is a build-in prop, do not edit it -->
4-
<ClientOnly>
5-
<Sandbox
6-
:rtl="rtl"
7-
:template="'react-ts'"
8-
:light-theme="lightTheme"
9-
:dark-theme="darkTheme"
10-
:options="{
11-
...props, // do not forget it
12-
showLineNumbers: true,
13-
editorWidthPercentage: 40,
14-
}"
15-
:custom-setup="{
16-
...props, // do not forget it
17-
deps: { '@blocknote/react': 'latest' },
18-
}"
19-
:code-options="codeOptions"
20-
>
21-
<slot />
22-
</Sandbox>
23-
</ClientOnly>
4+
<div>
5+
<ClientOnly>
6+
<Sandbox
7+
:rtl="rtl"
8+
:template="'react-ts'"
9+
:light-theme="lightTheme"
10+
:dark-theme="darkTheme"
11+
:theme="isDark ? 'dark' : 'light'"
12+
:options="{
13+
...props, // do not forget it
14+
showLineNumbers: false,
15+
editorWidthPercentage: 40,
16+
}"
17+
:custom-setup="{
18+
...props, // do not forget it
19+
deps: { '@blocknote/react': 'latest', 'react-icons': 'latest' },
20+
}"
21+
:code-options="codeOptions"
22+
>
23+
<slot />
24+
</Sandbox>
25+
</ClientOnly>
26+
</div>
2427
</template>
2528

2629
<script setup lang="ts">
30+
import { useData } from "vitepress";
2731
import { Sandbox, sandboxProps } from "vitepress-plugin-sandpack";
2832
33+
const { isDark } = useData();
2934
const props = defineProps(sandboxProps);
3035
</script>

0 commit comments

Comments
 (0)