-
Notifications
You must be signed in to change notification settings - Fork 12
/
Title.js
71 lines (58 loc) · 1.34 KB
/
Title.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import { MJMLElement } from 'mjml-core'
import merge from 'lodash/merge'
import MJMLText from 'mjml-text'
import React, { Component } from 'react'
import {
registerMJElement,
} from 'mjml'
const tagName = 'mj-title'
const endingTag = false
const columnElement = false
//These are your default css attributes
const defaultMJMLDefinition = {
attributes: {
'color': '#424242',
'font-family': 'Helvetica',
'margin-top': '10px'
}
}
@MJMLElement
class Title extends Component {
/*
* Build your styling here
*/
getStyles() {
const { mjAttribute, color } = this.props
return merge({}, this.constructor.baseStyles, {
text: {
/*
* Get the color attribute
* Example: <mj-title color="blue">content</mj-title>
*/
color: mjAttribute('color'),
fontSize: '14px'
}
})
}
render() {
const css = this.getStyles(),
content = 'Hello World!'
//return (
// <MjText style={ css }>
// { content }
// </MjText>
//)
// TODO temporary fix, remove when mjml is updated
return (
<MJMLText style={css}>
{content}
</MJMLText>
)
}
}
Title.tagName = tagName
Title.defaultMJMLDefinition = defaultMJMLDefinition
Title.endingTag = endingTag
Title.columnElement = columnElement
registerMJElement(Title)
export default Title