Skip to content

Commit

Permalink
Block figure: make back configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
distantnative committed May 11, 2024
1 parent cc59c0e commit b976d8c
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 5 deletions.
8 changes: 8 additions & 0 deletions panel/lab/components/block/3_figure/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,14 @@
/>
</k-block-figure>
</k-lab-example>
<k-lab-example label="Back">
<k-block-figure caption="This is a nice caption" back="pattern-light">
<k-image-frame
ratio="16/9"
src="https://fakeimg.pl/1200x600/ff0000,0/333333,255/?text=Pattern"
/>
</k-block-figure>
</k-lab-example>
<k-lab-example label="Video">
<k-block-figure caption="This is a nice caption">
<k-frame :cover="true" ratio="16/9">
Expand Down
16 changes: 13 additions & 3 deletions panel/src/components/Forms/Blocks/Elements/BlockFigure.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<figure class="k-block-figure">
<figure :style="{ '--block-img-back': backValue }" class="k-block-figure">
<k-button
v-if="isEmpty"
:disabled="disabled"
Expand Down Expand Up @@ -32,6 +32,7 @@
export default {
inheritAttrs: false,
props: {
back: String,
caption: String,
captionMarks: {
default: true,
Expand All @@ -42,7 +43,16 @@ export default {
emptyIcon: String,
emptyText: String
},
emits: ["open", "update"]
emits: ["open", "update"],
computed: {
backValue() {
if (this.back?.startsWith("pattern")) {
return `var(--${this.back})`;
}
return `var(--color-${this.back}, ${this.back})`;
}
}
};
</script>
Expand All @@ -51,7 +61,7 @@ export default {
cursor: pointer;
}
.k-block-figure-container img {
background: var(--pattern-light);
background: var(--block-img-back);
}
.k-block-figure iframe {
border: 0;
Expand Down
13 changes: 11 additions & 2 deletions panel/src/components/Forms/Blocks/Types/Gallery.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<figure>
<figure :style="{ '--block-img-back': back }">
<ul @dblclick="open">
<template v-if="!content.images?.length">
<li
Expand Down Expand Up @@ -43,6 +43,15 @@ import Block from "./Default.vue";
export default {
extends: Block,
computed: {
back() {
const back = this.field("back");
if (back?.startsWith("pattern")) {
return `var(--${back})`;
}
return `var(--color-${back}, ${back})`;
},
captionMarks() {
return this.field("caption", { marks: true }).marks;
},
Expand Down Expand Up @@ -75,7 +84,7 @@ export default {
background: var(--color-background);
}
.k-block-type-gallery img {
background: var(--pattern-light);
background: var(--block-img-back);
}
.k-block-type-gallery figcaption {
padding-top: 0.5rem;
Expand Down
1 change: 1 addition & 0 deletions panel/src/components/Forms/Blocks/Types/Image.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<template>
<k-block-figure
:back="field('back')"
:caption="content.caption"
:caption-marks="captionMarks"
:empty-text="$t('field.blocks.image.placeholder') + ''"
Expand Down

0 comments on commit b976d8c

Please sign in to comment.