Skip to content
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

💡Dark Mode for Editor.JS #1537

Open
KShivendu opened this issue Feb 16, 2021 · 21 comments
Open

💡Dark Mode for Editor.JS #1537

KShivendu opened this issue Feb 16, 2021 · 21 comments

Comments

@KShivendu
Copy link

  1. Describe a problem.
    Many of the modern applications now support dark mode and since editor.js is getting popular, It would be fantastic to have a ready-to-use dark mode configuration.

  2. Describe the solution you'd like.

const editor = new EditorJS({
  // ...
  theme: 'dark'
})

We can decide the colors as we move ahead.

@mrspence
Copy link

This would be a fantastic addition to this issue from November - #822

Essentially the option to import editor JS without any styles would be really useful, so we can avoid duplicate code / overriding code.

P.S - not sure if I've yet dropped an issue on Editor.JS, so I'd just like to say this codebase is one I avidly follow updates and respect. Thank-you for building such a brilliant ecosystem! Some day I hope to donate or contribute if I get time, but for now I want to publicly say thank-you! 👋🙌

@neSpecc
Copy link
Member

neSpecc commented Feb 16, 2021

Something like that? Made in 2 mins by custom style overrides.

photo_2021-02-16_23-59-29

@KShivendu
Copy link
Author

Looks great. That's what I was talking about. Now I think it's better if we leave it up to the developers to set their colors using CSS classes provided in Core Styles API.

@Eonasdan
Copy link

Eonasdan commented Sep 2, 2021

Here's what I ended up with. Main body background color is #171717 and font color is white.

image

.ce-block--selected .ce-block__content,
.ce-inline-toolbar,
.codex-editor--narrow .ce-toolbox,
.ce-conversion-toolbar,
.ce-settings,
.ce-settings__button,
.ce-toolbar__settings-btn,
.cdx-button,
.ce-popover,
.ce-toolbar__plus:hover {
  background: #007991;
  color: inherit;
}

.ce-inline-tool,
.ce-conversion-toolbar__label,
.ce-toolbox__button,
.cdx-settings-button,
.ce-toolbar__plus {
  color: inherit;
}

::selection {
  background: #439a86;
}

.cdx-settings-button:hover,
.ce-settings__button:hover,
.ce-toolbox__button--active,
.ce-toolbox__button:hover,
.cdx-button:hover,
.ce-inline-toolbar__dropdown:hover,
.ce-inline-tool:hover,
.ce-popover__item:hover,
.ce-toolbar__settings-btn:hover {
  background-color: #439a86;
  color: inherit;
}

.cdx-notify--error {
  background: #fb5d5d !important;
}

.cdx-notify__cross::after,
.cdx-notify__cross::before {
  background: white;
}

@fitterfizzle
Copy link

Something like that? Made in 2 mins by custom style overrides.

photo_2021-02-16_23-59-29

Could you please share your CSS?

@fitterfizzle
Copy link

Friendly bump @neSpecc

@Eonasdan
Copy link

@fitterfizzle copy what I posted and change the colors

@fitterfizzle
Copy link

    background: #007991;

Thanks much appreciated.

I tried creating a .css file with your suggestions but sadly still doesn't really look as it should.

image

Moreover I need also some way to change the applied classes dynamically as my application supports changing between light and dark mode on the fly.

@Eonasdan
Copy link

I updated my previous comment. I must have fixed the other styles at some point. As far as a light/dark, media queries could do that based on the users preferred theme. If you have a toggle button, something like this might help: https://css-tricks.com/updating-a-css-variable-with-javascript/

@neSpecc neSpecc removed the feature label Jan 28, 2023
@homocodian
Copy link

Something like that? Made in 2 mins by custom style overrides.

photo_2021-02-16_23-59-29

Can share these styles with us?

@MussaratAziz
Copy link

@neSpecc can you please share the css please.

@geekyayush
Copy link

Friendly bump good sir @neSpecc
I'd appreciate it if you share the custom CSS for this design: #1537 (comment)

@MussaratAziz
Copy link

Friendly bump good sir @neSpecc I'd appreciate it if you share the custom CSS for this design: #1537 (comment)

most probably @neSpecc doesnt want to share @geekyayush

@geekyayush
Copy link

most probably @neSpecc doesnt want to share @geekyayush

If it's true, it's really sad. :(
I wish I was skilled enough to do custom CSS. Just stuck in the backend at the moment lol.

@anuragrao04
Copy link

@neSpecc please do post if you're willing to share the styles, and if yes- please do post the styles as well.

@anuragrao04
Copy link

I put together some CSS and it looks decent:

image

Here's the CSS:

.cdx-block,
.ce-header,
.inlineToolButton,
.ce-toolbar__plus,
.ce-toolbar__settings-btn,
.ce-popover__search {
  background-color: #2b2b2b;
  color: white;
}

.ce-toolbar__plus:hover,
.ce-toolbar__settings-btn:hover,
.cdx-loader,
.cdx-button {
  color: white;
  background-color: #262626;
}

.cdx-button:hover {
  background-color: #2f2f2f;
}

.ce-popover,
.ce-popover-item,
.ce-popover-item__icon,
.ce-popover-items,
.ce-popover-item:hover {
  --color-background-item-hover: #2f2f2f;
  background-color: #262626;
  color: white;
  border: none;
}

@geekyayush
Copy link

I put together some CSS and it looks decent

Dude, who are you? Did god send you to help me (a fellow developer)?

Thank you so much.

@neSpecc
Copy link
Member

neSpecc commented Nov 23, 2023

Hi there. I remember this request.

I can't share exact those styles from my screenshot since they were made just to experiment with how easily anyone can override any Editor style. I made them in DevTools and did not save them.

I suppose you are mostly interested in a set of CSS selectors to override, not in colors itself. You can begin with these classes from our example page, and then just use your DevTools inspector to find what style you also want to override.

More important for us is to refactor Editor styles at all. I'm planning to rewrite styles by exposing a set of CSS variables that you can easily override and tune. Not only colors but all main tokens (sizes, roundings, font, etc).

At the moment I'm also working on our Design System, which will be a separate package including theming, colors, and components. It could be used by Editor and 3rd party tools as well.

@longvo00221
Copy link

.ce-block--selected .ce-block__content,
.ce-inline-toolbar,
.codex-editor--narrow .ce-toolbox,
.ce-conversion-toolbar,
.ce-settings,
.ce-settings__button,
.ce-toolbar__settings-btn,
.cdx-button,
.ce-popover,
.ce-toolbar__plus:hover {
background: #0000;
color: inherit;
}

.ce-inline-tool,
.ce-conversion-toolbar__label,
.ce-toolbox__button,
.cdx-settings-button,
.ce-toolbar__plus {
color: inherit;
}

::selection {
background: #000;
}

.cdx-settings-button:hover,
.ce-settings__button:hover,
.ce-toolbox__button--active,
.ce-toolbox__button:hover,
.cdx-button:hover,
.ce-inline-toolbar__dropdown:hover,
.ce-inline-tool:hover,
.ce-popover__item:hover,
.ce-toolbar__settings-btn:hover {
background-color: #aaaaaa;
color: inherit;
}

.cdx-notify--error {
background: #fb5d5d !important;
}

.cdx-notify__cross::after,
.cdx-notify__cross::before {
background: white;
}

.dark .ce-inline-toolbar,
.dark .codex-editor--narrow .ce-toolbox,
.dark .ce-conversion-toolbar,
.dark .ce-settings,
.dark .ce-settings__button,
.dark .ce-toolbar__settings-btn,
.dark .cdx-button,
.dark .ce-popover,
.dark .ce-toolbar__plus:hover {
background: #fff;
color: #000;
}

.dark .ce-inline-tool,
.dark .ce-conversion-toolbar__label,
.dark .ce-toolbox__button,
.dark .cdx-settings-button,
.dark .ce-toolbar__plus {
color: #616161;
}

.dark ::selection {
background: #4d4d4d;
}

.dark .cdx-settings-button:hover,
.dark .ce-settings__button:hover,
.dark .ce-toolbox__button--active,
.dark .ce-toolbox__button:hover,
.dark .cdx-button:hover,
.dark .ce-inline-toolbar__dropdown:hover,
.dark .ce-inline-tool:hover,
.dark .ce-popover__item:hover,
.dark .ce-toolbar__settings-btn:hover {
background-color: #4d4d4d;
color: #fff;
}

.dark .cdx-notify--error {
background: #fb5d5d !important;
}

.dark .cdx-notify__cross::after,
.dark .cdx-notify__cross::before {
background: #1a1a1a;
}

this is the css for dark and light theme nextjs shadcn

@Miguel-Domingos
Copy link

I was working with the Editor yesterday and I was looking for dark mode, I saw that more people were in the same situation.
So, I've decided to solve and publish my code (style), soon I'll be creating a configuration mode to support dark mode, for now, if you want to use dark mode, you can find style code in my portfolio here

See the result, bellow:

Light mode
light

Dark mode
dark

@manuelcunga
Copy link

I was working with the Editor yesterday and I was looking for dark mode, I saw that more people were in the same situation. So, I've decided to solve and publish my code (style), soon I'll be creating a configuration mode to support dark mode, for now, if you want to use dark mode, you can find style code in my portfolio here

See the result, bellow:

Light mode light

Dark mode dark

Man you´re Hero

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

No branches or pull requests