Yoopta-Editor icon indicating copy to clipboard operation
Yoopta-Editor copied to clipboard

[BUG] Toolbar doesn't adhere to dark mode

Open debkanchan opened this issue 1 year ago • 23 comments

Has this bug been raised before?

  • [X] I have checked "open" AND "closed" issues and this is not a duplicate

Description

In dark mode, toolbar background is still white while background is dark

Steps to Reproduce

  • init a next.js project
  • setup a theme switcher using next/themes
  • setup shadcn/ui
  • copy any block
  • add a yoopta editor anywhere with toolbar plugin
  • add text
  • switch to dark mode
  • select text

Environment

  • OS: MacOS Sonoma 14.5 (23F79)
  • Browser: Arc Version 1.54.0 (52220) [Chromium Engine Version 127.0.6533.89]

Screenshots

Screenshot 2024-08-20 at 12 22 55 PM

Do you want to work on this issue?

No

If "yes" to above, please explain how you would technically implement this

No response

debkanchan avatar Aug 20 '24 06:08 debkanchan

im running into the same issues with a very similar stack

iamhenry avatar Sep 12 '24 04:09 iamhenry

Same here. Next.js

trancethehuman avatar Sep 13 '24 11:09 trancethehuman

If you create your own toolbar, with custom action menu styling, you can resolve it (but then you won't get to use the default toolbar)

Here's the example from the docs for setting up a toolbar that's similar to Notion's: https://github.dev/Darginec05/Yoopta-Editor/blob/master/web/next-example/src/components/examples/withCustomToolbar/index.tsx

And in FloatingPortal's div that wraps ActionMenu, you can style that (I use tailwind so I just do it like this)

<FloatingPortal
                id="yoo-custom-toolbar-action-menu-list-portal"
                root={document.getElementById("yoopta-editor")}
              >
                <div
                  style={actionMenuStyles}
                  ref={actionMenuRefs.setFloating}
                  onClick={(e) => e.stopPropagation()}
                  className="dark:text-black"
                >
                  <ActionMenu {...actionMenuRenderProps} />
                </div>
              </FloatingPortal>
            )}

trancethehuman avatar Sep 13 '24 16:09 trancethehuman

But not sure how to resolve the side plus button and drag handle's colors

image

trancethehuman avatar Sep 13 '24 17:09 trancethehuman

Managed to fix these by overriding the css for stuff. I use tailwind and a global.css. This now changes according to my .dark theme.

p.s main-editor is just the id I gave the

that wraps my yoopta editor
#main-editor .yoopta-block-actions-plus,
#main-editor .yoopta-block-actions-drag {
  color: silver;
}

#main-editor .yoopta-extended-block-actions,
#main-editor .yoopta-block-options-menu-content {
  background-color: hsl(var(--popover));
  color: hsl(var(--card-foreground));
  border: none;
}

I couldn't find the className that targets the default menu action, so I opted for the Notion example and tweaked it's scss there.

Hope this is useful

trancethehuman avatar Sep 13 '24 20:09 trancethehuman

Screenshot 2024-09-13 at 4 29 55 PM

Still have issues in the code menu and stuff too though - not sure how to fix these

trancethehuman avatar Sep 13 '24 20:09 trancethehuman

I'll add some common readable classnames (not tailwind classes) to these components. So this should make it easy to manage styles for any theme.

FYI @iamhenry @debkanchan @trancethehuman

Darginec05 avatar Sep 15 '24 14:09 Darginec05

Sounds great!

trancethehuman avatar Sep 15 '24 15:09 trancethehuman

thank you

iamhenry avatar Sep 16 '24 18:09 iamhenry

Arigato

debkanchan avatar Sep 16 '24 18:09 debkanchan

Merci

Darginec05 avatar Sep 16 '24 20:09 Darginec05

looks like it's fixed right? @Darginec05

debkanchan avatar Sep 23 '24 16:09 debkanchan

@debkanchan Yes, it's actually fixed in the latest release, but I'm working on updating the examples to clearly show how it works with dark themes

Darginec05 avatar Sep 23 '24 17:09 Darginec05

Upgraded!

Still getting white out text on toolbars and such - also looked in the sandbox docs but couldn't find a classname to target these

Screenshot 2024-09-24 at 2 59 21 PM Screenshot 2024-09-24 at 3 00 18 PM

trancethehuman avatar Sep 24 '24 19:09 trancethehuman

@trancethehuman To style Toolbar, I suggest using these classname - https://github.com/Darginec05/Yoopta-Editor/blob/master/web/next-example/src/styles/globals.scss#L71

And it works in examples with dark theme - https://yoopta.dev/examples/withDarkTheme

Let me know if it helps you.

Darginec05 avatar Sep 24 '24 19:09 Darginec05

.yoopta-toolbar-root works!

I still have issues with the menu for codeblock languages.

Also, how do I change the background color for the buttons in the default toolbar? When in darkmode, the hover bg is quite bright

image Screenshot 2024-09-24 at 3 30 36 PM

trancethehuman avatar Sep 24 '24 19:09 trancethehuman

Related to https://github.com/Darginec05/Yoopta-Editor/issues/277

Darginec05 avatar Sep 24 '24 19:09 Darginec05

