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

feat(frontend): Add warning to MessageBox component #3254

Merged
Merged
6 changes: 3 additions & 3 deletions src/frontend/src/eth/components/send/SendInfo.svelte
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script lang="ts">
import { getContext } from 'svelte';
import type { Erc20Token } from '$eth/types/erc20';
import Info from '$lib/components/ui/Info.svelte';
import Alert from '$lib/components/ui/Alert.svelte';
import { i18n } from '$lib/stores/i18n.store';
import { SEND_CONTEXT_KEY, type SendContext } from '$lib/stores/send.store';
import { replacePlaceholders } from '$lib/utils/i18n.utils';
Expand All @@ -16,7 +16,7 @@
</script>

{#if displayInfo}
<Info>
<Alert>
<span>
{#if sendPurpose === 'convert-eth-to-cketh'}
{$i18n.convert.text.cketh_conversions_may_take}
Expand All @@ -26,5 +26,5 @@
})}
{/if}
</span>
</Info>
</Alert>
{/if}
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
<script lang="ts">
import { Html } from '@dfinity/gix-components';
import Warning from '$lib/components/ui/Warning.svelte';
import Alert from '$lib/components/ui/Alert.svelte';
import { i18n } from '$lib/stores/i18n.store';
</script>

<Warning>
<Alert alertType="light-warning">
<span>
<Html text={$i18n.tokens.warning.trust_token} />
</span>
</Warning>
</Alert>

<style lang="scss">
span {
Expand Down
22 changes: 22 additions & 0 deletions src/frontend/src/lib/components/ui/Alert.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<script lang="ts">
import IconInfo from '$lib/components/icons/lucide/IconInfo.svelte';

export let alertType: 'info' | 'light-warning' = 'info';
Copy link
Member

Choose a reason for hiding this comment

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

light-warning? not just warning?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

light-warning, because we have a warning level according to design, that is different

Copy link
Member

Choose a reason for hiding this comment

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

Yeah but alertType is not about the style but about the intent no?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

maybe I shall rename the prop with componentStyle, where component is what better name we can find instead of Alert eheh

Any suggestion?

</script>

<div
class="mb-4 flex items-start gap-4 rounded-xl px-4 py-3 text-sm font-medium sm:text-base"
class:bg-onahau={alertType === 'info'}
class:bg-warning-orange={alertType === 'light-warning'}
>
<div
class="min-w-5 py-0 sm:py-0.5"
class:text-blue-ribbon={alertType === 'info'}
class:text-american-orange={alertType === 'light-warning'}
>
<IconInfo />
</div>
<div>
peterpeterparker marked this conversation as resolved.
Show resolved Hide resolved
<slot />
</div>
</div>
8 changes: 3 additions & 5 deletions src/frontend/src/lib/components/ui/InProgressWizard.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
import type { ProgressStep } from '@dfinity/gix-components';
import { nonNullish } from '@dfinity/utils';
import { onDestroy, onMount } from 'svelte';
import Alert from '$lib/components/ui/Alert.svelte';
import InProgress from '$lib/components/ui/InProgress.svelte';
import Warning from '$lib/components/ui/Warning.svelte';
import { ProgressStepsSend } from '$lib/enums/progress-steps';
import { i18n } from '$lib/stores/i18n.store';
import { modalStore } from '$lib/stores/modal.store';
Expand All @@ -28,11 +28,9 @@
</script>

<div class="stretch">
<Warning>
<span>{$i18n.core.warning.may_take_a_few_seconds}</span>
<br />
<Alert alertType="light-warning">
<span>{$i18n.core.warning.do_not_close}</span>
</Warning>
</Alert>

<InProgress {progressStep} {steps} />
</div>
12 changes: 0 additions & 12 deletions src/frontend/src/lib/components/ui/Info.svelte

This file was deleted.

12 changes: 0 additions & 12 deletions src/frontend/src/lib/components/ui/Warning.svelte

This file was deleted.

3 changes: 1 addition & 2 deletions src/frontend/src/lib/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@
"back": "Go back to the previous page"
},
"warning": {
"may_take_a_few_seconds": "This may take a few seconds.",
"do_not_close": "Please do not close your browser tab."
"do_not_close": "Don't close this tab until the transaction is done"
}
},
"navigation": {
Expand Down
2 changes: 1 addition & 1 deletion src/frontend/src/lib/types/i18n.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ interface I18nCore {
};
info: { test_banner: string };
alt: { logo: string; go_to_home: string; back: string };
warning: { may_take_a_few_seconds: string; do_not_close: string };
warning: { do_not_close: string };
}

interface I18nNavigation {
Expand Down