Skip to content

feat: Dark theme #171

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 17 commits into from
Apr 20, 2023
Merged

feat: Dark theme #171

merged 17 commits into from
Apr 20, 2023

Conversation

matthewlipski
Copy link
Collaborator

@matthewlipski matthewlipski commented Apr 17, 2023

This PR adds a dark theme to BlockNote which you can toggle using the useDarkTheme editor option. Looks pretty good but has a few issues:

  1. The hack we used to fix the color picker sets a white background on hover, and we don't have a way of easily accessing the useDarkTheme option to change this. I think this may be fixed in PR feat: customize sidemenu #143.
  2. The actual editor is not currently themed as it is part of the core package, while the dark theme at least partially relies on Mantine which is only used for UI in the react package.

Theming with Mantine is actually a bit of a pain since we customize the layouts quite a bit and have to change the colours of those manually. At some point when we want to focus more on UI design it might be worth just making a custom UI instead of relying on premade Mantine components.

closes #169

@vercel
Copy link

vercel bot commented Apr 17, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
blocknote-website ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 20, 2023 11:14am

Copy link
Collaborator

@YousefED YousefED left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice. I left some inline comments. Also:

editor content styling

  1. The actual editor is not currently themed as it is part of the core package, while the dark theme at least partially relies on Mantine which is only used for UI in the react package.

The core package should be responsible for styling the actual editor content right? The contents of the editor now remains black text on white bg, that should also be changed

website dark mode
I've pushed a commit that enables dark mode on the website so we can properly showcase the dark-mode compatibality 😄. This brings up a few new issues:

  • We need to update the theme at run time (there's a TODO left in code where we can do this).
  • Some elements of the website will need to come with a dark + light variant. I've already done this for the logo + "try this" elements. We'll need to update the screenshots
  • Ideally, the examples in the documentation are also theme-aware

@YousefED YousefED mentioned this pull request Apr 18, 2023
@YousefED YousefED changed the title Dark theme feat: Dark theme Apr 18, 2023
@matthewlipski
Copy link
Collaborator Author

Nice. I left some inline comments. Also:

editor content styling

  1. The actual editor is not currently themed as it is part of the core package, while the dark theme at least partially relies on Mantine which is only used for UI in the react package.

The core package should be responsible for styling the actual editor content right? The contents of the editor now remains black text on white bg, that should also be changed

website dark mode I've pushed a commit that enables dark mode on the website so we can properly showcase the dark-mode compatibality 😄. This brings up a few new issues:

  • We need to update the theme at run time (there's a TODO left in code where we can do this).
  • Some elements of the website will need to come with a dark + light variant. I've already done this for the logo + "try this" elements. We'll need to update the screenshots
  • Ideally, the examples in the documentation are also theme-aware

One thing about the editor dark mode is since we're only using basic CSS in core we have to hard code the text and background colors instead of taking them from blockNoteColorTheme like we do for the menus. Do you think that's ok for now?

@YousefED
Copy link
Collaborator

One thing about the editor dark mode is since we're only using basic CSS in core we have to hard code the text and background colors instead of taking them from blockNoteColorTheme like we do for the menus. Do you think that's ok for now?

Yes that's ok for now (i.e.: use a .dark class on the container). We can come up with other solutions as well to set these colors dynamically (e.g.: css vars), but I think now it's ok

@matthewlipski
Copy link
Collaborator Author

Nice. I left some inline comments. Also:

editor content styling

  1. The actual editor is not currently themed as it is part of the core package, while the dark theme at least partially relies on Mantine which is only used for UI in the react package.

The core package should be responsible for styling the actual editor content right? The contents of the editor now remains black text on white bg, that should also be changed

website dark mode I've pushed a commit that enables dark mode on the website so we can properly showcase the dark-mode compatibality 😄. This brings up a few new issues:

  • We need to update the theme at run time (there's a TODO left in code where we can do this).
  • Some elements of the website will need to come with a dark + light variant. I've already done this for the logo + "try this" elements. We'll need to update the screenshots
  • Ideally, the examples in the documentation are also theme-aware

Also, do we want to sort out the website dark mode in this PR? Imo should be on a separate branch since it seems like dark mode for the editor is highly requested and I think shouldn't break anything for the website, maybe just look a bit ugly if we have a dark mode example.

# Conflicts:
#	packages/react/src/BlockSideMenu/BlockSideMenuFactory.tsx
#	packages/react/src/ElementFactory/components/EditorElementComponentWrapper.tsx
#	packages/react/src/ElementFactory/components/ReactElementFactory.tsx
#	packages/react/src/FormattingToolbar/FormattingToolbarFactory.tsx
#	packages/react/src/hooks/useBlockNote.ts
@matthewlipski matthewlipski merged commit accf253 into main Apr 20, 2023
fogle pushed a commit to fogle/BlockNote that referenced this pull request May 20, 2023
* Added first iteration dark theme

* website dark mode

* Removed some unnecessary styles

* Changed how theme is passed to factories

* Changed `useDarkTheme` option to `theme`

* Removed redundant varible

* Added dark theme to editor body

* Changed editor theme from class to attribute

* Converted mock ID to string and updated snapshots

* Updated unit test snapshots

* Updated snapshots

* Updated snapshots

* Updated screenshots

* Made keyboard handler tests less flaky

* Removed dark mode toggle from website

---------

Co-authored-by: yousefed <[email protected]>
@YousefED YousefED mentioned this pull request May 23, 2023
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support for darkmode
2 participants