@trancethehuman I'm working on related task. It will be fixed in the next patch release

But for now you can use this hack:

[data-radix-popper-content-wrapper] button {
    color: #000;
}

Darginec05 avatar Sep 24 '24 19:09 Darginec05

Thanks! Fixed my codeblock language panel

trancethehuman avatar Sep 24 '24 20:09 trancethehuman

The dark mode does not work for me. I'm using Next.js with shad cn

Quietscher avatar Sep 26 '24 05:09 Quietscher

I am using the useTheme(); handle but it does not change the popover with the marker options

Quietscher avatar Sep 26 '24 18:09 Quietscher

image

Quietscher avatar Sep 26 '24 18:09 Quietscher

Unfortunately, there are a lot of hardcoded colors. I have solved it like the css below, but it would be nice to use semantic colors everywhere.


.dark,
[data-theme='dark'] {
    .yoopta-toolbar-root {
        background-color: var(--color-base-100) !important;
        border-color: color-mix(in oklab, var(--color-base-content) 30%, transparent) !important;
    }

    .yoopta-toolbar-separator {
        background-color: color-mix(in oklab, var(--color-base-content) 30%, transparent) !important;
    }

    .yoopta-toolbar-item:hover,
    .yoopta-toolbar-item-mark:hover {
        background-color: var(--color-base-300) !important;
    }

    .yoopta-mark-code {
        background-color: var(--color-base-300) !important;
    }

    .yoopta-extended-block-actions {
        background-color: var(--color-base-100) !important;
    }

    .yoopta-block-options-menu-content {
        background-color: var(--color-base-100) !important;
        border-color: color-mix(in oklab, var(--color-base-content) 30%, transparent) !important;
    }

    .yoopta-block-options-button:hover {
        background-color: var(--color-base-300) !important;
    }

    .yoo-code-text-popover-foreground {
        background-color: var(--color-base-200) !important;
    }

    .yoo-code-text-popover-foreground > * > .yoopta-button:hover {
        background-color: var(--color-base-300) !important;
    }

    .yoopta-action-menu-list-content {
        background-color: var(--color-base-100) !important;
        border-color: color-mix(in oklab, var(--color-base-content) 30%, transparent) !important;
    }

    .yoopta-action-menu-list-content > * > * > .yoopta-button:hover {
        background-color: var(--color-base-300) !important;
    }

    .yoopta-action-menu-list-content > * > * > .yoopta-button[aria-selected='true'] {
        background-color: var(--color-base-300) !important;
    }

    .yoopta-action-menu-list-content > * > * > .yoopta-button > .yoo-action-menu-flex {
        background-color: var(--color-base-200) !important;
    }

    .yoopta-block-actions-plus,
    .yoopta-block-actions-drag {
        color: color-mix(in oklab, var(--color-base-content) 30%, transparent) !important;
    }

    .yoopta-block-actions-plus:hover,
    .yoopta-block-actions-drag:hover {
        color: color-mix(in oklab, var(--color-base-content) 60%, transparent) !important;
    }

    .yoopta-link-preview {
        background-color: var(--color-base-100) !important;
        border-color: color-mix(in oklab, var(--color-base-content) 30%, transparent) !important;
    }
}

One more small detail: in the file DefaultToolbarRender.tsx:

const getModalTriggerStyle = (modal: keyof ModalsState) => ({
        backgroundColor: isActiveTriggerModal(modal) ? 'var(--color-base-300)' : undefined,
    })
  • --color-base-100
  • --color-base-200
  • --color-base-300
  • --color-base-content are names from daisyui which I use in my project.

Also, it's not related to the issue, but I would suggest to use semantic colors in ColorPicker too.

const COLOR_PRESETS = {
    text: [
        { name: 'Default', value: 'var(--color-base-content)' },
        { name: 'Base-Content-100', value: 'var(--color-base-content-100)' },
        { name: 'Base-Content-200', value: 'var(--color-base-content-200)' },
        { name: 'Base-Content-300', value: 'var(--color-base-content-300)' },
        { name: 'Primary', value: 'var(--color-primary)' },
        { name: 'Secondary', value: 'var(--color-secondary)' },
        { name: 'Success', value: 'var(--color-success)' },
        { name: 'Warning', value: 'var(--color-warning)' },
        { name: 'Info', value: 'var(--color-info)' },
        { name: 'Danger', value: 'var(--color-error)' },
    ],
    background: [
        { name: 'Default', value: 'unset' },
        { name: 'Base-100', value: 'var(--color-base-100)' },
        { name: 'Base-200', value: 'var(--color-base-200)' },
        { name: 'Base-300', value: 'var(--color-base-300)' },
        { name: 'Primary', value: 'var(--color-primary)' },
        { name: 'Secondary', value: 'var(--color-secondary)' },
        { name: 'Success', value: 'var(--color-success)' },
        { name: 'Warning', value: 'var(--color-warning)' },
        { name: 'Info', value: 'var(--color-info)' },
        { name: 'Danger', value: 'var(--color-error)' },
    ],
}

it makes correct text-color/background-color regardless of light/dark mode.

Otherwise I am falling in love with the editor ;-)

whitetown avatar Mar 20 '25 19:03 whitetown