2020-09-14 08:22:19 +03:00
import * as React from "react" ;
import * as Constants from "~/common/constants" ;
2020-10-29 20:43:04 +03:00
import * as Actions from "~/common/actions" ;
2020-11-28 07:39:01 +03:00
import * as Events from "~/common/custom-events" ;
2020-09-14 08:22:19 +03:00
2020-11-30 08:24:22 +03:00
import { css } from "@emotion/react" ;
2020-10-30 06:33:25 +03:00
import { ButtonPrimary } from "~/components/system/components/Buttons" ;
2020-09-14 08:22:19 +03:00
const STYLES _MODAL = css `
text - align : center ;
padding - bottom : 64 px ;
box - sizing : border - box ;
max - width : 680 px ;
width : 95 vw ;
2020-09-15 05:58:23 +03:00
min - height : 630 px ;
2020-09-14 08:22:19 +03:00
border - radius : 4 px ;
background - color : $ { Constants . system . white } ;
overflow : hidden ;
box - shadow : 0 0 60 px 8 px rgba ( 0 , 0 , 0 , 0.03 ) ;
` ;
const STYLES _BUTTON _SECONDARY = {
backgroundColor : Constants . system . white ,
2021-07-07 22:14:51 +03:00
boxShadow : ` 0 0 0 1px ${ Constants . system . blue } inset ` ,
color : Constants . system . blue ,
2020-09-14 08:22:19 +03:00
marginRight : 16 ,
width : 160 ,
2020-10-29 20:43:04 +03:00
textDecoration : ` none ` ,
2020-09-14 08:22:19 +03:00
} ;
const STYLES _IMAGE = css `
width : 100 % ;
background - color : $ { Constants . system . black } ;
` ;
const STYLES _TITLE = css `
font - family : $ { Constants . font . semiBold } ;
font - size : 32 px ;
padding - top : 40 px ;
margin - bottom : 16 px ;
` ;
const STYLES _TEXT = css `
font - family : $ { Constants . font . text } ;
font - size : 18 px ;
margin - bottom : 24 px ;
padding : 0 64 px ;
` ;
2020-10-30 03:48:47 +03:00
const STYLES _LINK = css `
text - decoration : none ;
color : $ { Constants . system . white } ;
: visited {
color : $ { Constants . system . white } ;
}
` ;
2021-06-01 02:41:00 +03:00
export const announcements = [ ] ;
2020-10-29 20:43:04 +03:00
2020-09-14 08:22:19 +03:00
export class OnboardingModal extends React . Component {
state = {
step : 0 ,
2020-10-29 20:43:04 +03:00
slides : [ ] ,
} ;
componentDidMount = ( ) => {
2021-03-07 23:53:54 +03:00
Actions . updateStatus ( {
onboarding : this . props . unseenAnnouncements ,
} ) ;
2020-10-30 06:33:25 +03:00
let slides = [ ] ;
if ( this . props . newAccount ) {
slides = this . onboardingCopy ;
2020-10-29 20:43:04 +03:00
}
2020-11-04 00:43:11 +03:00
for ( let feature of this . announcements ) {
2020-10-29 20:43:04 +03:00
if ( this . props . unseenAnnouncements . includes ( feature . title ) ) {
2020-10-30 06:33:25 +03:00
slides . push ( feature ) ;
2020-10-29 20:43:04 +03:00
}
}
2020-10-30 06:33:25 +03:00
if ( ! slides . length ) {
2020-11-28 07:39:01 +03:00
Events . dispatchCustomEvent ( {
2020-10-30 06:33:25 +03:00
name : "delete-modal" ,
detail : { } ,
} ) ;
}
this . setState ( { slides } ) ;
2020-09-14 08:22:19 +03:00
} ;
2020-11-04 00:43:11 +03:00
announcements = [
2021-06-01 02:41:00 +03:00
// {
// title: "New On Slate: Grid System 2.0",
// text:
// "We just introduced a completely new layout engine that gives you total control over the way you can organize and display your collections.",
// image: (
// <img
// src="https://slate.textile.io/ipfs/bafybeigb7pd2dh64ty7l2yhnzu5kjupgxbfzqzjjb2gtprexfxzkwx4nle"
// alt="grid layout"
// css={STYLES_IMAGE}
// />
// ),
// button: (
// <ButtonPrimary style={{ width: 160 }} onClick={() => this._handleClick(1)}>
// Try it out
// </ButtonPrimary>
// ),
// },
2020-11-04 00:43:11 +03:00
] ;
2020-09-14 08:22:19 +03:00
onboardingCopy = [
{
title : "Welcome to Slate" ,
text :
2021-03-03 21:24:32 +03:00
"Slate is a distributed file-sharing network designed for private and public storage. Drag and drop your files into the app to easily start uploading your books, images, and documents." ,
2020-09-14 08:22:19 +03:00
image : (
< img
src = "https://slate.textile.io/ipfs/bafybeih4yqlefcbvuuhuyddg5vyfcm7latyifexzynmnbep4dx5hapbbjq"
alt = ""
css = { STYLES _IMAGE }
/ >
) ,
button : (
2020-10-27 07:14:13 +03:00
< ButtonPrimary style = { { width : 160 } } onClick = { ( ) => this . _handleClick ( 1 ) } >
2020-09-14 08:22:19 +03:00
Got it
< / B u t t o n P r i m a r y >
) ,
} ,
{
title : "Upload from Anywhere" ,
text :
"Use the Slate Chrome extension to upload images and screenshots to your account from anywhere on the web." ,
image : (
< img
src = "https://slate.textile.io/ipfs/bafybeifchvk6cxi4yl3twlontxlpkff623pcz2lhukrlzwor5rioviqsea"
alt = ""
css = { STYLES _IMAGE }
/ >
) ,
button : (
< React . Fragment >
2020-10-29 20:43:04 +03:00
< a
href = "https://chrome.google.com/webstore/detail/slate/gloembacbehhbfbkcfjmloikeeaebnoc"
target = "_blank"
style = { { textDecoration : ` none ` } }
>
< ButtonPrimary style = { STYLES _BUTTON _SECONDARY } > Get extension < / B u t t o n P r i m a r y >
< / a >
2020-10-27 07:14:13 +03:00
< ButtonPrimary style = { { width : 160 } } onClick = { ( ) => this . _handleClick ( 1 ) } >
2020-09-14 08:22:19 +03:00
Next
< / B u t t o n P r i m a r y >
< / R e a c t . F r a g m e n t >
) ,
} ,
{
title : "Organize and share" ,
text :
"Organize your files into slates to organize research, create mood boards, and collect your thoughts to share with other people." ,
image : (
< img
src = "https://slate.textile.io/ipfs/bafybeiaiy3c72sdirjj24vvev7xpuvvqckwip3ot7l4u4iaxdlnbp4hqae"
alt = ""
css = { STYLES _IMAGE }
/ >
) ,
button : (
2020-10-29 20:43:04 +03:00
< ButtonPrimary style = { { width : 160 } } onClick = { ( ) => this . _handleClick ( 1 ) } >
2020-09-14 08:22:19 +03:00
Start using Slate
< / B u t t o n P r i m a r y >
) ,
} ,
] ;
_handleClick = ( i ) => {
2020-10-29 20:43:04 +03:00
if ( this . state . step + i >= this . state . slides . length ) {
2020-11-28 07:39:01 +03:00
Events . dispatchCustomEvent ( {
2020-10-29 20:43:04 +03:00
name : "delete-modal" ,
detail : { } ,
} ) ;
} else {
this . setState ( { step : this . state . step + i } ) ;
}
2020-09-14 08:22:19 +03:00
} ;
render ( ) {
2020-10-29 20:43:04 +03:00
if ( ! this . state . slides || ! this . state . slides . length ) {
return null ;
}
2020-09-14 08:22:19 +03:00
return (
2020-10-29 20:43:04 +03:00
< div >
< div css = { STYLES _MODAL } >
< div >
{ this . state . slides [ this . state . step ] . image }
< div css = { STYLES _TITLE } > { this . state . slides [ this . state . step ] . title } < / d i v >
< div css = { STYLES _TEXT } > { this . state . slides [ this . state . step ] . text } < / d i v >
{ this . state . slides [ this . state . step ] . button }
< / d i v >
< / d i v >
2020-09-14 08:22:19 +03:00
< / d i v >
) ;
}
}