Skip to content

Commit

Permalink
Move button
Browse files Browse the repository at this point in the history
  • Loading branch information
mbidenaio committed Apr 1, 2024
1 parent 2d19b2c commit b95454f
Show file tree
Hide file tree
Showing 2 changed files with 88 additions and 67 deletions.
77 changes: 44 additions & 33 deletions renderer/pages/flips/edit.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import React, {useEffect, useState} from 'react'
import {useRouter} from 'next/router'
import {Box, Flex, useToast, Divider, useDisclosure} from '@chakra-ui/react'
import {
Box,
Flex,
useToast,
Divider,
useDisclosure,
Stack,

Check warning on line 9 in renderer/pages/flips/edit.js

View workflow job for this annotation

GitHub Actions / build

'Stack' is defined but never used. Allowed unused vars must match /^_/u

Check warning on line 9 in renderer/pages/flips/edit.js

View workflow job for this annotation

GitHub Actions / build

'Stack' is defined but never used. Allowed unused vars must match /^_/u
} from '@chakra-ui/react'
import {useTranslation} from 'react-i18next'
import {useMachine} from '@xstate/react'
import {
Expand Down Expand Up @@ -402,36 +409,9 @@ export default function EditFlipPage() {
</FlipMaster>
)}
</Flex>
<FlipMasterFooter>
{not('keywords') && (
<SecondaryButton
isDisabled={
is('images.painting') ||
is('protect.protecting') ||
is('protect.shuffling') ||
is('protect.preparing')
}
onClick={() => send('PREV')}
>
{t('Previous step')}
</SecondaryButton>
)}
{not('submit') && (
<PrimaryButton
isDisabled={
is('images.painting') ||
is('protect.protecting') ||
is('protect.shuffling') ||
is('protect.preparing') ||
is('keywords.loading')
}
onClick={() => send('NEXT')}
>
{t('Next step')}
</PrimaryButton>
)}
{is('submit') && (
<>
<FlipMasterFooter justify="space-between">
<Flex isInline spacing={2} ml={16}>
{is('submit') && (
<SecondaryButton
onClick={async () =>
(await writeTextToClipboard(
Expand All @@ -451,6 +431,37 @@ export default function EditFlipPage() {
>
{t('Copy to clipboard')}
</SecondaryButton>
)}
</Flex>
<Flex isInline spacing={2}>
{not('keywords') && (
<SecondaryButton
isDisabled={
is('images.painting') ||
is('protect.protecting') ||
is('protect.shuffling') ||
is('protect.preparing')
}
onClick={() => send('PREV')}
>
{t('Previous step')}
</SecondaryButton>
)}
{not('submit') && (
<PrimaryButton
isDisabled={
is('images.painting') ||
is('protect.protecting') ||
is('protect.shuffling') ||
is('protect.preparing') ||
is('keywords.loading')
}
onClick={() => send('NEXT')}
>
{t('Next step')}
</PrimaryButton>
)}
{is('submit') && (
<PrimaryButton
isDisabled={is('submit.submitting')}
isLoading={is('submit.submitting')}
Expand All @@ -469,8 +480,8 @@ export default function EditFlipPage() {
>
{t('Submit')}
</PrimaryButton>
</>
)}
)}
</Flex>
</FlipMasterFooter>

<BadFlipDialog
Expand Down
78 changes: 44 additions & 34 deletions renderer/pages/flips/new.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import React, {useEffect, useState} from 'react'
import {useRouter} from 'next/router'
import {Box, Flex, useToast, Divider, useDisclosure} from '@chakra-ui/react'
import {
Box,
Flex,
useToast,
Divider,
useDisclosure,
Stack,
} from '@chakra-ui/react'
import {useTranslation} from 'react-i18next'
import {useMachine} from '@xstate/react'
import {
Expand Down Expand Up @@ -36,7 +43,6 @@ import {
protectFlip,
prepareAdversarialImages,
shuffleAdversarial,
shufflePics,
} from '../../screens/flips/utils'
import {Step} from '../../screens/flips/types'
import {
Expand Down Expand Up @@ -415,36 +421,9 @@ export default function NewFlipPage() {
</FlipMaster>
)}
</Flex>
<FlipMasterFooter>
{not('keywords') && (
<SecondaryButton
isDisabled={
is('images.painting') ||
is('protect.protecting') ||
is('protect.shuffling') ||
is('protect.preparing')
}
onClick={() => send('PREV')}
>
{t('Previous step')}
</SecondaryButton>
)}
{not('submit') && (
<PrimaryButton
isDisabled={
is('images.painting') ||
is('protect.protecting') ||
is('protect.shuffling') ||
is('protect.preparing') ||
is('keywords.loading')
}
onClick={() => send('NEXT')}
>
{t('Next step')}
</PrimaryButton>
)}
{is('submit') && (
<>
<FlipMasterFooter justify="space-between">
<Stack isInline spacing={2} ml={16}>
{is('submit') && (
<SecondaryButton
onClick={async () =>
(await writeTextToClipboard(
Expand All @@ -464,6 +443,37 @@ export default function NewFlipPage() {
>
{t('Copy to clipboard')}
</SecondaryButton>
)}
</Stack>
<Stack isInline spacing={2}>
{not('keywords') && (
<SecondaryButton
isDisabled={
is('images.painting') ||
is('protect.protecting') ||
is('protect.shuffling') ||
is('protect.preparing')
}
onClick={() => send('PREV')}
>
{t('Previous step')}
</SecondaryButton>
)}
{not('submit') && (
<PrimaryButton
isDisabled={
is('images.painting') ||
is('protect.protecting') ||
is('protect.shuffling') ||
is('protect.preparing') ||
is('keywords.loading')
}
onClick={() => send('NEXT')}
>
{t('Next step')}
</PrimaryButton>
)}
{is('submit') && (
<PrimaryButton
isDisabled={is('submit.submitting')}
isLoading={is('submit.submitting')}
Expand All @@ -482,8 +492,8 @@ export default function NewFlipPage() {
>
{t('Submit')}
</PrimaryButton>
</>
)}
)}
</Stack>
</FlipMasterFooter>

<BadFlipDialog
Expand Down

0 comments on commit b95454f

Please sign in to comment.