-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathindex.tsx
More file actions
540 lines (478 loc) · 16.6 KB
/
Copy pathindex.tsx
File metadata and controls
540 lines (478 loc) · 16.6 KB
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
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
import './index.css'
import {
AppleLogo, AppStoreLogo, CaretDown, DownloadSimple, GooglePlayLogo,
LinuxLogo, QrCode, WindowsLogo,
} from '@phosphor-icons/react'
import { useEffect, useRef, useState } from 'react'
import cx from 'classnames'
import { Button } from '../../components/Buttons'
import { LandingFooterDesc, LandingFooterNav } from '../Landing'
import { useAppState } from '../../state'
import { navigateTabs } from '../../components/utils'
import { Dropdown } from '../../components/Dropdown'
const iosImageQr: any = new URL('assets/ios_app_qr.png', import.meta.url)
const intelImageIcon: any = new URL('assets/icon_intel.png', import.meta.url)
const M1ImageIcon: any = new URL('assets/icon_m1.png', import.meta.url)
const WindowsImageIcon: any = new URL('assets/icon_windows_64.png',
import.meta.url)
const LinuxImageIcon: any = new URL('assets/icon_linux.png', import.meta.url)
const GooglePlayImageIcon: any = new URL('assets/icon_google_play.png',
import.meta.url)
const AppleImageIcon: any = new URL('assets/icon_apple.png', import.meta.url)
const releaseImages: any = {
'macos': new URL('assets/p_macos.png', import.meta.url),
'windows': new URL('assets/p_windows.png', import.meta.url),
'linux': new URL('assets/p_linux.png', import.meta.url),
'ios': new URL('assets/p_ios.png', import.meta.url),
'android': new URL('assets/p_android.png', import.meta.url),
}
const IntelIcon = (props: any) => {
const { className, ...rest } = props
return (
<span className={cx(
'color-icon flex rounded overflow-hidden items-center justify-center',
className)} {...rest}>
<img src={intelImageIcon} className={'w-4/5'} alt="intel"/>
</span>
)
}
const M1Icon = (props: any) => {
const { className, ...rest } = props
return (
<span className={cx(
'color-icon flex rounded overflow-hidden items-center justify-center',
className)} {...rest}>
<img src={M1ImageIcon} className={'w-4/5'} alt="M1"/>
</span>
)
}
const AppleIcon = (props: any) => {
const { className, ...rest } = props
return (
<span className={cx(
'color-icon flex rounded overflow-hidden items-center justify-center',
className)} {...rest}>
<img src={AppleImageIcon} className={'w-4/5'} alt="GooglePlay"/>
</span>
)
}
const Windows64Icon = (props: any) => {
const { className, ...rest } = props
return (
<span className={cx(
'color-icon flex rounded overflow-hidden items-center justify-center',
className)} {...rest}>
<img src={WindowsImageIcon} className={'w-4/5'} alt="Windows64"/>
</span>
)
}
const LinuxIcon = (props: any) => {
const { className, ...rest } = props
return (
<span className={cx(
'color-icon flex rounded overflow-hidden items-center justify-center',
className)} {...rest}>
<img src={LinuxImageIcon} className={'w-4/5'} alt="GooglePlay"/>
</span>
)
}
const GooglePlayIcon = (props: any) => {
const { className, ...rest } = props
return (
<span className={cx(
'color-icon flex rounded overflow-hidden items-center justify-center',
className)} {...rest}>
<img src={GooglePlayImageIcon} className={'w-4/5'} alt="GooglePlay"/>
</span>
)
}
const releases = [
['MacOS', (props = {}) => <AppleLogo {...props} weight={'duotone'}/>],
['Windows', (props = {}) => <WindowsLogo {...props} weight={'duotone'}/>],
['Linux', (props = {}) => <LinuxLogo {...props} weight={'duotone'}/>],
['iOS', (props = {}) => <AppStoreLogo {...props} weight={'duotone'}/>],
['Android', (props = {}) => <GooglePlayLogo {...props} weight={'duotone'}/>],
]
const resolveDownloadHref = (
appState: any,
item: typeof releases[number],
isIOS: boolean,
platform: string = ''
) => {
const rollback =
isIOS ? 'https://apps.apple.com/us/app/logseq/id1601013908' :
`https://github.com/logseq/logseq/releases`
const downloads: any = appState.releases.downloads.get()
platform = platform || item?.[0].toString().toLowerCase()
if (!downloads?.[platform]) {
return rollback
}
return downloads[platform]?.browser_download_url
}
export function WrapGlobalDownloadButton (
props: any = {},
) {
const { className, children, ...rest } = props
const appState = useAppState()
const wrapElRef = useRef<HTMLDivElement>(null)
const os = appState.get().os
const [active, setActive] = useState(releases[0])
const isIOS = active?.[0] === 'iOS'
const isMacOS = active?.[0] === 'MacOS'
const rightIconFn = isMacOS ? (
(props: any = {}) => <CaretDown className={'ml-1 opacity-60'} {...props}/>
) : (isIOS ? (
(props: any = {}) => (
appState.sm.get() ?
<DownloadSimple weight={'duotone'} className={'ml-1 opacity-60'} {...props} /> :
<QrCode weight={'duotone'} className={'ml-1 opacity-60'} {...props}/>)
) : null)
useEffect(() => {
releases.some((it) => {
if (
os[it?.[0].toString().toLowerCase()]
) {
setActive(it)
return true
}
})
}, [os])
const subItems = isMacOS ? (
<div className="sub-items flex flex-col absolute top-5 right-0 w-full pt-6">
<div className="sub-items-inner">
<a className={'block'} href={resolveDownloadHref(appState, active, isIOS, 'macos-x64')}>
<div className="flex items-center">
<div className="flex pr-2">
<IntelIcon className={'bg-black w-8 h-8'}/>
</div>
<div
className={'w-full flex flex-col opacity-80'}
>
<span className="text-sm">
Intel chip
</span>
<span className="text-[11px] opacity-60">
Macs from before November 2020
</span>
</div>
</div>
</a>
<a className={'block'} href={resolveDownloadHref(appState, active, isIOS, 'macos-arm64')}>
<div className="flex items-center">
<div className="flex pr-2">
<M1Icon className={'bg-black w-8 h-8'}/>
</div>
<div
className={'w-full flex flex-col opacity-80'}
>
<span className="text-sm">
Apple silicon
</span>
<span className="text-[11px] opacity-60">
Macs from November 2020 and later
</span>
</div>
</div>
</a>
</div>
</div>
) : (isIOS ? (
<span
className="sub-items absolute top-6 right-2 z-10 flex justify-center translate-x-4 transition-opacity qr">
<img src={iosImageQr} alt="qr" className="w-3/4"/>
</span>
) : null
)
const activePlatformIcon = active?.[1]
return (
<Dropdown
className={cx('global-downloads-wrap', className)}
ref={wrapElRef}
items={subItems}
wrapItems={false}
>
<a className={'block'} target={'_blank'} href={resolveDownloadHref(appState, active, isIOS)}>
{children({
active,
leftIconFn: typeof activePlatformIcon === 'function'
? activePlatformIcon
: () => activePlatformIcon,
rightIconFn,
})}
</a>
</Dropdown>
)
}
export function HeadDownloadLinksSelect (
props: { activeRelease: any, setActiveRelease: any }
) {
const { activeRelease, setActiveRelease } = props
const activeLabel = activeRelease?.[0]
let activeIcon = activeRelease?.[1]
if (typeof activeIcon === 'function') {
activeIcon = activeIcon()
}
return (
<div className={cx('selects', `active-of-${activeLabel?.toLowerCase()}`)}>
<div className="app-form-select-wrap">
<span className="icon">
{activeIcon}
</span>
<select className={'app-form-select w-full'}
onChange={(e) => {
const item = releases.find(it => {
return it[0] === e.target.value
})
setActiveRelease(item)
}}
value={activeLabel}
>
{releases.map(([label]: any) => {
return (
<option
key={label}
value={label}>
{label}
</option>
)
})}
</select>
<span className="arrow">
<CaretDown weight={'bold'}/>
</span>
</div>
</div>
)
}
export function HeadDownloadLinksTabs (
props: { activeRelease: any, setActiveRelease: any }
) {
const { activeRelease, setActiveRelease } = props
return (
<ul className="tabs flex space-x-8 justify-around" role="tablist">
{releases.map(([label, icon]: any) => {
if (typeof icon === 'function') {
icon = icon()
}
const isActive = activeRelease[0] === label
return (
<li className={cx({ active: isActive },
`is-${(label as string).toLowerCase()}`)}
onClick={() => {
setActiveRelease([label, icon])
}}
key={label}
tabIndex={isActive ? 0 : -1}
role="tab"
aria-controls={label}
id={'tab-' + label}
aria-selected={isActive}
onKeyDown={navigateTabs}
>
<span className="opacity-60">
{icon}
</span>
<strong>
{label}
</strong>
</li>
)
})}
</ul>
)
}
export function HeadDownloadLinks () {
const appState = useAppState()
const os = appState.get().os
const isSm = appState.sm.get()
let active = releases[0]
releases.some((it) => {
if (
os[it?.[0].toString().toLowerCase()]
) {
active = it
return true
}
})
const [activeRelease, setActiveRelease] = useState(active)
const _getDownloadHref = (platform: string) => {
const isIOS = platform === 'ios'
const item: any = releases.find(it => {
return (it[0] as string).toLowerCase() === platform
})
return resolveDownloadHref(appState, item, isIOS, platform)
}
const resolvePanel = function ([label, icon]: [string, any]) {
const isWindows = label.toLowerCase() === 'windows'
const isAndroid = label.toLowerCase() === 'android'
const isLinux = label.toLowerCase() === 'linux'
const isIOS = label.toLowerCase() === 'ios'
icon = isWindows ? (
<Windows64Icon className="bg-black/50 w-6 h-6 sm:w-8 sm:h-8"/>
) : (isAndroid ?
<GooglePlayIcon className="bg-black/50 w-6 h-6 sm:w-8 sm:h-8"/>
: (isLinux ?
<LinuxIcon className="bg-black/50 w-6 h-6 sm:w-8 sm:h-8"/> :
(isIOS ? (
<AppleIcon className="bg-black/50 w-6 h-6 sm:w-8 sm:h-8"/>
) : icon)))
switch (label) {
case 'iOS':
return (
<div className="w-full sm:w-auto flex flex-col items-center is-ios cursor-crosshair" id={label}
role="tabpanel" aria-labelledby={'tab-' + label}>
<Button
className={'w-full bg-logseq-400 px-3 py-3 sm:px-6 sm:py-4'}
leftIcon={icon}
disabled={!isSm}
rightIcon={isSm ? <DownloadSimple className="opacity-50"/> : <QrCode className="opacity-50"/>}
href={_getDownloadHref('ios')}
asAnchor={true}
>
Download on the App Store
</Button>
<span
className="absolute top-16 z-10 flex justify-center translate-x-4 transition-opacity qr opacity-0">
<img src={iosImageQr} alt="qr" className="w-1/2"/>
</span>
</div>
)
case 'MacOS':
return (
<div className="w-full sm:w-auto sm:flex sm:space-x-6" id={label} role="tabpanel"
aria-labelledby={'tab-' + label}>
<div className="flex flex-col items-center">
<Button
className={'w-full bg-logseq-400 px-3 py-3 sm:px-6 sm:py-4'}
leftIcon={<IntelIcon className={'w-6 h-6 sm:w-8 sm:h-8 bg-gray-900'}
color={'white'}/>}
rightIcon={<DownloadSimple className="opacity-50"/>}
href={_getDownloadHref('macos-x64')}
asAnchor={true}
>
Download for Intel chip
</Button>
<span className="text-xs opacity-60 py-2">
Most common in Macs
</span>
</div>
<div className="flex flex-col items-center">
<Button
className={'w-full bg-logseq-600 px-3 py-3 sm:px-6 sm:py-4'}
leftIcon={<M1Icon className={'w-6 h-6 sm:w-8 sm:h-8 bg-gray-900'}
color={'white'}/>}
rightIcon={<DownloadSimple className="opacity-50"/>}
href={_getDownloadHref('macos-arm64')}
asAnchor={true}
>
Download for Apple silicon
</Button>
<span className="text-xs opacity-60 py-2">
Macs from November 2020 and later
</span>
</div>
</div>
)
case 'Linux':
return (
<div className={'w-full sm:w-auto flex flex-col items-center'} id={label} role="tabpanel"
aria-labelledby={'tab-' + label}>
<Button
leftIcon={icon}
rightIcon={<DownloadSimple className="opacity-50"/>}
className="w-full sm:w-auto bg-logseq-600 px-3 py-3 sm:px-6 sm:py-4"
href={_getDownloadHref('linux')}
asAnchor={true}
>
Download Linux release
</Button>
<span className="opacity-60 py-3">
You are advised to use <a className="text-logseq-100" target="_blank"
href="https://github.com/TheAssassin/AppImageLauncher">AppImageLauncher</a> for proper desktop integration
</span>
</div>
)
default:
return (
<div className={'w-full sm:w-auto'} id={label} role="tabpanel" aria-labelledby={'tab-' + label}>
<Button
leftIcon={icon}
rightIcon={<DownloadSimple className="opacity-50"/>}
className="w-full bg-logseq-600 px-3 py-3 sm:px-6 sm:py-4"
href={_getDownloadHref(label.toString().toLowerCase())}
asAnchor={true}
>
Download {label} release
</Button>
</div>
)
}
}
return (
<div className="app-head-downloads">
<div className="flex flex-col pt-10 sm:items-center sm:pt-20 pb-12 text-slogan">
<h1 className="text-3xl sm:text-6xl">
<strong className="font-semibold tracking-wide">Download </strong>
<span className="text-logseq-50/80">the apps.</span>
</h1>
<h2
className="text-xl flex flex-col justify-center sm:items-center pt-2 tracking-wide">
<span className="text-logseq-50/80">
Collect your thoughts and get inspired.
</span>
<span className="opacity-90">
Your train-of-thought is waiting for you!
</span>
</h2>
</div>
<div className="dl-items">
{/* Tabs/Select */}
{appState.sm.get() ?
<HeadDownloadLinksSelect
activeRelease={activeRelease}
setActiveRelease={setActiveRelease}
/> :
<HeadDownloadLinksTabs
activeRelease={activeRelease}
setActiveRelease={setActiveRelease}
/>
}
{/* Panels */}
<div className="panels flex sm:justify-center pt-6 pb-0 sm:pb-10 sm:pt-10">
{resolvePanel(activeRelease as any)}
</div>
</div>
<div className="screen-shot sm:-mt-10">
<div className="pt-4 -m-5 sm:m-0 sm:pt-0 sm:mx-24 relative overflow-hidden">
<img alt="Image"
src={releaseImages[activeRelease[0].toString().toLowerCase()]}
className="sm:opacity-90 sm:translate-y-28 rounded-md overflow-hidden sm:-mt-24 img-bg"
/>
</div>
</div>
</div>
)
}
export function DownloadsPage () {
return (
<div className="app-page pt-20">
<div className="page-inner-full-wrap dl-a">
<div className="page-inner">
<HeadDownloadLinks/>
</div>
</div>
<div className="page-inner-full-wrap b relative">
{/* particles background */}
{/*<div id="particles-bg" className="particles-bg"></div>*/}
<div className="page-inner footer-desc pt-16">
<LandingFooterDesc downloadsPage={true}/>
</div>
<div className="page-inner footer-nav">
<div className="page-inner">
<LandingFooterNav/>
</div>
</div>
</div>
</div>
)
}