CloudLibrary
1 year ago
Settings
1 year ago
StarterSites
3 years ago
App.js
2 years ago
Card.js
3 years ago
CategoriesTabs.js
3 years ago
CategorySelector.js
2 years ago
CustomTooltip.js
3 years ago
DocNotice.js
2 years ago
EditorSelector.js
2 years ago
EditorTabs.js
4 years ago
Header.js
2 years ago
Icon.js
2 years ago
ImportModal.js
1 year ago
ImportModalError.js
2 years ago
ImportModalMock.js
4 years ago
ImportModalNote.js
4 years ago
ImportStepper.js
1 year ago
InstallModal.js
1 year ago
License.js
2 years ago
LicensePanelContext.js
3 years ago
Loading.js
4 years ago
Main.js
1 year ago
Migration.js
4 years ago
NewTCNotice.js
1 year ago
Notification.js
4 years ago
OnboardingContent.js
4 years ago
PreviewFrame.js
3 years ago
Search.js
2 years ago
StarterSiteCard.js
3 years ago
StarterSiteCard.js
143 lines
| 1 | /* eslint-disable camelcase */ |
| 2 | import { withDispatch } from '@wordpress/data'; |
| 3 | import { Button, Dashicon } from '@wordpress/components'; |
| 4 | import { useState } from '@wordpress/element'; |
| 5 | import { compose } from '@wordpress/compose'; |
| 6 | import { __ } from '@wordpress/i18n'; |
| 7 | |
| 8 | import classnames from 'classnames'; |
| 9 | |
| 10 | const StarterSiteCard = ( { |
| 11 | data, |
| 12 | setSite, |
| 13 | setPreview, |
| 14 | setModal, |
| 15 | setImportingPages, |
| 16 | } ) => { |
| 17 | const { upsell, screenshot, title, has_templates, isNew } = data; |
| 18 | const [ actionsClass, setActionClass ] = useState( '' ); |
| 19 | |
| 20 | const showActions = () => { |
| 21 | setActionClass( 'visible' ); |
| 22 | }; |
| 23 | const hideActions = () => { |
| 24 | setActionClass( '' ); |
| 25 | }; |
| 26 | |
| 27 | const launchImport = ( e ) => { |
| 28 | e.preventDefault(); |
| 29 | |
| 30 | setSite(); |
| 31 | setModal( true ); |
| 32 | }; |
| 33 | |
| 34 | const launchPreview = ( e ) => { |
| 35 | e.preventDefault(); |
| 36 | setSite(); |
| 37 | setPreview( true ); |
| 38 | }; |
| 39 | |
| 40 | const cardClassNames = classnames( 'card starter-site-card', { |
| 41 | 'has-templates': has_templates, |
| 42 | } ); |
| 43 | |
| 44 | return ( |
| 45 | <div |
| 46 | onMouseEnter={ showActions } |
| 47 | onMouseLeave={ hideActions } |
| 48 | className={ cardClassNames } |
| 49 | > |
| 50 | { isNew && ( |
| 51 | <span className="new-badge"> |
| 52 | { __( |
| 53 | 'New', |
| 54 | 'templates-patterns-collection' |
| 55 | ).toUpperCase() } |
| 56 | </span> |
| 57 | ) } |
| 58 | <div className="top"> |
| 59 | <div className={ 'actions ' + actionsClass }> |
| 60 | <Button isSecondary onClick={ launchPreview }> |
| 61 | { __( 'Preview', 'templates-patterns-collection' ) } |
| 62 | </Button> |
| 63 | { ! upsell && ( |
| 64 | <Button |
| 65 | isPrimary |
| 66 | className="import" |
| 67 | onClick={ launchImport } |
| 68 | > |
| 69 | { __( 'Import', 'templates-patterns-collection' ) } |
| 70 | </Button> |
| 71 | ) } |
| 72 | { ! has_templates && upsell && ( |
| 73 | <Button |
| 74 | isLink |
| 75 | className="templates" |
| 76 | target="_blank" |
| 77 | href="https://themeisle.com/themes/neve/upgrade/?utm_medium=nevedashboard&utm_source=wpadmin&utm_campaign=templatecloud&utm_content=neve" |
| 78 | > |
| 79 | { __( |
| 80 | 'Unlock access with Business plan', |
| 81 | 'templates-patterns-collection' |
| 82 | ) } |
| 83 | </Button> |
| 84 | ) } |
| 85 | { has_templates && ( |
| 86 | <Button |
| 87 | isLink |
| 88 | className="templates" |
| 89 | onClick={ ( e ) => { |
| 90 | e.preventDefault(); |
| 91 | setSite(); |
| 92 | setImportingPages(); |
| 93 | } } |
| 94 | > |
| 95 | { __( |
| 96 | 'View Pages', |
| 97 | 'templates-patterns-collection' |
| 98 | ) } |
| 99 | </Button> |
| 100 | ) } |
| 101 | </div> |
| 102 | { screenshot && ( |
| 103 | <div |
| 104 | className="image" |
| 105 | style={ { |
| 106 | backgroundImage: `url("${ screenshot }")`, |
| 107 | } } |
| 108 | /> |
| 109 | ) } |
| 110 | </div> |
| 111 | <div className="bottom"> |
| 112 | <p className="title">{ title }</p> |
| 113 | { upsell && ( |
| 114 | <span className="pro-badge"> |
| 115 | <Dashicon icon="lock" size={ 15 } /> |
| 116 | <span> |
| 117 | { __( 'Premium', 'templates-patterns-collection' ) } |
| 118 | </span> |
| 119 | </span> |
| 120 | ) } |
| 121 | </div> |
| 122 | </div> |
| 123 | ); |
| 124 | }; |
| 125 | |
| 126 | export default compose( |
| 127 | withDispatch( ( dispatch, { data } ) => { |
| 128 | const { slug } = data; |
| 129 | const { |
| 130 | setCurrentSite, |
| 131 | setPreviewStatus, |
| 132 | setImportModalStatus, |
| 133 | setSingleTemplateImport, |
| 134 | } = dispatch( 'neve-onboarding' ); |
| 135 | return { |
| 136 | setSite: () => setCurrentSite( data ), |
| 137 | setPreview: ( status ) => setPreviewStatus( status ), |
| 138 | setModal: ( status ) => setImportModalStatus( status ), |
| 139 | setImportingPages: () => setSingleTemplateImport( slug ), |
| 140 | }; |
| 141 | } ) |
| 142 | )( StarterSiteCard ); |
| 143 |