From 39a14a140dd6b4a2d7ed2d56e6730dae5c61dffc Mon Sep 17 00:00:00 2001 From: Daniel Bisgrove Date: Thu, 14 Nov 2024 15:45:37 -0500 Subject: [PATCH 1/2] Adding align and textColor to ngStyles on the text component. Then simplified how we add the styles. --- .../content-text/content-text.component.ts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/app/page/component/content-text/content-text.component.ts b/src/app/page/component/content-text/content-text.component.ts index 74166707..9d555be7 100644 --- a/src/app/page/component/content-text/content-text.component.ts +++ b/src/app/page/component/content-text/content-text.component.ts @@ -54,14 +54,16 @@ export class ContentTextComponent implements OnChanges { } private init(): void { - const styles = {}; - this.text?.textStyles?.forEach((style) => { - if (style.name === 'BOLD') styles['font-weight'] = 'bold'; - if (style.name === 'ITALIC') styles['font-style'] = 'italic'; - if (style.name === 'UNDERLINE') styles['text-decoration'] = 'underline'; - }); + const styles = { + 'font-weight': this.text.textStyles.some(style => style.name === 'BOLD') ? 'bold' : '', + 'font-style': this.text.textStyles.some(style => style.name === 'ITALIC') ? 'italic' : '', + 'text-decoration': this.text.textStyles.some(style => style.name === 'UNDERLINE') ? 'underline' : '', + 'text-align': this.text.textAlign.name || '', + 'color': this.text.textColor || '' + }; + + this.textColor = this.text?.textColor || null; this.styles = styles; - this.textColor = this.text.textColor || null; const text = parseTextAddBrTags(this.text.text); this.textValue = text || ''; this.ready = true; From 7601693cfacf4e9f1174ad2f0ea4f56413d32b73 Mon Sep 17 00:00:00 2001 From: Daniel Bisgrove Date: Thu, 14 Nov 2024 15:57:21 -0500 Subject: [PATCH 2/2] Prettier and test fixes --- src/app/_tests/mocks.ts | 9 ++++++--- .../content-text/content-text.component.ts | 20 +++++++++++++++---- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/src/app/_tests/mocks.ts b/src/app/_tests/mocks.ts index a29ba799..b3b751c0 100644 --- a/src/app/_tests/mocks.ts +++ b/src/app/_tests/mocks.ts @@ -60,10 +60,13 @@ const standardTypeValues = () => { const createText = (text: string): Text => { return { text: text, - textAlign: null, - textColor: null, + textAlign: { + name: 'START', + ordinal: 0 + }, + textColor: '#000000', textScale: null, - _textStyles: null, + _textStyles: [], minimumLines: null, startImage: null, startImageSize: null, diff --git a/src/app/page/component/content-text/content-text.component.ts b/src/app/page/component/content-text/content-text.component.ts index 9d555be7..34b9f650 100644 --- a/src/app/page/component/content-text/content-text.component.ts +++ b/src/app/page/component/content-text/content-text.component.ts @@ -55,11 +55,23 @@ export class ContentTextComponent implements OnChanges { private init(): void { const styles = { - 'font-weight': this.text.textStyles.some(style => style.name === 'BOLD') ? 'bold' : '', - 'font-style': this.text.textStyles.some(style => style.name === 'ITALIC') ? 'italic' : '', - 'text-decoration': this.text.textStyles.some(style => style.name === 'UNDERLINE') ? 'underline' : '', + 'font-weight': this.text.textStyles?.some( + (style) => style.name === 'BOLD' + ) + ? 'bold' + : '', + 'font-style': this.text.textStyles?.some( + (style) => style.name === 'ITALIC' + ) + ? 'italic' + : '', + 'text-decoration': this.text.textStyles?.some( + (style) => style.name === 'UNDERLINE' + ) + ? 'underline' + : '', 'text-align': this.text.textAlign.name || '', - 'color': this.text.textColor || '' + color: this.text.textColor || '' }; this.textColor = this.text?.textColor || null;