PluginProbe
Extendify / 0.9.3
Extendify v0.9.3
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 0.7.0 All 126 releases
extendify / src / Onboarding / components / PageControl.js

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

66 lines 2.5 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 onFirstPage = currentPageIndex === 0
11 const currentPageKey = Array.from(pages.keys())[currentPageIndex]
12
13 return (
14 <div className="flex items-center space-x-2">
15 <div
16 className={classNames('flex flex-1', {
17 'justify-end': currentPageKey === 'welcome',
18 'justify-between': currentPageKey !== 'welcome',
19 })}>
20 {onFirstPage || (
21 <button
22 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"
23 type="button"
24 onClick={previousPage}>
25 <RightArrowIcon className="h-5 w-5" />
26 {__('Back', 'extendify')}
27 </button>
28 )}
29 <NextButton />
30 </div>
31 </div>
32 )
33 }
34
35 const NextButton = () => {
36 const { nextPage, currentPageIndex, pages } = usePagesStore()
37 const totalPages = usePagesStore((state) => state.count())
38 const canLaunch = useUserSelectionStore((state) => state.canLaunch())
39 const onLastPage = currentPageIndex === totalPages - 1
40 const currentPageKey = Array.from(pages.keys())[currentPageIndex]
41 const pageState = pages.get(currentPageKey).state()
42
43 if (canLaunch && onLastPage) {
44 return (
45 <button
46 className="px-4 py-3 font-bold bg-partner-primary-bg text-partner-primary-text button-focus"
47 onClick={() => {
48 useGlobalStore.setState({ generating: true })
49 }}
50 type="button">
51 {__('Launch site', 'extendify')}
52 </button>
53 )
54 }
55 return (
56 <button
57 className="flex items-center px-4 py-3 font-bold bg-partner-primary-bg text-partner-primary-text button-focus"
58 onClick={nextPage}
59 disabled={!pageState.ready}
60 type="button">
61 {__('Next', 'extendify')}
62 <LeftArrowIcon className="h-5 w-5" />
63 </button>
64 )
65 }
66