pass computeColor into shadow control, fix shadow switching types due to invalid shadow color
This commit is contained in:
parent
1a38e0273e
commit
098c6af7ef
|
@ -46,12 +46,12 @@ library.add(
|
||||||
const props = defineProps(['modelValue'])
|
const props = defineProps(['modelValue'])
|
||||||
const emit = defineEmits(['update:modelValue'])
|
const emit = defineEmits(['update:modelValue'])
|
||||||
const paletteExporter = newExporter({
|
const paletteExporter = newExporter({
|
||||||
filename: 'pleroma',
|
filename: 'pleroma_palette',
|
||||||
extension: 'palette.json',
|
extension: 'json',
|
||||||
getExportedObject: () => props.modelValue
|
getExportedObject: () => props.modelValue
|
||||||
})
|
})
|
||||||
const paletteImporter = newImporter({
|
const paletteImporter = newImporter({
|
||||||
accept: '.palette.json',
|
accept: '.json',
|
||||||
onImport (parsed, filename) {
|
onImport (parsed, filename) {
|
||||||
emit('update:modelValue', parsed)
|
emit('update:modelValue', parsed)
|
||||||
}
|
}
|
||||||
|
|
|
@ -620,7 +620,6 @@ export default {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case 'color':
|
case 'color':
|
||||||
console.log('COLOR', selectedVirtualDirective.value.value)
|
|
||||||
return selectedVirtualDirective.value.value
|
return selectedVirtualDirective.value.value
|
||||||
default:
|
default:
|
||||||
return selectedVirtualDirective.value.value
|
return selectedVirtualDirective.value.value
|
||||||
|
|
|
@ -409,6 +409,7 @@
|
||||||
<ShadowControl
|
<ShadowControl
|
||||||
v-if="selectedVirtualDirectiveValType === 'shadow'"
|
v-if="selectedVirtualDirectiveValType === 'shadow'"
|
||||||
v-model="selectedVirtualDirectiveParsed"
|
v-model="selectedVirtualDirectiveParsed"
|
||||||
|
:computeColor="computeColor"
|
||||||
:compact="true"
|
:compact="true"
|
||||||
/>
|
/>
|
||||||
<ColorInput
|
<ColorInput
|
||||||
|
|
|
@ -46,6 +46,7 @@ export default {
|
||||||
'separateInset',
|
'separateInset',
|
||||||
'noPreview',
|
'noPreview',
|
||||||
'disabled',
|
'disabled',
|
||||||
|
'computeColor',
|
||||||
'compact'
|
'compact'
|
||||||
],
|
],
|
||||||
emits: ['update:modelValue', 'subShadowSelected'],
|
emits: ['update:modelValue', 'subShadowSelected'],
|
||||||
|
@ -107,6 +108,13 @@ export default {
|
||||||
usingFallback () {
|
usingFallback () {
|
||||||
return this.modelValue == null
|
return this.modelValue == null
|
||||||
},
|
},
|
||||||
|
getFallback () {
|
||||||
|
if (typeof this.computeColor === 'function' && this.selected?.color) {
|
||||||
|
return this.computeColor(this.selected.color)
|
||||||
|
} else {
|
||||||
|
return this.currentFallback?.color
|
||||||
|
}
|
||||||
|
},
|
||||||
style () {
|
style () {
|
||||||
try {
|
try {
|
||||||
if (this.separateInset) {
|
if (this.separateInset) {
|
||||||
|
|
|
@ -165,7 +165,7 @@
|
||||||
:model-value="selected?.color"
|
:model-value="selected?.color"
|
||||||
:disabled="disabled || !present"
|
:disabled="disabled || !present"
|
||||||
:label="$t('settings.style.common.color')"
|
:label="$t('settings.style.common.color')"
|
||||||
:fallback="currentFallback?.color"
|
:fallback="getFallback"
|
||||||
:show-optional-tickbox="false"
|
:show-optional-tickbox="false"
|
||||||
name="shadow"
|
name="shadow"
|
||||||
@update:modelValue="e => updateProperty('color', e)"
|
@update:modelValue="e => updateProperty('color', e)"
|
||||||
|
|
|
@ -21,7 +21,11 @@ export const parseShadow = string => {
|
||||||
const regex = new RegExp(regexPrep, 'gis') // global, (stable) indices, single-string
|
const regex = new RegExp(regexPrep, 'gis') // global, (stable) indices, single-string
|
||||||
const result = regex.exec(string)
|
const result = regex.exec(string)
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
|
if (string.startsWith('$') || string.startsWith('--')) {
|
||||||
return string
|
return string
|
||||||
|
} else {
|
||||||
|
throw new Error(`Invalid shadow definition: ${string}`)
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
const numeric = new Set(['x', 'y', 'blur', 'spread', 'alpha'])
|
const numeric = new Set(['x', 'y', 'blur', 'spread', 'alpha'])
|
||||||
const { x, y, blur, spread, alpha, inset, color } = Object.fromEntries(modes.map((mode, i) => {
|
const { x, y, blur, spread, alpha, inset, color } = Object.fromEntries(modes.map((mode, i) => {
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
import { unroll } from './iss_utils.js'
|
import { unroll } from './iss_utils.js'
|
||||||
|
|
||||||
export const serializeShadow = s => {
|
export const serializeShadow = (s, throwOnInvalid) => {
|
||||||
if (typeof s === 'object') {
|
if (typeof s === 'object') {
|
||||||
return `${s.inset ? 'inset ' : ''}${s.x} ${s.y} ${s.blur} ${s.spread} ${s.color} / ${s.alpha}`
|
return `${s.inset ? 'inset ' : ''}${s.x} ${s.y} ${s.blur} ${s.spread} ${s.color} / ${s.alpha}`
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in a new issue