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