Theming doc updates
parent
18367429f6
commit
fbc12930b1
|
@ -1,6 +1,7 @@
|
||||||
<template>
|
<template>
|
||||||
<DocSectionText v-bind="$attrs">
|
<DocSectionText v-bind="$attrs">
|
||||||
<p>Design tokens can be scoped to a certain component using CSS variables. In this example, first switch uses the global tokens whereas second one overrides the global with its own tokens.</p>
|
<p>Design tokens can be scoped to a certain component using the <i>dt</i> property. In this example, first switch uses the global tokens whereas second one overrides the global with its own tokens.</p>
|
||||||
|
<p>This approach is recommended over the <i>:deep()</i> as it offers a cleaner API while avoiding the hassle of CSS rule overrides.</p>
|
||||||
</DocSectionText>
|
</DocSectionText>
|
||||||
<div class="card flex justify-center gap-4">
|
<div class="card flex justify-center gap-4">
|
||||||
<ToggleSwitch v-model="checked1" />
|
<ToggleSwitch v-model="checked1" />
|
||||||
|
|
|
@ -42,7 +42,7 @@ options: {
|
||||||
options: {
|
options: {
|
||||||
cssLayer: {
|
cssLayer: {
|
||||||
name: 'primevue',
|
name: 'primevue',
|
||||||
order: 'tailwind-base, primevue, tailwind-utilities'
|
order: 'app-styles, primevue, another-css-library'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
`
|
`
|
||||||
|
|
|
@ -1,9 +1,8 @@
|
||||||
<template>
|
<template>
|
||||||
<DocSectionText v-bind="$attrs">
|
<DocSectionText v-bind="$attrs">
|
||||||
<p>
|
<p>
|
||||||
Ease of customization may present an issue if you have global styles on HTML elements like inputs and buttons that are also utilized by PrimeVue because global styles with a broader scope e.g. <i>button { }</i> and no layer always
|
In case PrimeVue components have visual issues in your application, a Reset CSS may be the culprit. CSS layers would be an efficient solution that involves enabling the PrimeVue layer, wrapping the Reset CSS in another layer and defining
|
||||||
override the PrimeVue components leading to unexpected results. A common use case for global styles applying to standard HTML elements is CSS reset utilities to remove the default styling of the browsers. In this case, best practice is
|
the layer order. This way, your Reset CSS does not get in the way of PrimeVue components.
|
||||||
wrapping your CSS in a layer like <i>reset</i> and make sure <i>primevue</i> comes after your layer since layers defined after has higher precedence. This way, your Reset CSS does not get in the way of PrimeVue components.
|
|
||||||
</p>
|
</p>
|
||||||
<DocSectionCode :code="code" hideToggleCode importCode hideStackBlitz />
|
<DocSectionCode :code="code" hideToggleCode importCode hideStackBlitz />
|
||||||
</DocSectionText>
|
</DocSectionText>
|
||||||
|
|
|
@ -1,71 +1,13 @@
|
||||||
<template>
|
<template>
|
||||||
<DocSectionText v-bind="$attrs">
|
<DocSectionText v-bind="$attrs">
|
||||||
<p>
|
<p>
|
||||||
The <i>@layer</i> is a standard CSS feature to define cascade layers for a customizable order of precedence. If you need to become more familiar with layers, visit the documentation at
|
The <i>@layer</i> is a standard CSS feature to define cascade layers for a customizable order of precedence. If you need to become more familiar with layers, visit the documentation at
|
||||||
<a href="https://developer.mozilla.org/en-US/docs/Web/CSS/@layer" class="doc-link">MDN</a> to begin with. In styled mode, when the <i>cssLayer</i> option is enabled at theme configuration, PrimeVue wraps the built-in style classes under
|
<a href="https://developer.mozilla.org/en-US/docs/Web/CSS/@layer" class="doc-link">MDN</a> to begin with.
|
||||||
the <i>primevue</i> cascade layer to make the library styles easy to override. CSS in your app without a layer has the highest CSS specificity, so you'll be able to override styles regardless of the location or how strong a class is
|
|
||||||
written. The <i>cssLayer</i> is disabled by default to avoid compatibility issues with 3rd party CSS libraries which require a layer configuration for compatibility that is discussed in the next reset section.
|
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>
|
||||||
For example, let's assume you need to remove the rounded borders of the ToggleSwitch component defined by the theme in use. In order to achieve this, <i>.p-toggleswitch .p-toggleswitch-slider</i> selector needs to be overriden. Without
|
The <i>cssLayer</i> is disabled by default, when it is enabled at theme configuration, PrimeVue wraps the built-in style classes under the <i>primevue</i> cascade layer to make the library styles easy to override. CSS in your app without
|
||||||
the layers, we'd have to write a stronger css or use <i>!important</i>, however, with layers, this does not present an issue as your CSS can always override PrimeVue with a more straightforward class name such as <i>my-switch-slider</i>.
|
a layer has the highest CSS specificity, so you'll be able to override styles regardless of the location or how strong a class is written.
|
||||||
Another advantage of this approach is that it does not force you to figure out the built-in class names of the components.
|
|
||||||
</p>
|
</p>
|
||||||
<div class="card flex justify-center">
|
|
||||||
<ToggleSwitch v-model="checked" :pt="{ slider: 'my-switch-slider', handle: 'my-switch-handle', icon: 'my-switch-icon' }" />
|
|
||||||
</div>
|
|
||||||
<DocSectionCode :code="code" hideToggleCode hideStackBlitz />
|
|
||||||
<p>Layers also make it easier to use CSS Modules, view the CSS Modules guide for examples.</p>
|
<p>Layers also make it easier to use CSS Modules, view the CSS Modules guide for examples.</p>
|
||||||
</DocSectionText>
|
</DocSectionText>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
|
||||||
export default {
|
|
||||||
data() {
|
|
||||||
return {
|
|
||||||
checked: false,
|
|
||||||
code: {
|
|
||||||
basic: `
|
|
||||||
<template>
|
|
||||||
<ToggleSwitch v-model="checked" :pt="{ slider: 'my-switch-slider', handle: 'my-switch-handle', icon: 'my-switch-icon' }" />
|
|
||||||
</template>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
import { ref } from "vue";
|
|
||||||
|
|
||||||
const checked = ref(false);
|
|
||||||
<\/script>
|
|
||||||
|
|
||||||
<style>
|
|
||||||
.my-switch-slider {
|
|
||||||
border-radius: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.my-switch-handle {
|
|
||||||
border-radius: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.my-switch-icon {
|
|
||||||
display: none !important;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
`
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
};
|
|
||||||
</script>
|
|
||||||
|
|
||||||
<style>
|
|
||||||
.my-switch-slider {
|
|
||||||
border-radius: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.my-switch-handle {
|
|
||||||
border-radius: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.my-switch-icon {
|
|
||||||
display: none !important;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
|
@ -4,10 +4,7 @@
|
||||||
The theming system can be extended by adding custom design tokens and additional styles. This feature provides a high degree of customization, allowing you to adjust styles according to your needs, as you are not limited to the default
|
The theming system can be extended by adding custom design tokens and additional styles. This feature provides a high degree of customization, allowing you to adjust styles according to your needs, as you are not limited to the default
|
||||||
tokens.
|
tokens.
|
||||||
</p>
|
</p>
|
||||||
<p>
|
<p>The example preset configuration adds a new <i>accent</i> button with custom <i>button.accent.color</i> and <i>button.accent.inverse.color</i> tokens. It is also possible to add tokens globally to share them within the components.</p>
|
||||||
Use the <i>extend</i> property to add custom tokens along with the <i>css</i> property to utilize them. As an example, let's customize the disabled state of the ToggleSwitch component to add an opacity token, and use the primary color for
|
|
||||||
the handle. By default, there is no opacity option available, and the disabled switch uses a gray handle by design.
|
|
||||||
</p>
|
|
||||||
</DocSectionText>
|
</DocSectionText>
|
||||||
<DocSectionCode :code="code" hideToggleCode importCode hideStackBlitz />
|
<DocSectionCode :code="code" hideToggleCode importCode hideStackBlitz />
|
||||||
</template>
|
</template>
|
||||||
|
@ -20,26 +17,40 @@ export default {
|
||||||
basic: `
|
basic: `
|
||||||
const MyPreset = definePreset(Aura, {
|
const MyPreset = definePreset(Aura, {
|
||||||
components: {
|
components: {
|
||||||
toggleswitch: {
|
// custom button tokens and additional style
|
||||||
|
button: {
|
||||||
extend: {
|
extend: {
|
||||||
root: {
|
accent: {
|
||||||
myDisabledOpacity: '0.7'
|
color: '#f59e0b',
|
||||||
},
|
inverseColor: '#ffffff'
|
||||||
handle: {
|
|
||||||
myCheckedDisabledBackground: '{primary.color}'
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
css: ({ dt }) => \`
|
css: ({ dt }) => \`
|
||||||
.p-toggleswitch.p-disabled .p-toggleswitch-slider {
|
.p-button-accent {
|
||||||
opacity: \${dt('toggleswitch.my.disabled.opacity')};
|
background: \${dt('button.accent.color')};
|
||||||
}
|
color: \${dt('button.accent.inverse.color')};
|
||||||
|
transition-duration: \${dt('my.transition.fast')};
|
||||||
.p-toggleswitch.p-disabled .p-toggleswitch-handle {
|
|
||||||
background: \${dt('toggleswitch.my.checked.disabled.background')};
|
|
||||||
}
|
}
|
||||||
\`
|
\`
|
||||||
},
|
}
|
||||||
}
|
},
|
||||||
|
// common tokens and styles
|
||||||
|
extend: {
|
||||||
|
my: {
|
||||||
|
transition: {
|
||||||
|
slow: '0.75s'
|
||||||
|
normal: '0.5s'
|
||||||
|
fast: '0.25s'
|
||||||
|
},
|
||||||
|
imageDisplay: 'block'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
css: ({ dt }) => \`
|
||||||
|
/* Global CSS */
|
||||||
|
img {
|
||||||
|
display: \${dt('my.image.display')};
|
||||||
|
}
|
||||||
|
\`
|
||||||
});
|
});
|
||||||
`
|
`
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<template>
|
<template>
|
||||||
<DocSectionText v-bind="$attrs">
|
<DocSectionText v-bind="$attrs">
|
||||||
<p>
|
<p>
|
||||||
The <i>noir</i> mode is the nickname of a variant that uses black tones as the primary and requires and additional <i>colorScheme</i> configuration to implement. A sample preset configuration with black and white variants as the primary
|
The <i>noir</i> mode is the nickname of a variant that uses surface tones as the primary and requires and additional <i>colorScheme</i> configuration to implement. A sample preset configuration with black and white variants as the primary
|
||||||
color;
|
color;
|
||||||
</p>
|
</p>
|
||||||
</DocSectionText>
|
</DocSectionText>
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
<DocSectionText v-bind="$attrs">
|
<DocSectionText v-bind="$attrs">
|
||||||
<p>
|
<p>
|
||||||
The color scheme palette that varies between light and dark modes is specified with the surface tokens. Example below uses <i>zinc</i> for light mode and <i>slategray</i> for dark mode. With this setting, light mode, would have a
|
The color scheme palette that varies between light and dark modes is specified with the surface tokens. Example below uses <i>zinc</i> for light mode and <i>slategray</i> for dark mode. With this setting, light mode, would have a
|
||||||
grayscale tone and dark mode would include blue tone.
|
grayscale tone and dark mode would include bluish tone.
|
||||||
</p>
|
</p>
|
||||||
</DocSectionText>
|
</DocSectionText>
|
||||||
<DocSectionCode :code="code" hideToggleCode importCode hideStackBlitz />
|
<DocSectionCode :code="code" hideToggleCode importCode hideStackBlitz />
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
<div class="doc-main">
|
<div class="doc-main">
|
||||||
<div class="doc-intro">
|
<div class="doc-intro">
|
||||||
<h1>Styled Mode</h1>
|
<h1>Styled Mode</h1>
|
||||||
<p>Choose from a variety of pre-styled themes or develop your own..</p>
|
<p>Choose from a variety of pre-styled themes or develop your own.</p>
|
||||||
</div>
|
</div>
|
||||||
<DocSections :docs="docs" />
|
<DocSections :docs="docs" />
|
||||||
</div>
|
</div>
|
||||||
|
@ -30,7 +30,6 @@ import ScaleDoc from '@/doc/theming/styled/ScaleDoc.vue';
|
||||||
import ScopedTokensDoc from '@/doc/theming/styled/ScopedTokensDoc.vue';
|
import ScopedTokensDoc from '@/doc/theming/styled/ScopedTokensDoc.vue';
|
||||||
import OptionsDoc from '@/doc/theming/styled/configuration/OptionsDoc.vue';
|
import OptionsDoc from '@/doc/theming/styled/configuration/OptionsDoc.vue';
|
||||||
import ThemeDoc from '@/doc/theming/styled/configuration/ThemeDoc.vue';
|
import ThemeDoc from '@/doc/theming/styled/configuration/ThemeDoc.vue';
|
||||||
import LibrariesDoc from '@/doc/theming/styled/csslayer/LibrariesDoc.vue';
|
|
||||||
import ResetDoc from '@/doc/theming/styled/csslayer/ResetDoc.vue';
|
import ResetDoc from '@/doc/theming/styled/csslayer/ResetDoc.vue';
|
||||||
import SpecificityDoc from '@/doc/theming/styled/csslayer/SpecificityDoc.vue';
|
import SpecificityDoc from '@/doc/theming/styled/csslayer/SpecificityDoc.vue';
|
||||||
import ComponentDoc from '@/doc/theming/styled/customization/ComponentDoc.vue';
|
import ComponentDoc from '@/doc/theming/styled/customization/ComponentDoc.vue';
|
||||||
|
@ -113,16 +112,16 @@ export default {
|
||||||
label: 'Primary',
|
label: 'Primary',
|
||||||
component: PrimaryDoc
|
component: PrimaryDoc
|
||||||
},
|
},
|
||||||
{
|
|
||||||
id: 'noir',
|
|
||||||
label: 'Noir',
|
|
||||||
component: NoirDoc
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
id: 'surface',
|
id: 'surface',
|
||||||
label: 'Surface',
|
label: 'Surface',
|
||||||
component: SurfaceDoc
|
component: SurfaceDoc
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
id: 'noir',
|
||||||
|
label: 'Noir',
|
||||||
|
component: NoirDoc
|
||||||
|
},
|
||||||
{
|
{
|
||||||
id: 'font',
|
id: 'font',
|
||||||
label: 'Font',
|
label: 'Font',
|
||||||
|
@ -205,11 +204,6 @@ export default {
|
||||||
id: 'reset',
|
id: 'reset',
|
||||||
label: 'Reset',
|
label: 'Reset',
|
||||||
component: ResetDoc
|
component: ResetDoc
|
||||||
},
|
|
||||||
{
|
|
||||||
id: 'libraries',
|
|
||||||
label: 'Libraries',
|
|
||||||
component: LibrariesDoc
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue