Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(frontend): Extract Button that represents Done action #2765

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/frontend/src/eth/components/tokens/TokenModal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import { explorerUrl as explorerUrlStore } from '$eth/derived/network.derived';
import type { OptionErc20Token } from '$eth/types/erc20';
import Token from '$lib/components/tokens/Token.svelte';
import Button from '$lib/components/ui/Button.svelte';
import ButtonDone from '$lib/components/ui/ButtonDone.svelte';
import ContentWithToolbar from '$lib/components/ui/ContentWithToolbar.svelte';
import Copy from '$lib/components/ui/Copy.svelte';
import ExternalLink from '$lib/components/ui/ExternalLink.svelte';
Expand Down Expand Up @@ -44,6 +44,6 @@
</Token>
{/if}

<Button fullWidth on:click={modalStore.close} slot="toolbar">{$i18n.core.text.done}</Button>
<ButtonDone on:click={modalStore.close} slot="toolbar" />
</ContentWithToolbar>
</Modal>
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import { SEND_CONTEXT_KEY, type SendContext } from '$icp-eth/stores/send.store';
import ReceiveAddress from '$lib/components/receive/ReceiveAddress.svelte';
import Button from '$lib/components/ui/Button.svelte';
import ButtonDone from '$lib/components/ui/ButtonDone.svelte';
import ContentWithToolbar from '$lib/components/ui/ContentWithToolbar.svelte';
import Value from '$lib/components/ui/Value.svelte';
import { ZERO } from '$lib/constants/app.constants';
Expand Down Expand Up @@ -149,7 +150,7 @@
>{$i18n.core.text.back}</Button
>
{:else}
<Button fullWidth type="button" on:click={modalStore.close}>{$i18n.core.text.done}</Button>
<ButtonDone type="button" on:click={modalStore.close} />
{/if}
</div>
</ContentWithToolbar>
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
type ReceiveTokenContext
} from '$icp/stores/receive-token.store';
import ReceiveAddress from '$lib/components/receive/ReceiveAddress.svelte';
import Button from '$lib/components/ui/Button.svelte';
import ButtonDone from '$lib/components/ui/ButtonDone.svelte';
import ContentWithToolbar from '$lib/components/ui/ContentWithToolbar.svelte';
import Hr from '$lib/components/ui/Hr.svelte';
import { i18n } from '$lib/stores/i18n.store';
Expand Down Expand Up @@ -66,5 +66,5 @@
</ReceiveAddress>
{/if}

<Button fullWidth on:click={close} slot="toolbar">{$i18n.core.text.done}</Button>
<ButtonDone on:click={close} slot="toolbar" />
</ContentWithToolbar>
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
RECEIVE_TOKEN_CONTEXT_KEY,
type ReceiveTokenContext
} from '$icp/stores/receive-token.store';
import Button from '$lib/components/ui/Button.svelte';
import ButtonDone from '$lib/components/ui/ButtonDone.svelte';
import ContentWithToolbar from '$lib/components/ui/ContentWithToolbar.svelte';
import Hr from '$lib/components/ui/Hr.svelte';
import Value from '$lib/components/ui/Value.svelte';
Expand Down Expand Up @@ -57,4 +57,4 @@
</button>
</ContentWithToolbar>

<Button fullWidth on:click={close}>{$i18n.core.text.done}</Button>
<ButtonDone on:click={close} />
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
type ReceiveTokenContext
} from '$icp/stores/receive-token.store';
import ReceiveAddress from '$lib/components/receive/ReceiveAddress.svelte';
import Button from '$lib/components/ui/Button.svelte';
import ButtonDone from '$lib/components/ui/ButtonDone.svelte';
import ContentWithToolbar from '$lib/components/ui/ContentWithToolbar.svelte';
import Hr from '$lib/components/ui/Hr.svelte';
import { i18n } from '$lib/stores/i18n.store';
Expand Down Expand Up @@ -54,7 +54,5 @@
<svelte:fragment slot="text">{$i18n.receive.icp.text.use_for_icp_deposit}</svelte:fragment>
</ReceiveAddress>

