primefaces / primevue

Next Generation Vue UI Component Library
https://primevue.org
MIT License
10.64k stars 1.24k forks source link

documentation: preset theming and css() function positioning within the theme declaration is wrong #6790

Open petitkriket opened 1 week ago

petitkriket commented 1 week ago

Describe the bug

There is a documented example to inject css when using the Primevue v4 preset. The documentation example does not work, and I suspect that there is an error in the documentation.

const MyPreset = definePreset(Lara, {
  components: {
    tag: {
      // inside a component itself, works 🎉 
      css: ({ dt }) => ``,
  },
  // inside the `components:` at the same level of other components like seen in the theme `extend` documentation section ❌
        css: ({ dt }) => `
.p-toggleswitch.p-disabled .p-toggleswitch-slider {
    opacity: ${dt('toggleswitch.my.disabled.opacity')};
}

.p-toggleswitch.p-disabled .p-toggleswitch-handle {
    background: ${dt('toggleswitch.my.checked.disabled.background')};
}
`
    }
});

2. On the other hand, when i place the css property within the tag or button object itself, it works

The css property has to be within the component itself.- material theme working example at an atomic component preset level.

3. On the root position of the theme object it seems to work, see material theme root declaration. But it's empty so it's unclear.

Reproduction

a simple reproduction

Proposition

  1. Can you clarify if both or all the 3 uses should be working ?
  2. If not, updating the docs could help

Reproducer

https://github.com/primefaces/primevue/blob/aec47f4fcb4748f7bd36fe8efa16342c453de3a0/packages/themes/src/presets/material/index.js#L185

PrimeVue version

4.2.2

Vue version

4.x

Language

TypeScript

Build / Runtime

Vite

Browser(s)

No response

Steps to reproduce the behavior

  1. add css customization and or extended Design Token to the theme.
  2. inspect the DOM and see that the given properties are not applied

Expected behavior

  1. add css customizations with or without design tokens
  2. see that the css is properly injected and enjoy Tags with a thin border.
hisuwh commented 1 day ago

I can't seem to get the css: ({ dt }) => ... function to work wherever I put it.