common.js
94 lines
| 1 | import { __ } from '@wordpress/i18n'; |
| 2 | |
| 3 | const addUrlHash = ( hash ) => { |
| 4 | window.location.hash = hash; |
| 5 | }; |
| 6 | |
| 7 | const getTabHash = ( tabs ) => { |
| 8 | let hash = window.location.hash; |
| 9 | |
| 10 | if ( 'string' !== typeof window.location.hash ) { |
| 11 | return null; |
| 12 | } |
| 13 | |
| 14 | hash = hash.substring( 1 ); |
| 15 | |
| 16 | if ( ! Object.keys( tabs ).includes( hash ) ) { |
| 17 | return null; |
| 18 | } |
| 19 | |
| 20 | return hash; |
| 21 | }; |
| 22 | |
| 23 | const untrailingSlashIt = ( str ) => str.replace( /\/$/, '' ); |
| 24 | const trailingSlashIt = ( str ) => untrailingSlashIt( str ) + '/'; |
| 25 | |
| 26 | const isTabbedEditor = false; |
| 27 | |
| 28 | const TAGS = [ |
| 29 | __( 'Business', 'templates-patterns-collection' ), |
| 30 | __( 'Ecommerce', 'templates-patterns-collection' ), |
| 31 | __( 'Fashion', 'templates-patterns-collection' ), |
| 32 | __( 'Blogging', 'templates-patterns-collection' ), |
| 33 | __( 'Photography', 'templates-patterns-collection' ), |
| 34 | ]; |
| 35 | const CATEGORIES = { |
| 36 | all: __( 'All Categories', 'templates-patterns-collection' ), |
| 37 | free: __( 'Free', 'templates-patterns-collection' ), |
| 38 | business: __( 'Business', 'templates-patterns-collection' ), |
| 39 | portfolio: __( 'Portfolio', 'templates-patterns-collection' ), |
| 40 | woocommerce: __( 'WooCommerce', 'templates-patterns-collection' ), |
| 41 | blog: __( 'Blog', 'templates-patterns-collection' ), |
| 42 | personal: __( 'Personal', 'templates-patterns-collection' ), |
| 43 | other: __( 'Other', 'templates-patterns-collection' ), |
| 44 | }; |
| 45 | const EDITOR_MAP = { |
| 46 | gutenberg: { |
| 47 | icon: 'gutenberg.jpg', |
| 48 | niceName: 'Gutenberg', |
| 49 | }, |
| 50 | elementor: { |
| 51 | icon: 'elementor.jpg', |
| 52 | niceName: 'Elementor', |
| 53 | }, |
| 54 | }; |
| 55 | |
| 56 | const EDITOR_MAP_ARCHIVED = { |
| 57 | 'beaver builder': { |
| 58 | icon: 'beaver.jpg', |
| 59 | niceName: ( |
| 60 | <> |
| 61 | Beaver <span className="long-name">Builder</span> |
| 62 | </> |
| 63 | ), |
| 64 | }, |
| 65 | brizy: { |
| 66 | icon: 'brizy.jpg', |
| 67 | niceName: 'Brizy', |
| 68 | }, |
| 69 | 'divi builder': { |
| 70 | icon: 'divi.jpg', |
| 71 | niceName: 'Divi', |
| 72 | }, |
| 73 | 'thrive architect': { |
| 74 | icon: 'thrive.jpg', |
| 75 | niceName: ( |
| 76 | <> |
| 77 | Thrive <span className="long-name">Architect</span> |
| 78 | </> |
| 79 | ), |
| 80 | }, |
| 81 | }; |
| 82 | |
| 83 | export { |
| 84 | addUrlHash, |
| 85 | getTabHash, |
| 86 | trailingSlashIt, |
| 87 | untrailingSlashIt, |
| 88 | isTabbedEditor, |
| 89 | CATEGORIES, |
| 90 | EDITOR_MAP, |
| 91 | EDITOR_MAP_ARCHIVED, |
| 92 | TAGS, |
| 93 | }; |
| 94 |