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
CategoriesTabs.js
67 lines
| 1 | /* global tiobDash */ |
| 2 | import classnames from 'classnames'; |
| 3 | |
| 4 | import { withDispatch, withSelect } from '@wordpress/data'; |
| 5 | import { compose } from '@wordpress/compose'; |
| 6 | |
| 7 | const CategoriesTabs = ( { |
| 8 | categories, |
| 9 | count, |
| 10 | category, |
| 11 | setCurrentCategory, |
| 12 | showCount = false, |
| 13 | } ) => { |
| 14 | return ( |
| 15 | <div className="editor-tabs"> |
| 16 | { Object.keys( categories ).map( ( key, index ) => { |
| 17 | if ( 1 > count[ key ] ) { |
| 18 | return null; |
| 19 | } |
| 20 | if ( |
| 21 | tiobDash && |
| 22 | tiobDash.isValidLicense === '1' && |
| 23 | 'free' === key |
| 24 | ) { |
| 25 | return null; |
| 26 | } |
| 27 | const classes = classnames( [ |
| 28 | 'tab', |
| 29 | key, |
| 30 | { active: key === category }, |
| 31 | ] ); |
| 32 | return ( |
| 33 | <a |
| 34 | key={ index } |
| 35 | href="#" |
| 36 | className={ classes } |
| 37 | onClick={ ( e ) => { |
| 38 | e.preventDefault(); |
| 39 | setCurrentCategory( key ); |
| 40 | } } |
| 41 | > |
| 42 | <span className="editor">{ categories[ key ] }</span> |
| 43 | { showCount && ( |
| 44 | <span className="count">{ count[ key ] }</span> |
| 45 | ) } |
| 46 | </a> |
| 47 | ); |
| 48 | } ) } |
| 49 | </div> |
| 50 | ); |
| 51 | }; |
| 52 | |
| 53 | export default compose( |
| 54 | withSelect( ( select ) => { |
| 55 | const { getCurrentCategory } = select( 'neve-onboarding' ); |
| 56 | return { |
| 57 | category: getCurrentCategory(), |
| 58 | }; |
| 59 | } ), |
| 60 | withDispatch( ( dispatch ) => { |
| 61 | const { setCurrentCategory } = dispatch( 'neve-onboarding' ); |
| 62 | return { |
| 63 | setCurrentCategory: ( category ) => setCurrentCategory( category ), |
| 64 | }; |
| 65 | } ) |
| 66 | )( CategoriesTabs ); |
| 67 |