<Button fullWidth on:click={close} slot="toolbar">
{$i18n.core.text.done}
</Button>
<ButtonDone on:click={close} slot="toolbar" />
</ContentWithToolbar>
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,14 @@
RECEIVE_TOKEN_CONTEXT_KEY,
type ReceiveTokenContext
} from '$icp/stores/receive-token.store';
import Button from '$lib/components/ui/Button.svelte';
import ButtonDone from '$lib/components/ui/ButtonDone.svelte';
import ContentWithToolbar from '$lib/components/ui/ContentWithToolbar.svelte';
import { i18n } from '$lib/stores/i18n.store';
const { close } = getContext<ReceiveTokenContext>(RECEIVE_TOKEN_CONTEXT_KEY);
</script>

<ContentWithToolbar>
<IcReceiveWalletAddress on:icQRCode />

<Button fullWidth on:click={close} slot="toolbar">{$i18n.core.text.done}</Button>
<ButtonDone on:click={close} slot="toolbar" />
</ContentWithToolbar>
4 changes: 2 additions & 2 deletions src/frontend/src/icp/components/tokens/IcTokenModal.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { nonNullish } from '@dfinity/utils';
import type { OptionIcCkToken } from '$icp/types/ic';
import Token from '$lib/components/tokens/Token.svelte';
import Button from '$lib/components/ui/Button.svelte';
import ButtonDone from '$lib/components/ui/ButtonDone.svelte';
import ContentWithToolbar from '$lib/components/ui/ContentWithToolbar.svelte';
import Copy from '$lib/components/ui/Copy.svelte';
import Logo from '$lib/components/ui/Logo.svelte';
Expand Down Expand Up @@ -84,6 +84,6 @@
</Token>
{/if}

<Button fullWidth on:click={modalStore.close} slot="toolbar">{$i18n.core.text.done}</Button>
<ButtonDone on:click={modalStore.close} slot="toolbar" />
</ContentWithToolbar>
</Modal>
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import { ETHEREUM_TOKEN, ICP_TOKEN } from '$env/tokens.env';
import { icpAccountIdentifierText, icrcAccountIdentifierText } from '$icp/derived/ic.derived';
import ReceiveAddressWithLogo from '$lib/components/receive/ReceiveAddressWithLogo.svelte';
import Button from '$lib/components/ui/Button.svelte';
import ButtonDone from '$lib/components/ui/ButtonDone.svelte';
import ContentWithToolbar from '$lib/components/ui/ContentWithToolbar.svelte';
import Hr from '$lib/components/ui/Hr.svelte';
import { LOCAL } from '$lib/constants/app.constants';
Expand Down Expand Up @@ -144,5 +144,5 @@
{$i18n.receive.ethereum.text.ethereum}
</ReceiveAddressWithLogo>

<Button fullWidth on:click={modalStore.close} slot="toolbar">{$i18n.core.text.done}</Button>
<ButtonDone on:click={modalStore.close} slot="toolbar" />
</ContentWithToolbar>
4 changes: 2 additions & 2 deletions src/frontend/src/lib/components/receive/ReceiveModal.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="ts">
import { Modal } from '@dfinity/gix-components';
import ReceiveQRCode from '$lib/components/receive/ReceiveQRCode.svelte';
import Button from '$lib/components/ui/Button.svelte';
import ButtonDone from '$lib/components/ui/ButtonDone.svelte';
import ContentWithToolbar from '$lib/components/ui/ContentWithToolbar.svelte';
import Copy from '$lib/components/ui/Copy.svelte';
import { i18n } from '$lib/stores/i18n.store';
Expand All @@ -28,6 +28,6 @@

<slot name="content" />

<Button fullWidth on:click={modalStore.close} slot="toolbar">{$i18n.core.text.done}</Button>
<ButtonDone on:click={modalStore.close} slot="toolbar" />
</ContentWithToolbar>
</Modal>
10 changes: 10 additions & 0 deletions src/frontend/src/lib/components/ui/ButtonDone.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<script lang="ts">
import Button from '$lib/components/ui/Button.svelte';
import { i18n } from '$lib/stores/i18n.store';
export let type: 'submit' | 'reset' | 'button' = 'submit';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it really ever used to submit a form? If not, should we also set it as button for all use case?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't want to change the logic to be honest, just in case it is needed as submit somewhere.

But it make sense that "Done" does not submit a form.

I double checked and it is really never used in a form, you are right! Changed

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense. THx

</script>

<Button {type} fullWidth on:click>
{$i18n.core.text.done}
</Button>