Skip to content

Commit

Permalink
Merge pull request #171 from CruGlobal/align-text-attribute
Browse files Browse the repository at this point in the history
Text align to use value from admin
  • Loading branch information
dr-bizz authored Nov 18, 2024
2 parents cc090a2 + 7601693 commit 88d170f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 10 deletions.
9 changes: 6 additions & 3 deletions src/app/_tests/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
28 changes: 21 additions & 7 deletions src/app/page/component/content-text/content-text.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,28 @@ 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;
Expand Down

0 comments on commit 88d170f

Please sign in to comment.