primevue-mirror/doc/theming/styled/ScopedCSSDoc.vue

87 lines
2.7 KiB
Vue
Raw Normal View History

2023-02-28 08:29:30 +00:00
<template>
<DocSectionText v-bind="$attrs">
<p>Design tokens can be scoped to a certain component using CSS variables.</p>
2023-02-28 08:29:30 +00:00
</DocSectionText>
2024-03-31 12:29:10 +00:00
<div class="card flex justify-content-center gap-3">
<InputSwitch v-model="checked1" class="blue-switch" />
<InputSwitch v-model="checked2" class="amber-switch" />
2023-02-28 08:29:30 +00:00
</div>
2024-03-31 12:29:10 +00:00
<DocSectionCode :code="code1" hideToggleCode hideStackBlitz />
2024-01-30 08:16:35 +00:00
<DocSectionCode :code="code2" hideToggleCode hideStackBlitz />
<h3>Future API Preview</h3>
<p>In an upcoming update, a special <i>dt</i> property would be introduced for each component to generate the CSS variables from a design token object.</p>
<DocSectionCode :code="code3" importCode hideToggleCode hideStackBlitz />
2023-02-28 08:29:30 +00:00
</template>
<script>
export default {
data() {
return {
2024-03-31 12:29:10 +00:00
checked1: true,
checked2: true,
2023-02-28 08:29:30 +00:00
code1: {
2023-09-22 12:54:14 +00:00
basic: `
2024-03-31 12:29:10 +00:00
<InputSwitch v-model="checked1" class="blue-switch" />
<InputSwitch v-model="checked2" class="amber-switch" />
2023-10-15 09:38:39 +00:00
`
2023-02-28 08:29:30 +00:00
},
code2: {
2023-09-22 12:54:14 +00:00
basic: `
2024-03-31 12:29:10 +00:00
<style scoped>
.blue-switch {
--p-inputswitch-checked-background: var(--p-blue-500);
--p-inputswitch-checked-hover-background: var(--p-blue-500);
--p-inputswitch-border-radius: 4px;
}
.amber-switch {
--p-inputswitch-checked-background: var(--p-amber-500);
--p-inputswitch-checked-hover-background: var(--p-amber-500);
--p-inputswitch-handle-background: var(--p-zinc-950);
--p-inputswitch-handle-hover-background: var(--p-zinc-950);
--p-inputswitch-handle-checked-background: var(--p-zinc-950);
--p-inputswitch-handle-checked-hover-background: var(--p-zinc-950);
}
</style>
`
},
code3: {
basic: `
<InputSwitch v-model="checked" :dt="blueSwitch" />
/*
const blueSwitch = {
root: {
checkedBackground: '{blue.500}',
checkedHoverBackground: '{blue.500}',
borderRadius: '40x'
},
handle: {
background: '{blue.50}'
}
}
*/
2023-10-15 09:38:39 +00:00
`
2023-02-28 08:29:30 +00:00
}
};
}
};
</script>
<style scoped>
2024-03-31 12:29:10 +00:00
.blue-switch {
--p-inputswitch-checked-background: var(--p-blue-500);
--p-inputswitch-checked-hover-background: var(--p-blue-500);
--p-inputswitch-border-radius: 4px;
2023-02-28 08:29:30 +00:00
}
2024-03-31 12:29:10 +00:00
.amber-switch {
--p-inputswitch-checked-background: var(--p-amber-500);
--p-inputswitch-checked-hover-background: var(--p-amber-500);
--p-inputswitch-handle-background: var(--p-zinc-950);
--p-inputswitch-handle-hover-background: var(--p-zinc-950);
--p-inputswitch-handle-checked-background: var(--p-zinc-950);
--p-inputswitch-handle-checked-hover-background: var(--p-zinc-950);
}
2023-02-28 08:29:30 +00:00
</style>