editor.js icon indicating copy to clipboard operation
editor.js copied to clipboard

💡Dark Mode for Editor.JS

Open KShivendu opened this issue 4 years ago • 30 comments
trafficstars

  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.

KShivendu avatar Feb 16 '21 17:02 KShivendu

This would be a fantastic addition to this issue from November - https://github.com/codex-team/editor.js/issues/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! 👋🙌

mrspence avatar Feb 16 '21 18:02 mrspence

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

photo_2021-02-16_23-59-29

neSpecc avatar Feb 16 '21 21:02 neSpecc

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.

KShivendu avatar Feb 17 '21 03:02 KShivendu

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;
}

Eonasdan avatar Sep 02 '21 21:09 Eonasdan

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 avatar Nov 25 '22 10:11 fitterfizzle

Friendly bump @neSpecc

fitterfizzle avatar Nov 30 '22 08:11 fitterfizzle

@fitterfizzle copy what I posted and change the colors

Eonasdan avatar Nov 30 '22 13:11 Eonasdan

    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.

fitterfizzle avatar Nov 30 '22 14:11 fitterfizzle

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/

Eonasdan avatar Nov 30 '22 15:11 Eonasdan

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

photo_2021-02-16_23-59-29

Can share these styles with us?

homocodian avatar Apr 21 '23 15:04 homocodian

@neSpecc can you please share the css please.

MussaratAziz avatar Sep 26 '23 16:09 MussaratAziz

Friendly bump good sir @neSpecc I'd appreciate it if you share the custom CSS for this design: https://github.com/codex-team/editor.js/issues/1537#issuecomment-780115551

geekyayush avatar Oct 11 '23 11:10 geekyayush

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

MussaratAziz avatar Oct 11 '23 23:10 MussaratAziz

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.

geekyayush avatar Oct 12 '23 00:10 geekyayush

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

anuragrao04 avatar Nov 13 '23 13:11 anuragrao04

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;
}

anuragrao04 avatar Nov 13 '23 14:11 anuragrao04

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.

geekyayush avatar Nov 13 '23 20:11 geekyayush

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.

neSpecc avatar Nov 23 '23 17:11 neSpecc

.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

longvo00221 avatar Feb 02 '24 11:02 longvo00221

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

Miguel-Domingos avatar May 03 '24 09:05 Miguel-Domingos

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

manuelcunga avatar May 03 '24 12:05 manuelcunga