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
EditorTabs.js
85 lines
| 1 | import classnames from 'classnames'; |
| 2 | |
| 3 | import { __ } from '@wordpress/i18n'; |
| 4 | import { withDispatch, withSelect } from '@wordpress/data'; |
| 5 | import { compose } from '@wordpress/compose'; |
| 6 | |
| 7 | import { Dashicon } from '@wordpress/components'; |
| 8 | const EditorTabs = ( { |
| 9 | EDITOR_MAP, |
| 10 | count, |
| 11 | onlyProSites, |
| 12 | editor, |
| 13 | setCurrentEditor, |
| 14 | sites, |
| 15 | } ) => { |
| 16 | const editorsOrderedFromAPI = Object.keys( sites ); |
| 17 | return ( |
| 18 | <div className="editor-tabs"> |
| 19 | { editorsOrderedFromAPI.map( ( key, index ) => { |
| 20 | const classes = classnames( [ |
| 21 | 'tab', |
| 22 | key, |
| 23 | { active: key === editor }, |
| 24 | ] ); |
| 25 | return ( |
| 26 | <a |
| 27 | key={ index } |
| 28 | href="#" |
| 29 | className={ classes } |
| 30 | onClick={ ( e ) => { |
| 31 | e.preventDefault(); |
| 32 | setCurrentEditor( key ); |
| 33 | } } |
| 34 | > |
| 35 | <span className="icon-wrap"> |
| 36 | <img |
| 37 | className="editor-icon" |
| 38 | src={ |
| 39 | tiobDash.assets + |
| 40 | 'img/' + |
| 41 | EDITOR_MAP[ key ].icon |
| 42 | } |
| 43 | alt={ __( |
| 44 | 'Builder Logo', |
| 45 | 'templates-patterns-collection' |
| 46 | ) } |
| 47 | /> |
| 48 | </span> |
| 49 | <span className="editor"> |
| 50 | { onlyProSites.includes( key ) && ( |
| 51 | <Dashicon |
| 52 | icon="lock" |
| 53 | style={ { |
| 54 | fontSize: '16px', |
| 55 | width: '16px', |
| 56 | height: '16px', |
| 57 | } } |
| 58 | /> |
| 59 | ) } |
| 60 | { EDITOR_MAP[ key ].niceName } |
| 61 | </span> |
| 62 | <span className="count">{ count[ key ] }</span> |
| 63 | </a> |
| 64 | ); |
| 65 | } ) } |
| 66 | </div> |
| 67 | ); |
| 68 | }; |
| 69 | |
| 70 | export default compose( |
| 71 | withSelect( ( select ) => { |
| 72 | const { getCurrentEditor, getSites } = select( 'neve-onboarding' ); |
| 73 | return { |
| 74 | editor: getCurrentEditor(), |
| 75 | sites: getSites().sites, |
| 76 | }; |
| 77 | } ), |
| 78 | withDispatch( ( dispatch ) => { |
| 79 | const { setCurrentEditor } = dispatch( 'neve-onboarding' ); |
| 80 | return { |
| 81 | setCurrentEditor: ( editor ) => setCurrentEditor( editor ), |
| 82 | }; |
| 83 | } ) |
| 84 | )( EditorTabs ); |
| 85 |