({
})
export default {
- // 'modelValue' and 'Fallback' can be undefined, but if they are
- // initially vue won't detect it when they become something else
- // therefore i'm using "ready" which should be passed as true when
- // data becomes available
props: [
- 'modelValue', 'fallback', 'ready'
+ 'modelValue', 'fallback', 'separateInset'
],
emits: ['update:modelValue'],
data () {
@@ -51,75 +48,86 @@ export default {
ColorInput,
OpacityInput,
Select,
- Checkbox
- },
- methods: {
- add () {
- this.cValue.push(toModel(this.selected))
- this.selectedId = this.cValue.length - 1
- },
- del () {
- this.cValue.splice(this.selectedId, 1)
- this.selectedId = this.cValue.length === 0 ? undefined : Math.max(this.selectedId - 1, 0)
- },
- moveUp () {
- const movable = this.cValue.splice(this.selectedId, 1)[0]
- this.cValue.splice(this.selectedId - 1, 0, movable)
- this.selectedId -= 1
- },
- moveDn () {
- const movable = this.cValue.splice(this.selectedId, 1)[0]
- this.cValue.splice(this.selectedId + 1, 0, movable)
- this.selectedId += 1
- }
+ Checkbox,
+ Popover
},
beforeUpdate () {
- this.cValue = this.modelValue || this.fallback
+ this.cValue = (this.modelValue || this.fallback || []).map(toModel)
},
computed: {
+ selected () {
+ const selected = this.cValue[this.selectedId]
+ if (selected) {
+ return { ...selected }
+ }
+ return null
+ },
+ present () {
+ return this.selected != null && !this.usingFallback
+ },
+ shadowsAreNull () {
+ return this.modelValue == null
+ },
anyShadows () {
return this.cValue.length > 0
},
anyShadowsFallback () {
return this.fallback.length > 0
},
- selected () {
- if (this.ready && this.anyShadows) {
- return this.cValue[this.selectedId]
- } else {
- return toModel({})
- }
- },
currentFallback () {
- if (this.ready && this.anyShadowsFallback) {
- return this.fallback[this.selectedId]
- } else {
- return toModel({})
- }
+ return this.fallback?.[this.selectedId]
},
moveUpValid () {
- return this.ready && this.selectedId > 0
+ return this.selectedId > 0
},
moveDnValid () {
- return this.ready && this.selectedId < this.cValue.length - 1
- },
- present () {
- return this.ready &&
- typeof this.cValue[this.selectedId] !== 'undefined' &&
- !this.usingFallback
+ return this.selectedId < this.cValue.length - 1
},
usingFallback () {
- return typeof this.modelValue === 'undefined'
+ return this.modelValue == null
},
rgb () {
return hex2rgb(this.selected.color)
},
style () {
- return this.ready
- ? {
- boxShadow: getCssShadow(this.fallback)
- }
- : {}
+ if (!this.ready) return {}
+ if (this.separateInset) {
+ return {
+ filter: getCssShadowFilter(this.fallback),
+ boxShadow: getCssShadow(this.fallback, true)
+ }
+ }
+ return {
+ boxShadow: getCssShadow(this.fallback)
+ }
+ }
+ },
+ methods: {
+ updateProperty (prop, value) {
+ this.cValue[this.selectedId][prop] = value
+ this.$emit('update:modelValue', this.cValue)
+ },
+ add () {
+ this.cValue.push(toModel(this.selected))
+ this.selectedId = Math.max(this.cValue.length - 1, 0)
+ this.$emit('update:modelValue', this.cValue)
+ },
+ del () {
+ this.cValue.splice(this.selectedId, 1)
+ this.selectedId = this.cValue.length === 0 ? undefined : Math.max(this.selectedId - 1, 0)
+ this.$emit('update:modelValue', this.cValue)
+ },
+ moveUp () {
+ const movable = this.cValue.splice(this.selectedId, 1)[0]
+ this.cValue.splice(this.selectedId - 1, 0, movable)
+ this.selectedId -= 1
+ this.$emit('update:modelValue', this.cValue)
+ },
+ moveDn () {
+ const movable = this.cValue.splice(this.selectedId, 1)[0]
+ this.cValue.splice(this.selectedId + 1, 0, movable)
+ this.selectedId += 1
+ this.$emit('update:modelValue', this.cValue)
}
}
}
diff --git a/src/components/shadow_control/shadow_control.scss b/src/components/shadow_control/shadow_control.scss
index 0fba39f3..d7bc15c4 100644
--- a/src/components/shadow_control/shadow_control.scss
+++ b/src/components/shadow_control/shadow_control.scss
@@ -69,6 +69,16 @@
}
}
+ .inset-alert {
+ padding: 0.25em 0.5em;
+ }
+
+ &.disabled {
+ .inset-alert {
+ opacity: 0.2;
+ }
+ }
+
.shadow-preview {
order: 2;
flex: 3 3 15em;
@@ -94,7 +104,7 @@
.input-light-grid {
grid-area: options;
- justify-self: end;
+ justify-self: center;
}
.input-number {
@@ -176,3 +186,8 @@
}
}
}
+
+.inset-tooltip {
+ padding: 0.5em;
+ max-width: 30em;
+}
diff --git a/src/components/shadow_control/shadow_control.vue b/src/components/shadow_control/shadow_control.vue
index b867d6e0..8e2133ee 100644
--- a/src/components/shadow_control/shadow_control.vue
+++ b/src/components/shadow_control/shadow_control.vue
@@ -11,20 +11,22 @@
{{ $t('settings.style.shadows.offset') }}
updateProperty('y', e.target.value)"
>
updateProperty('y', e.target.value)"
>