PluginProbe
Extendify / 0.10.1
Extendify v0.10.1
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.1, at src/Onboarding/components/PageControl.js

99 lines 3.9 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 { updateOption } from '@onboarding/api/WPApi'
4 import { useGlobalStore } from '@onboarding/state/Global'
5 import { usePagesStore } from '@onboarding/state/Pages'
6 import { useUserSelectionStore } from '@onboarding/state/UserSelections'
7 import { LeftArrowIcon, RightArrowIcon } from '@onboarding/svg'
8
9 export const PageControl = () => {
10 const { previousPage, currentPageIndex, pages } = usePagesStore()
11 const onFirstPage = currentPageIndex === 0
12 const currentPageKey = Array.from(pages.keys())[currentPageIndex]
13 const exitLaunch = async (e) => {
14 e.preventDefault()
15
16 // Store when Launch is skipped.
17 await updateOption(
18 'extendify_onboarding_skipped',
19 new Date().toISOString(),
20 )
21
22 location.href = window.extOnbData.adminUrl
23 }
24
25 return (
26 <div className="flex items-center space-x-2">
27 {onFirstPage && (
28 <div className="fixed top-0 right-0 px-3 md:px-6 py-2">
29 <button
30 className="flex items-center p-1 text-partner-primary-bg font-medium button-focus md:focus:bg-transparent bg-transparent shadow-none"
31 type="button"
32 title={__('Exit Launch', 'extendify')}
33 onClick={exitLaunch}>
34 <span className="dashicons dashicons-no-alt text-white md:text-black"></span>
35 </button>
36 </div>
37 )}
38 <div
39 className={classNames('flex flex-1', {
40 'justify-end': currentPageKey === 'welcome',
41 'justify-between': currentPageKey !== 'welcome',
42 })}>
43 {onFirstPage || (
44 <button
45 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"
46 type="button"
47 onClick={previousPage}>
48 <RightArrowIcon className="h-5 w-5" />
49 {__('Back', 'extendify')}
50 </button>
51 )}
52 {onFirstPage && (
53 <button
54 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"
55 type="button"
56 onClick={exitLaunch}>
57 <RightArrowIcon className="h-5 w-5" />
58 {__('Exit Launch', 'extendify')}
59 </button>
60 )}
61 <NextButton />
62 </div>
63 </div>
64 )
65 }
66
67 const NextButton = () => {
68 const { nextPage, currentPageIndex, pages } = usePagesStore()
69 const totalPages = usePagesStore((state) => state.count())
70 const canLaunch = useUserSelectionStore((state) => state.canLaunch())
71 const onLastPage = currentPageIndex === totalPages - 1
72 const currentPageKey = Array.from(pages.keys())[currentPageIndex]
73 const pageState = pages.get(currentPageKey).state()
74
75 if (canLaunch && onLastPage) {
76 return (
77 <button
78 className="px-4 py-3 font-bold bg-partner-primary-bg text-partner-primary-text button-focus"
79 onClick={() => {
80 useGlobalStore.setState({ generating: true })
81 }}
82 type="button">
83 {__('Launch site', 'extendify')}
84 </button>
85 )
86 }
87
88 return (
89 <button
90 className="flex items-center px-4 py-3 font-bold bg-partner-primary-bg text-partner-primary-text button-focus"
91 onClick={nextPage}
92 disabled={!pageState.ready}
93 type="button">
94 {__('Next', 'extendify')}
95 <LeftArrowIcon className="h-5 w-5" />
96 </button>
97 )
98 }
99