Skip to content

Commit

Permalink
adds direction property to mj-social-element to reverse icon/text order
Browse files Browse the repository at this point in the history
  • Loading branch information
jamestomasino committed Jul 4, 2024
1 parent 824cd66 commit 989487f
Showing 1 changed file with 21 additions and 6 deletions.
27 changes: 21 additions & 6 deletions packages/mjml-social/src/SocialElement.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export default class MjSocialElement extends BodyComponent {

static allowedAttributes = {
align: 'enum(left,center,right)',
direction: 'enum(left,right)',
'background-color': 'color',
color: 'color',
'border-radius': 'unit(px)',
Expand Down Expand Up @@ -132,6 +133,7 @@ export default class MjSocialElement extends BodyComponent {
static defaultAttributes = {
alt: '',
align: 'left',
direction: 'left',
color: '#000',
'border-radius': '3px',
'font-family': 'Ubuntu, Helvetica, Arial, sans-serif',
Expand Down Expand Up @@ -232,13 +234,10 @@ export default class MjSocialElement extends BodyComponent {
} = this.getSocialAttributes()

const hasLink = !!this.getAttribute('href')
const direction = this.getAttribute('direction')

return `
<tr
${this.htmlAttributes({
class: this.getAttribute('css-class'),
})}
>
const makeIcon = () => {

Check failure on line 239 in packages/mjml-social/src/SocialElement.js

View workflow job for this annotation

GitHub Actions / build (16.x)

Unexpected block statement surrounding arrow body; move the returned value immediately after the `=>`

Check failure on line 239 in packages/mjml-social/src/SocialElement.js

View workflow job for this annotation

GitHub Actions / build (18.x)

Unexpected block statement surrounding arrow body; move the returned value immediately after the `=>`

Check failure on line 239 in packages/mjml-social/src/SocialElement.js

View workflow job for this annotation

GitHub Actions / build (20.x)

Unexpected block statement surrounding arrow body; move the returned value immediately after the `=>`
return `
<td ${this.htmlAttributes({ style: 'td' })}>
<table
${this.htmlAttributes({
Expand Down Expand Up @@ -279,6 +278,10 @@ export default class MjSocialElement extends BodyComponent {
</tbody>
</table>
</td>
`
}

const makeContent = () => `
${
this.getContent()
? `
Expand All @@ -303,6 +306,18 @@ export default class MjSocialElement extends BodyComponent {
`
: ''
}
`

const renderLeft = () => `${makeIcon()} ${makeContent()}`
const renderRight = () => `${makeContent()} ${makeIcon()}`

return `
<tr
${this.htmlAttributes({
class: this.getAttribute('css-class'),
})}
>
${direction === 'left' ? renderLeft() : renderRight() }
</tr>
`
}
Expand Down

0 comments on commit 989487f

Please sign in to comment.