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

Primvue V4 Style Configuration : colorScheme Dark Surface Not Work as expected #5963

Closed
khaledOghli opened this issue Jun 25, 2024 · 7 comments
Labels
Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible

Comments

@khaledOghli
Copy link

Describe the bug

surface Variables: Still Take the root variables for light and dark mode

semantic: {
colorScheme: {
light: {
surface: {
0: '#00ffff',
50: '{zinc.50}',
100: '{zinc.100}',
200: '{zinc.200}',
300: '{zinc.300}',
400: '{zinc.400}',
500: '{zinc.500}',
600: '{zinc.600}',
700: '{zinc.700}',
800: '{zinc.800}',
900: '{zinc.900}',
950: '{zinc.950}',
},
},
dark: {
surface: {
0: '#ff2',
50: '{slate.50}',
100: '{slate.100}',
200: '{slate.200}',
300: '{slate.300}',
400: '{slate.400}',
500: '{slate.500}',
600: '{slate.600}',
700: '{slate.700}',
800: '{slate.800}',
900: '{slate.900}',
950: '{slate.950}',
},
},
},
},

Screenshot 2024-06-25 at 12 13 38 PM
.

Reproducer

https://stackblitz.com/edit/nuxt-starter-dhgcfm?file=theme.js

PrimeVue version

4.0.0-rc.2

Vue version

3.x

Language

TypeScript

Build / Runtime

Vue CLI App

Browser(s)

Chrome

Steps to reproduce the behavior

Go to the repro link:

https://stackblitz.com/edit/nuxt-starter-dhgcfm?file=theme.js

Expected behavior

No response

@khaledOghli khaledOghli added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Jun 25, 2024
@blevinelrp
Copy link

Seems to be working as expected in your stackblitz example.

light
image

dark
image

Can you provide more details regarding where you think this is not working?

@vruello
Copy link
Contributor

vruello commented Jun 25, 2024

I think I have the same issue with 4.0.0-rc.2.

As I understand the new theming system, the Aura preset sets the fieldset background to content.background (https://github.com/primefaces/primevue/blob/master/packages/themes/src/presets/aura/fieldset/index.js). content.background is set to surface.0 in light color scheme (https://github.com/primefaces/primevue/blob/master/packages/themes/src/presets/aura/index.js#L272) and to surface.900 in dark color scheme (https://github.com/primefaces/primevue/blob/master/packages/themes/src/presets/aura/index.js#L394).

If I'm correct, in the example, the background of the fieldset should be #00ffff in light theme and --p-slate-900 (#0f172a) in dark theme. However, when you switch themes, the background color of the fieldset does not change.

The css variable --p-surface-0 seems to be updated (as you showed up), but for some reason it does not seem to update --p-fieldset-background.

@blevinelrp
Copy link

blevinelrp commented Jun 25, 2024

There is a bug in how "toggleTheme" is implemented. It should be the following:

const toggleTheme = () => {
  const element = document.querySelector('html');
  element.classList.toggle('p-dark');
};

That is why you aren't seeing the update when the theme "switches" (because it isn't currently switching).

@vruello
Copy link
Contributor

vruello commented Jun 25, 2024

Wow thanks! The documentation needs to be updated (https://primevue.org/theming/styled/#darkmodetoggle).

@khaledOghli
Copy link
Author

There is a bug in how "toggleTheme" is implemented. It should be the following:

const toggleTheme = () => {
  const element = document.querySelector('html');
  element.classList.toggle('p-dark');
};

That is why you aren't seeing the update when the theme "switches" (because it isn't currently switching).

And that is the solution, Thanks man.
but really the documentation needs to be more clear.

@dxvgef
Copy link

dxvgef commented Aug 4, 2024

There is a bug in how "toggleTheme" is implemented. It should be the following:

const toggleTheme = () => {
  const element = document.querySelector('html');
  element.classList.toggle('p-dark');
};

That is why you aren't seeing the update when the theme "switches" (because it isn't currently switching).

So far, I still can't switch between light and dark colors, according to the code in the documentation

@IceflowRE
Copy link

// change dark mode surface
updateSurfacePalette({ light: null, dark: darkPalette })
// change light mode surface
updateSurfacePalette({ light: lightPalette, dark: null })

This works for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible
Projects
None yet
Development

No branches or pull requests

5 participants