PluginProbe
Extendify / 0.10.2
Extendify v0.10.2
3.2.1 3.2.0 3.1.6 3.1.5 3.1.4 3.1.3 3.1.2 3.1.1 3.1.0 3.0.6 3.0.5 3.0.4 trunk 0.1.0 0.10.0 0.10.1 0.10.2 0.11.0 0.11.1 0.2.0 0.3.0 0.3.1 0.4.0 0.5.0 0.6.0 All 127 releases
extendify / src / Onboarding / components / PageControl.js

PageControl.js in Extendify 0.10.2, at src/Onboarding/components/PageControl.js

90 lines 3.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import { __ } from '@wordpress/i18n'
2 import classNames from 'classnames'
3 import { useGlobalStore } from '@onboarding/state/Global'
4 import { usePagesStore } from '@onboarding/state/Pages'
5 import { useUserSelectionStore } from '@onboarding/state/UserSelections'
6 import { LeftArrowIcon, RightArrowIcon } from '@onboarding/svg'
7
8 export const PageControl = () => {
9 const { previousPage, currentPageIndex, pages } = usePagesStore()
10 const { openExitModal, setExitButtonHovered } = useGlobalStore()
11 const onFirstPage = currentPageIndex === 0
12 const currentPageKey = Array.from(pages.keys())[currentPageIndex]
13
14 return (
15 <div className="flex items-center space-x-2">
16 {onFirstPage && (
17 <div className="fixed top-0 right-0 px-3 md:px-6 py-2">
18 <button
19 className="flex items-center p-1 text-partner-primary-bg font-medium button-focus md:focus:bg-transparent bg-transparent shadow-none"
20 type="button"
21 title={__('Exit Launch', 'extendify')}
22 onMouseEnter={setExitButtonHovered}
23 onClick={openExitModal}>
24 <span className="dashicons dashicons-no-alt text-white md:text-black"></span>
25 </button>
26 </div>
27 )}
28 <div
29 className={classNames('flex flex-1', {
30 'justify-end': currentPageKey === 'welcome',
31 'justify-between': currentPageKey !== 'welcome',
32 })}>
33 {onFirstPage || (
34 <button
35 className="flex items-center px-4 py-3 text-partner-primary-bg font-medium button-focus bg-gray-100 hover:bg-gray-200 focus:bg-gray-200 bg-transparent"
36 type="button"
37 onClick={previousPage}>
38 <RightArrowIcon className="h-5 w-5" />
39 {__('Back', 'extendify')}
40 </button>
41 )}
42 {onFirstPage && (
43 <button
44 className="flex items-center px-4 py-3 text-partner-primary-bg font-medium button-focus bg-gray-100 hover:bg-gray-200 focus:bg-gray-200 bg-transparent"
45 type="button"
46 onMouseEnter={setExitButtonHovered}
47 onClick={openExitModal}>
48 <RightArrowIcon className="h-5 w-5" />
49 {__('Exit Launch', 'extendify')}
50 </button>
51 )}
52 <NextButton />
53 </div>
54 </div>
55 )
56 }
57
58 const NextButton = () => {
59 const { nextPage, currentPageIndex, pages } = usePagesStore()
60 const totalPages = usePagesStore((state) => state.count())
61 const canLaunch = useUserSelectionStore((state) => state.canLaunch())
62 const onLastPage = currentPageIndex === totalPages - 1
63 const currentPageKey = Array.from(pages.keys())[currentPageIndex]
64 const pageState = pages.get(currentPageKey).state()
65
66 if (canLaunch && onLastPage) {
67 return (
68 <button
69 className="px-4 py-3 font-bold bg-partner-primary-bg text-partner-primary-text button-focus"
70 onClick={() => {
71 useGlobalStore.setState({ generating: true })
72 }}
73 type="button">
74 {__('Launch site', 'extendify')}
75 </button>
76 )
77 }
78
79 return (
80 <button
81 className="flex items-center px-4 py-3 font-bold bg-partner-primary-bg text-partner-primary-text button-focus"
82 onClick={nextPage}
83 disabled={!pageState.ready}
84 type="button">
85 {__('Next', 'extendify')}
86 <LeftArrowIcon className="h-5 w-5" />
87 </button>
88 )
89 }
90