Infra to dynamic autocomplete tokens

pull/6775/head
Cagatay Civici 2024-11-13 02:14:58 +03:00
parent 632380414e
commit a9aecfd3f8
2 changed files with 10 additions and 43 deletions

View File

@ -160,7 +160,8 @@ const presets = {
export default { export default {
provide() { provide() {
return { return {
$preset: computed(() => this.preset) $preset: computed(() => this.preset),
$acTokens: computed(() => this.acTokens)
}; };
}, },
data() { data() {
@ -175,11 +176,13 @@ export default {
{ label: 'Lara', value: 'Lara' }, { label: 'Lara', value: 'Lara' },
{ label: 'Nora', value: 'Nora' } { label: 'Nora', value: 'Nora' }
], ],
customTokens: [] customTokens: [],
acTokens: []
}; };
}, },
mounted() { mounted() {
this.replaceColorPalette(); this.replaceColorPalette();
this.generateACTokens();
}, },
methods: { methods: {
apply() { apply() {
@ -306,6 +309,9 @@ app.mount("#app");
} else { } else {
return name; return name;
} }
},
generateACTokens() {
//@TODO: parse preset to generate tokens
} }
} }
}; };

View File

@ -26,46 +26,6 @@
<script> <script>
import { $dt } from '@primevue/themes'; import { $dt } from '@primevue/themes';
const tokens = [
'{primary.color}',
'{primary.contrast.color}',
'{primary.hover.color}',
'{primary.active.color}',
'{highlight.background}',
'{highlight.focus.background}',
'{highlight.color}',
'{highlight.focus.color}',
'{primary.50}',
'{primary.100}',
'{primary.200}',
'{primary.300}',
'{primary.400}',
'{primary.500}',
'{primary.600}',
'{primary.700}',
'{primary.800}',
'{primary.900}',
'{primary.950}',
'{surface.0}',
'{surface.50}',
'{surface.100}',
'{surface.200}',
'{surface.300}',
'{surface.400}',
'{surface.500}',
'{surface.600}',
'{surface.700}',
'{surface.800}',
'{surface.900}',
'{surface.950}',
'{border.radius.none}',
'{border.radius.xs}',
'{border.radius.sm}',
'{border.radius.md}',
'{border.radius.lg}',
'{border.radius.xl}'
];
export default { export default {
emits: ['update:modelValue'], emits: ['update:modelValue'],
props: { props: {
@ -82,6 +42,7 @@ export default {
default: undefined default: undefined
} }
}, },
inject: ['$acTokens'],
data() { data() {
return { return {
items: [] items: []
@ -98,7 +59,7 @@ export default {
const query = event.query; const query = event.query;
if (query.startsWith('{')) { if (query.startsWith('{')) {
this.items = tokens.filter((t) => t.startsWith(query)); this.items = this.$acTokens.filter((t) => t.startsWith(query));
} else { } else {
this.items = []; this.items = [];
} }