forked from avatsaev/slackin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsplash.js
321 lines (267 loc) · 8.3 KB
/
splash.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = splash;
var _vd = require('vd');
var _vd2 = _interopRequireDefault(_vd);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function splash(_ref) {
var path = _ref.path;
var name = _ref.name;
var org = _ref.org;
var coc = _ref.coc;
var logo = _ref.logo;
var active = _ref.active;
var total = _ref.total;
var channels = _ref.channels;
var large = _ref.large;
var iframe = _ref.iframe;
var gcaptcha_sitekey = _ref.gcaptcha_sitekey;
var div = (0, _vd2.default)('.splash', !iframe && (0, _vd2.default)('.logos', logo && (0, _vd2.default)('.logo.org'), (0, _vd2.default)('.logo.slack')), (0, _vd2.default)('p', 'Join ', (0, _vd2.default)('b', name),
// mention single single-channel inline
channels && channels.length === 1 && (0, _vd2.default)('span', ' #', channels[0]), ' on Slack.'), (0, _vd2.default)('p.status', active ? [(0, _vd2.default)('b.active', active), ' users online now of ', (0, _vd2.default)('b.total', total), ' registered.'] : [(0, _vd2.default)('b.total', total), ' users are registered so far.']), (0, _vd2.default)('form id=invite', channels && (channels.length > 1
// channel selection when there are multiple
? (0, _vd2.default)('select.form-item name=channel', channels.map(function (channel) {
return (0, _vd2.default)('option', { value: channel, text: channel });
}))
// otherwise a fixed channel
: (0, _vd2.default)('input type=hidden name=channel', { value: channels[0] })), (0, _vd2.default)('input.form-item type=email name=email [email protected] ' + (!iframe ? 'autofocus' : '')), (0, _vd2.default)('br'), (0, _vd2.default)('div class="g-recaptcha" data-sitekey="' + gcaptcha_sitekey + '"'), coc && (0, _vd2.default)('.coc', (0, _vd2.default)('label', (0, _vd2.default)('input type=checkbox name=coc value=1'), 'I agree to the ', (0, _vd2.default)('a', { href: coc, target: '_blank' }, 'Code of Conduct'), '.')), (0, _vd2.default)('button.loading', 'Get my Invite')), (0, _vd2.default)('p.signin', 'or ', (0, _vd2.default)('a href=https://' + org + '.slack.com target=_top', 'sign in'), '.'), !iframe && (0, _vd2.default)('footer', 'powered by ', (0, _vd2.default)('a href=http://rauchg.com/slackin target=_blank', 'slackin')), style({ logo: logo, active: active, large: large, iframe: iframe }),
// xxx: single build
(0, _vd2.default)('script', '\n data = {};\n data.path = ' + JSON.stringify(path) + ';\n '), (0, _vd2.default)('script src=https://cdn.socket.io/socket.io-1.4.4.js'), (0, _vd2.default)('script src=' + path + 'assets/superagent.js'), (0, _vd2.default)('script src=' + path + 'assets/client.js'));
return div;
}
var pink = '#E01563';
function style() {
var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var logo = _ref2.logo;
var active = _ref2.active;
var large = _ref2.large;
var iframe = _ref2.iframe;
var css = _vd2.default.style();
css.add('html', { 'font-size': large ? '14px' : '10px' });
css.add('.splash', {
'width': iframe ? '25rem' : '30rem',
'margin': iframe ? '0' : '20rem auto',
'text-align': 'center',
'font-family': '"Helvetica Neue", Helvetica, Arial'
});
if (iframe) {
css.add('body, html', {
'margin': '0',
'padding': '0',
'background': '#FAFAFA',
'overflow': 'hidden' // ff
});
css.add('.splash', {
'box-sizing': 'border-box',
'padding': '1rem'
});
}
if (!iframe) {
css.media('(max-width: 50rem)').add('.splash', {
'margin-top': '10rem'
});
}
css.add('.head', {
'margin-bottom': '4rem'
});
css.add('.logos', {
'position': 'relative',
'margin-bottom': '4rem'
});
if (!iframe) {
css.add('.logo', {
'width': '4.8rem',
'height': '4.8rem',
'display': 'inline-block',
'background-size': 'cover'
});
css.add('.logo.slack', {
'background-image': 'url(assets/slack.svg)'
});
if (logo) {
var pw = 1; // '+' width in rem
var lp = 3; // logos separation in rem
css.add('.logo.org::after', {
'position': 'absolute',
'display': 'block',
'content': '"+"',
'top': '1.5rem',
'left': '0',
'width': '30rem',
'text-align': 'center',
'color': '#D6D6D6',
'font-size': '1.5rem', // can't use rem in font shorthand IE9-10
// http://codersblock.com/blog/font-shorthand-bug-in-ie10/
'font-family': 'Helvetica Neue'
});
css.add('.logo.org', {
'background-image': 'url(' + logo + ')',
'margin-right': lp + pw + lp + 'rem'
});
}
}
css.add('.coc', {
'font-size': '1.2rem',
padding: '1.5rem 0 .5rem',
color: '#666'
});
if (iframe) {
css.add('.coc', {
'font-size': '1.1rem',
'padding-top': '1rem'
});
css.add('.coc input', {
position: 'relative',
top: '-.2rem'
});
}
css.add('.coc label', {
cursor: 'pointer'
});
css.add('.coc input', {
'appearance': 'none',
'-webkit-appearance': 'none',
border: 'none',
'vertical-align': 'middle',
margin: '0 .5rem 0 0'
});
css.add('.coc input::after', {
content: '""',
display: 'inline-block',
width: '1.5rem',
height: '1.5rem',
'vertical-align': 'middle',
background: 'url(/assets/checkbox.svg)',
cursor: 'pointer'
});
css.add('.coc input:checked::after', {
'background-position': 'right'
});
css.add('.coc a', {
color: '#666'
});
css.add('.coc a:hover', {
'background-color': '#666',
'text-decoration': 'none',
color: '#fff'
});
css.add('p', {
'font-size': iframe ? '1.2rem' : '1.5rem',
'margin': iframe ? '0 0 .5rem' : '.5rem 0'
});
if (iframe) {
css.add('p.status', {
'font-size': '1.1rem'
});
}
css.add('select', {
'background': 'none'
});
css.add('button, .form-item', {
'font-size': '1.2rem',
'margin-top': iframe ? '.5rem' : '1rem',
'vertical-align': 'middle',
'display': 'block',
'text-align': 'center',
'box-sizing': 'border-box',
'width': '100%',
'padding': '.9rem'
});
css.add('button', {
'color': '#fff',
'font-weight': 'bold',
'border-width': 0,
'background': pink,
'text-transform': 'uppercase',
'cursor': 'pointer',
'appearence': 'none',
'-webkit-appearence': 'none',
'outline': '0',
'transition': 'background-color 150ms ease-in, color 150ms ease-in'
});
css.add('button.loading', {
'pointer-events': 'none'
});
css.add('button:disabled', {
'color': '#9B9B9B',
'background-color': '#D6D6D6',
'cursor': 'default',
'pointer-events': 'none'
});
css.add('button.error', {
'background-color': '#F4001E',
'text-transform': 'none'
});
css.add('button.success:disabled', {
'color': '#fff',
'background-color': '#68C200'
});
css.add('button:not(.disabled):active', {
'background-color': '#7A002F'
});
css.add('b', {
'transition': 'transform 150ms ease-in'
});
css.add('b.grow', {
'transform': 'scale(1.3)'
});
css.add('form', {
'margin-top': iframe ? '1rem' : '2rem',
'margin-bottom': '0'
});
css.add('input', {
'color': '#9B9B9B',
'border': '.1rem solid #D6D6D6'
});
if (iframe) {
css.add('button, .form-item', {
'height': '2.8rem',
'line-height': '2.8rem',
'padding': 0,
'font-size': '1.1rem'
});
}
css.add('input:focus', {
'color': '#666',
'border-color': '#999',
'outline': '0'
});
if (active) {
css.add('.active', {
'color': pink
});
}
css.add('p.signin', {
'padding': '1rem 0 1rem',
'font-size': '1.1rem'
});
css.add('p.signin a', {
'color': pink,
'text-decoration': 'none'
});
css.add('p.signin a:hover', {
'background-color': '#E01563',
color: '#fff'
});
if (!iframe) {
css.add('footer', {
'color': '#D6D6D6',
'font-size': '1.1rem',
'margin': '20rem auto 0',
'width': '30rem',
'text-align': 'center'
});
css.add('footer a', {
'color': '#9B9B9B',
'text-decoration': 'none',
'border-bottom': '.1rem solid #9B9B9B'
});
css.add('footer a:hover', {
'color': '#fff',
'background-color': '#9B9B9B'
});
}
return css;
}