Skip to content

Commit 065731f

Browse files
Fix missing bar when switching back to green layout, refactor
1 parent ddbe8f7 commit 065731f

2 files changed

Lines changed: 37 additions & 15 deletions

File tree

resources/js/components/molecules/MBarBlock.vue

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@
5050
BarTypes,
5151
BackgroundTypes,
5252
ColorSchemes,
53-
StyleSetTypes
53+
StyleSetTypes,
54+
Alignments
5455
} from "../../service/canvas/Constants";
5556
import ABar from "../atoms/ABar";
5657
@@ -234,13 +235,47 @@
234235
this.$store.commit('canvas/removeBar', {index: 1})
235236
}
236237
}
238+
},
239+
240+
maybeAddHeadline() {
241+
// Green and young layouts need at least 2 headline bars
242+
if ((this.styleSet !== StyleSetTypes.green2025 &&
243+
this.styleSet !== StyleSetTypes.green2025Centered) &&
244+
this.bars.filter(bar => bar.type === BarTypes.headline).length === 1) {
245+
246+
const secondHeadline = {
247+
type: BarTypes.headline,
248+
schema: BarSchemes.magenta,
249+
text: 'Headline',
250+
canvas: null,
251+
padding: 0,
252+
};
253+
254+
this.$store.dispatch(
255+
'canvas/addBar',
256+
{index: 1, bar: secondHeadline}
257+
);
258+
}
237259
}
238260
},
239261
240262
watch: {
241263
styleSet() {
242264
this.maybeRemoveSubline();
243265
this.maybeRemoveHeadline();
266+
this.maybeAddHeadline();
267+
268+
// Handle alignment based on style set
269+
const currentAlignment = this.$store.getters['canvas/getAlignment'];
270+
271+
if ((this.styleSet === StyleSetTypes.green || this.styleSet === StyleSetTypes.green2025) &&
272+
currentAlignment !== Alignments.left) {
273+
this.$store.dispatch('canvas/setAlignment', Alignments.left);
274+
} else if (this.styleSet === StyleSetTypes.greenCentered ||
275+
this.styleSet === StyleSetTypes.green2025Centered ||
276+
this.styleSet === StyleSetTypes.young) {
277+
this.$store.dispatch('canvas/setAlignment', Alignments.center);
278+
}
244279
245280
this.$nextTick(() => {
246281
this.updateBarSchemas();

resources/js/components/organisms/OImagery.vue

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@
7272
</template>
7373

7474
<script>
75-
import {BackgroundTypes, HugeImageSurfaceLimit, StyleSetTypes, Alignments} from "../../service/canvas/Constants";
75+
import {BackgroundTypes, HugeImageSurfaceLimit, StyleSetTypes} from "../../service/canvas/Constants";
7676
import MBarBlock from "../molecules/MBarBlock";
7777
import MBackgroundBlock from "../molecules/MBackgroundBlock";
7878
import MBorderBlock from "../molecules/MBorderBlock";
@@ -122,7 +122,6 @@ let requestedAnimationFrame;
122122
context: null,
123123
backgroundTypes: BackgroundTypes,
124124
styleSetTypes: StyleSetTypes,
125-
alignments: Alignments,
126125
127126
viewHeight: document.documentElement.clientHeight,
128127
viewWidth: document.documentElement.clientWidth,
@@ -539,18 +538,6 @@ let requestedAnimationFrame;
539538
},
540539
styleSet(value) {
541540
this.engine.styleSet = value;
542-
543-
const currentAlignment = this.$store.getters['canvas/getAlignment'];
544-
545-
if ((value === StyleSetTypes.green || value === StyleSetTypes.green2025) &&
546-
currentAlignment !== Alignments.right) {
547-
this.$store.dispatch('canvas/setAlignment', Alignments.left);
548-
} else if (value === StyleSetTypes.greenCentered ||
549-
value === StyleSetTypes.green2025Centered ||
550-
value === StyleSetTypes.young) {
551-
this.$store.dispatch('canvas/setAlignment', Alignments.center);
552-
}
553-
554541
this.draw().catch(console.debug);
555542
},
556543
format(value) {

0 commit comments

Comments
 (0)