do the thing i wanted to do
This commit is contained in:
parent
82504a1fcf
commit
d6600bfa5a
|
@ -662,7 +662,10 @@ export default {
|
||||||
|
|
||||||
const previewRules = computed(() => {
|
const previewRules = computed(() => {
|
||||||
return overallPreviewRules.value.filter(r => {
|
return overallPreviewRules.value.filter(r => {
|
||||||
const rule = r.parent ? r.parent : r
|
const componentMatch = r.component === selectedComponentName.value
|
||||||
|
const parentComponentMatch = r.parent === selectedComponentName.value
|
||||||
|
if (!componentMatch && !parentComponentMatch) return false
|
||||||
|
const rule = parentComponentMatch ? r.parent : r
|
||||||
if (rule.component !== selectedComponentName.value) return false
|
if (rule.component !== selectedComponentName.value) return false
|
||||||
if (rule.variant !== selectedVariant.value) return false
|
if (rule.variant !== selectedVariant.value) return false
|
||||||
return r.state.filter(x => x !== 'normal').every(x => selectedState.has(x)) &&
|
return r.state.filter(x => x !== 'normal').every(x => selectedState.has(x)) &&
|
||||||
|
@ -695,9 +698,14 @@ export default {
|
||||||
})
|
})
|
||||||
|
|
||||||
const dynamicVars = computed(() => {
|
const dynamicVars = computed(() => {
|
||||||
console.log('ERR', toValue(previewRules.value))
|
console.log('ERR', selectedComponentName.value)
|
||||||
// NEED TO FIND SHORTEST
|
const sorted = [...previewRules.value].sort((a, b) => {
|
||||||
return previewRules.value.find(r => r.parent == null).dynamicVars
|
const aSelectorLength = a.selector.split(/ /g).length
|
||||||
|
const bSelectorLength = b.selector.split(/ /g).length
|
||||||
|
return aSelectorLength - bSelectorLength
|
||||||
|
})
|
||||||
|
|
||||||
|
return sorted[0].dynamicVars
|
||||||
})
|
})
|
||||||
|
|
||||||
const previewColors = computed(() => {
|
const previewColors = computed(() => {
|
||||||
|
|
Loading…
Reference in a new issue