|
48 | 48 | import { |
49 | 49 | BarSchemes, |
50 | 50 | BarTypes, |
| 51 | + BackgroundTypes, |
51 | 52 | ColorSchemes, |
52 | 53 | StyleSetTypes |
53 | 54 | } from "../../service/canvas/Constants"; |
|
70 | 71 | colorSchema: 'canvas/getColorSchema', |
71 | 72 | bars: 'canvas/getBars', |
72 | 73 | textFitsImage: 'canvas/getTextFitsImage', |
| 74 | + backgroundType: 'canvas/getBackgroundType', |
73 | 75 | }), |
74 | 76 |
|
75 | 77 | fontSizePercent: { |
|
131 | 133 | ) |
132 | 134 | }, |
133 | 135 |
|
| 136 | + updateBarSchemas() { |
| 137 | + // Handle bars based on layout and color scheme |
| 138 | + if (this.bars.length > 0 && this.bars[0].type === BarTypes.headline) { |
| 139 | + const schema = this.getSchemaForBar(0); |
| 140 | + this.$store.dispatch('canvas/setBar', { |
| 141 | + index: 0, |
| 142 | + bar: { ...this.bars[0], schema } |
| 143 | + }); |
| 144 | + } |
| 145 | +
|
| 146 | + // Force the second headline to use the scheme for current layout |
| 147 | + if (this.bars.length > 1 && this.bars[1].type === BarTypes.headline) { |
| 148 | + const schema = this.getSchemaForBar(1); |
| 149 | + this.$store.dispatch('canvas/setBar', { |
| 150 | + index: 1, |
| 151 | + bar: { ...this.bars[1], schema } |
| 152 | + }); |
| 153 | + } |
| 154 | +
|
| 155 | + // Handle third headline bar if present (for green layout with 3 headline bars) |
| 156 | + if (this.bars.length > 2 && this.bars[2].type === BarTypes.headline && |
| 157 | + !(this.styleSet === StyleSetTypes.green2025 || this.styleSet === StyleSetTypes.green2025Centered)) { |
| 158 | + this.$store.dispatch('canvas/setBar', { |
| 159 | + index: 2, |
| 160 | + bar: { ...this.bars[2], schema: BarSchemes.magenta } |
| 161 | + }); |
| 162 | + } |
| 163 | +
|
| 164 | + // For subline, use the computed sublineSchema which is based on current style set |
| 165 | + if (this.bars.length > 2 && this.bars[2].type === BarTypes.subline) { |
| 166 | + this.$store.dispatch('canvas/setBar', { |
| 167 | + index: 2, |
| 168 | + bar: { ...this.bars[2], schema: this.sublineSchema } |
| 169 | + }); |
| 170 | + } |
| 171 | + }, |
| 172 | +
|
| 173 | + getSchemaForBar(index) { |
| 174 | + // Green2025 layout |
| 175 | + if (this.styleSet === StyleSetTypes.green2025 || this.styleSet === StyleSetTypes.green2025Centered) { |
| 176 | + return BarSchemes.green2025; |
| 177 | + } |
| 178 | +
|
| 179 | + // Young layout |
| 180 | + if (this.styleSet === StyleSetTypes.young) { |
| 181 | + if(index === 0) { |
| 182 | + return (this.colorSchema === ColorSchemes.white) |
| 183 | + ? BarSchemes.white |
| 184 | + : BarSchemes.green; |
| 185 | + } else { |
| 186 | + return BarSchemes.magenta; |
| 187 | + } |
| 188 | + } |
| 189 | +
|
| 190 | + // Green layout |
| 191 | + const backgroundRequiresGreen = |
| 192 | + this.backgroundType === BackgroundTypes.transparent || |
| 193 | + this.backgroundType === BackgroundTypes.image; |
| 194 | +
|
| 195 | + if (index === 0 || (index === 1 && this.bars.length >2 && this.bars[2].type === BarTypes.headline)) { |
| 196 | + return backgroundRequiresGreen ? BarSchemes.green : BarSchemes.white; |
| 197 | + } |
| 198 | +
|
| 199 | + return BarSchemes.magenta; |
| 200 | + }, |
| 201 | +
|
134 | 202 | maybeRemoveSubline() { |
135 | 203 | // remove sublines for style set young |
136 | 204 | if (this.styleSet === StyleSetTypes.young) { |
|
148 | 216 | // remove first primary headline if there are two |
149 | 217 | const primaryHeadlines = this.bars.filter( |
150 | 218 | bar => bar.type === BarTypes.headline |
151 | | - && (bar.schema === BarSchemes.white || bar.schema === BarSchemes.green) |
| 219 | + && (bar.schema === BarSchemes.white || |
| 220 | + bar.schema === BarSchemes.green || |
| 221 | + bar.schema === BarSchemes.green2025) |
152 | 222 | ); |
153 | 223 | if (primaryHeadlines.length > 1) { |
154 | 224 | this.$store.commit('canvas/removeBar', {index: 0}) |
|
157 | 227 | // remove first secondary headline if there are two |
158 | 228 | const secondaryHeadlines = this.bars.filter( |
159 | 229 | bar => bar.type === BarTypes.headline |
160 | | - && (bar.schema === BarSchemes.magenta) |
| 230 | + && (bar.schema === BarSchemes.magenta || |
| 231 | + bar.schema === BarSchemes.transparent2025) |
161 | 232 | ); |
162 | 233 | if (secondaryHeadlines.length > 1) { |
163 | 234 | this.$store.commit('canvas/removeBar', {index: 1}) |
|
168 | 239 |
|
169 | 240 | watch: { |
170 | 241 | styleSet() { |
171 | | - this.maybeRemoveSubline() |
172 | | - this.maybeRemoveHeadline() |
| 242 | + this.maybeRemoveSubline(); |
| 243 | + this.maybeRemoveHeadline(); |
| 244 | +
|
| 245 | + this.$nextTick(() => { |
| 246 | + this.updateBarSchemas(); |
| 247 | + }); |
| 248 | + }, |
| 249 | + colorSchema() { |
| 250 | + this.$nextTick(() => { |
| 251 | + this.updateBarSchemas(); |
| 252 | + }); |
173 | 253 | }, |
174 | 254 | textFitsImage(val) { |
175 | 255 | if (!val) { |
|
0 commit comments