|
| 1 | +<!-- |
| 2 | + (c) 2023, Center for Computational Thinking and Design at Aarhus University and contributors |
| 3 | + |
| 4 | + SPDX-License-Identifier: MIT |
| 5 | + --> |
| 6 | + |
| 7 | +<script lang="ts"> |
| 8 | + import { t } from '../i18n'; |
| 9 | + import DialogHeading from './DialogHeading.svelte'; |
| 10 | + import HtmlFormattedMessage, { linkWithProps } from './HtmlFormattedMessage.svelte'; |
| 11 | + import StandardButton from './StandardButton.svelte'; |
| 12 | +
|
| 13 | + export let onClose: () => void; |
| 14 | + export let onStartBluetoothClick: () => void; |
| 15 | +
|
| 16 | + const linkWithPropsForMicrobitVersionSupport = linkWithProps({ |
| 17 | + href: 'https://support.microbit.org/support/solutions/articles/19000119162', |
| 18 | + target: '_blank', |
| 19 | + rel: 'noopener', |
| 20 | + }); |
| 21 | + const linkToBluetoothFlowId = 'link-to-bluetooth'; |
| 22 | + const linkToBluetoothFlow = linkWithProps( |
| 23 | + { |
| 24 | + id: linkToBluetoothFlowId, |
| 25 | + }, |
| 26 | + { tag: 'button' }, |
| 27 | + ); |
| 28 | + // The elements in translated strings don't support Svelte event handlers |
| 29 | + // so we wire it up ourselves. |
| 30 | + const wireLinkToBluetoothFlow = (node: Element) => { |
| 31 | + const link = node.querySelector('#' + linkToBluetoothFlowId); |
| 32 | + link?.addEventListener('click', onStartBluetoothClick); |
| 33 | + return { |
| 34 | + destroy() { |
| 35 | + link?.removeEventListener('click', onStartBluetoothClick); |
| 36 | + }, |
| 37 | + }; |
| 38 | + }; |
| 39 | +</script> |
| 40 | + |
| 41 | +<div class="w-175"> |
| 42 | + <DialogHeading>{$t('connectMB.unsupportedMicrobit.header')}</DialogHeading> |
| 43 | + <div class="space-y-5"> |
| 44 | + <div class="space-y-2"> |
| 45 | + <p> |
| 46 | + <HtmlFormattedMessage |
| 47 | + id={$t('connectMB.unsupportedMicrobit.explain')} |
| 48 | + options={{ |
| 49 | + values: { |
| 50 | + link: linkWithPropsForMicrobitVersionSupport, |
| 51 | + }, |
| 52 | + }} /> |
| 53 | + </p> |
| 54 | + <!-- svelte-ignore a11y-no-noninteractive-element-interactions --> |
| 55 | + <p use:wireLinkToBluetoothFlow> |
| 56 | + <HtmlFormattedMessage |
| 57 | + id={$t('connectMB.unsupportedMicrobit.advice')} |
| 58 | + options={{ |
| 59 | + values: { |
| 60 | + link1: linkToBluetoothFlow, |
| 61 | + link2: linkWithPropsForMicrobitVersionSupport, |
| 62 | + }, |
| 63 | + }} /> |
| 64 | + </p> |
| 65 | + </div> |
| 66 | + <div class="flex justify-end"> |
| 67 | + <StandardButton onClick={onClose} type="primary" |
| 68 | + >{$t('actions.close')}</StandardButton> |
| 69 | + </div> |
| 70 | + </div> |
| 71 | +</div> |
0 commit comments