diff options
Diffstat (limited to 'src/features/shareFranz/Component.js')
-rw-r--r-- | src/features/shareFranz/Component.js | 170 |
1 files changed, 170 insertions, 0 deletions
diff --git a/src/features/shareFranz/Component.js b/src/features/shareFranz/Component.js new file mode 100644 index 000000000..d463664df --- /dev/null +++ b/src/features/shareFranz/Component.js | |||
@@ -0,0 +1,170 @@ | |||
1 | import React, { Component } from 'react'; | ||
2 | import PropTypes from 'prop-types'; | ||
3 | import { observer, inject } from 'mobx-react'; | ||
4 | import injectSheet from 'react-jss'; | ||
5 | import { defineMessages, intlShape } from 'react-intl'; | ||
6 | import { Button } from '@meetfranz/forms'; | ||
7 | import { H1, Icon } from '@meetfranz/ui'; | ||
8 | |||
9 | import Modal from '../../components/ui/Modal'; | ||
10 | import { state } from '.'; | ||
11 | import { gaEvent } from '../../lib/analytics'; | ||
12 | import ServicesStore from '../../stores/ServicesStore'; | ||
13 | |||
14 | const messages = defineMessages({ | ||
15 | headline: { | ||
16 | id: 'feature.shareFranz.headline', | ||
17 | defaultMessage: '!!!Franz is better together!', | ||
18 | }, | ||
19 | text: { | ||
20 | id: 'feature.shareFranz.text', | ||
21 | defaultMessage: '!!!Tell your friends and colleagues how awesome Franz is and help us to spread the word.', | ||
22 | }, | ||
23 | actions: { | ||
24 | email: { | ||
25 | id: 'feature.shareFranz.action.email', | ||
26 | defaultMessage: '!!!Share as email', | ||
27 | }, | ||
28 | facebook: { | ||
29 | id: 'feature.shareFranz.action.facebook', | ||
30 | defaultMessage: '!!!Share on Facebook', | ||
31 | }, | ||
32 | twitter: { | ||
33 | id: 'feature.shareFranz.action.twitter', | ||
34 | defaultMessage: '!!!Share on Twitter', | ||
35 | }, | ||
36 | }, | ||
37 | shareText: { | ||
38 | email: { | ||
39 | id: 'feature.shareFranz.shareText.email', | ||
40 | defaultMessage: '!!! I\'ve added {count} services to Franz! Get the free app for WhatsApp, Messenger, Slack, Skype and co at www.meetfranz.com', | ||
41 | }, | ||
42 | twitter: { | ||
43 | id: 'feature.shareFranz.shareText.twitter', | ||
44 | defaultMessage: '!!! I\'ve added {count} services to Franz! Get the free app for WhatsApp, Messenger, Slack, Skype and co at www.meetfranz.com /cc @MeetFranz', | ||
45 | }, | ||
46 | }, | ||
47 | }); | ||
48 | |||
49 | const styles = theme => ({ | ||
50 | modal: { | ||
51 | width: '80%', | ||
52 | maxWidth: 600, | ||
53 | background: theme.styleTypes.primary.accent, | ||
54 | textAlign: 'center', | ||
55 | color: theme.styleTypes.primary.contrast, | ||
56 | }, | ||
57 | heartContainer: { | ||
58 | display: 'flex', | ||
59 | justifyContent: 'center', | ||
60 | borderRadius: '100%', | ||
61 | background: theme.brandDanger, | ||
62 | padding: 20, | ||
63 | width: 100, | ||
64 | height: 100, | ||
65 | margin: [-70, 'auto', 30], | ||
66 | }, | ||
67 | heart: { | ||
68 | fill: theme.styleTypes.primary.contrast, | ||
69 | }, | ||
70 | headline: { | ||
71 | textAlign: 'center', | ||
72 | fontSize: 40, | ||
73 | marginBottom: 20, | ||
74 | }, | ||
75 | actions: { | ||
76 | display: 'flex', | ||
77 | justifyContent: 'space-between', | ||
78 | marginTop: 30, | ||
79 | }, | ||
80 | cta: { | ||
81 | background: theme.styleTypes.primary.contrast, | ||
82 | color: theme.styleTypes.primary.accent, | ||
83 | |||
84 | '& svg': { | ||
85 | fill: theme.styleTypes.primary.accent, | ||
86 | }, | ||
87 | }, | ||
88 | }); | ||
89 | |||
90 | export default @injectSheet(styles) @inject('stores') @observer class ShareFranzModal extends Component { | ||
91 | static propTypes = { | ||
92 | classes: PropTypes.object.isRequired, | ||
93 | } | ||
94 | |||
95 | static contextTypes = { | ||
96 | intl: intlShape, | ||
97 | }; | ||
98 | |||
99 | close() { | ||
100 | state.isModalVisible = false; | ||
101 | } | ||
102 | |||
103 | render() { | ||
104 | const { isModalVisible } = state; | ||
105 | |||
106 | const { | ||
107 | classes, | ||
108 | stores, | ||
109 | } = this.props; | ||
110 | |||
111 | const serviceCount = stores.services.all.length; | ||
112 | |||
113 | const { intl } = this.context; | ||
114 | |||
115 | return ( | ||
116 | <Modal | ||
117 | isOpen={isModalVisible} | ||
118 | className={classes.modal} | ||
119 | shouldCloseOnOverlayClick | ||
120 | close={this.close.bind(this)} | ||
121 | > | ||
122 | <div className={classes.heartContainer}> | ||
123 | <Icon icon="mdiHeart" className={classes.heart} size={4} /> | ||
124 | </div> | ||
125 | <H1 className={classes.headline}> | ||
126 | {intl.formatMessage(messages.headline)} | ||
127 | </H1> | ||
128 | <p>{intl.formatMessage(messages.text)}</p> | ||
129 | <div className={classes.actions}> | ||
130 | <Button | ||
131 | label={intl.formatMessage(messages.actions.email)} | ||
132 | className={classes.cta} | ||
133 | icon="mdiEmail" | ||
134 | href={`mailto:?subject=Meet the cool app Franz&body=${intl.formatMessage(messages.shareText.email, { count: serviceCount })}}`} | ||
135 | target="_blank" | ||
136 | onClick={() => { | ||
137 | gaEvent('Share Franz', 'share', 'Share via email'); | ||
138 | }} | ||
139 | /> | ||
140 | <Button | ||
141 | label={intl.formatMessage(messages.actions.facebook)} | ||
142 | className={classes.cta} | ||
143 | icon="mdiFacebookBox" | ||
144 | href="https://www.facebook.com/sharer/sharer.php?u=https://www.meetfranz.com?utm_source=facebook&utm_medium=referral&utm_campaign=share-button" | ||
145 | target="_blank" | ||
146 | onClick={() => { | ||
147 | gaEvent('Share Franz', 'share', 'Share via Facebook'); | ||
148 | }} | ||
149 | /> | ||
150 | <Button | ||
151 | label={intl.formatMessage(messages.actions.twitter)} | ||
152 | className={classes.cta} | ||
153 | icon="mdiTwitter" | ||
154 | href={`http://twitter.com/intent/tweet?status=${intl.formatMessage(messages.shareText.twitter, { count: serviceCount })}`} | ||
155 | target="_blank" | ||
156 | onClick={() => { | ||
157 | gaEvent('Share Franz', 'share', 'Share via Twitter'); | ||
158 | }} | ||
159 | /> | ||
160 | </div> | ||
161 | </Modal> | ||
162 | ); | ||
163 | } | ||
164 | } | ||
165 | |||
166 | ShareFranzModal.wrappedComponent.propTypes = { | ||
167 | stores: PropTypes.shape({ | ||
168 | services: PropTypes.instanceOf(ServicesStore).isRequired, | ||
169 | }).isRequired, | ||
170 | }; | ||