From 5f372111694df7be8ef65789629d93d7c94f96df Mon Sep 17 00:00:00 2001 From: Robin Munn Date: Tue, 3 Dec 2024 11:19:13 +0700 Subject: [PATCH] Add component to encapsulate new-tab Markdown logic This allows us to do the renderer plugin typecast just once rather than everywhere the Markdown component is used. --- .../lib/components/Markdown/NewTabLinkMarkdown.svelte | 10 ++++++++++ frontend/src/lib/components/Markdown/index.ts | 1 + .../Projects/ProjectConfidentialityCombobox.svelte | 6 ++---- .../src/lib/components/Users/CreateUserModal.svelte | 10 +++------- frontend/src/lib/forms/Checkbox.svelte | 6 ++---- frontend/src/lib/forms/FormError.svelte | 6 ++---- frontend/src/lib/forms/FormField.svelte | 6 ++---- frontend/src/lib/forms/RadioButtonGroup.svelte | 6 ++---- .../project/[project_code]/OpenInFlexModal.svelte | 5 ++--- .../routes/(authenticated)/project/create/+page.svelte | 7 +++---- 10 files changed, 29 insertions(+), 34 deletions(-) create mode 100644 frontend/src/lib/components/Markdown/NewTabLinkMarkdown.svelte diff --git a/frontend/src/lib/components/Markdown/NewTabLinkMarkdown.svelte b/frontend/src/lib/components/Markdown/NewTabLinkMarkdown.svelte new file mode 100644 index 000000000..a8167cc33 --- /dev/null +++ b/frontend/src/lib/components/Markdown/NewTabLinkMarkdown.svelte @@ -0,0 +1,10 @@ + + + diff --git a/frontend/src/lib/components/Markdown/index.ts b/frontend/src/lib/components/Markdown/index.ts index 717ae5c56..9ece5f0ad 100644 --- a/frontend/src/lib/components/Markdown/index.ts +++ b/frontend/src/lib/components/Markdown/index.ts @@ -1 +1,2 @@ export { default as NewTabLinkRenderer } from './NewTabLinkRenderer.svelte'; +export { default as NewTabLinkMarkdown } from './NewTabLinkMarkdown.svelte'; diff --git a/frontend/src/lib/components/Projects/ProjectConfidentialityCombobox.svelte b/frontend/src/lib/components/Projects/ProjectConfidentialityCombobox.svelte index f1c3ffe5e..c76512e79 100644 --- a/frontend/src/lib/components/Projects/ProjectConfidentialityCombobox.svelte +++ b/frontend/src/lib/components/Projects/ProjectConfidentialityCombobox.svelte @@ -3,9 +3,7 @@ import Checkbox from '../../forms/Checkbox.svelte'; import { slide } from 'svelte/transition'; import { Icon } from '$lib/icons'; - import Markdown from 'svelte-exmarkdown'; - import { NewTabLinkRenderer } from '$lib/components/Markdown'; - import type {Component} from 'svelte'; + import {NewTabLinkMarkdown} from '$lib/components/Markdown'; export let value: boolean; @@ -22,6 +20,6 @@ {#if value}
- } }]} /> +
{/if} diff --git a/frontend/src/lib/components/Users/CreateUserModal.svelte b/frontend/src/lib/components/Users/CreateUserModal.svelte index 95c82c9cb..df5940bde 100644 --- a/frontend/src/lib/components/Users/CreateUserModal.svelte +++ b/frontend/src/lib/components/Users/CreateUserModal.svelte @@ -4,9 +4,7 @@ import { helpLinks } from '$lib/components/help'; import { type LexAuthUser, type RegisterResponse } from '$lib/user'; import CreateUser from '$lib/components/Users/CreateUser.svelte'; - import Markdown from 'svelte-exmarkdown'; - import { NewTabLinkRenderer } from '$lib/components/Markdown'; - import type {Component} from 'svelte'; + import {NewTabLinkMarkdown} from '$lib/components/Markdown'; import Icon from '$lib/icons/Icon.svelte'; import { createEventDispatcher } from 'svelte'; @@ -30,13 +28,11 @@

{$t('common.did_you_know')}

- } }]} /> - } }]} />
diff --git a/frontend/src/lib/forms/Checkbox.svelte b/frontend/src/lib/forms/Checkbox.svelte index 76a15f01b..507cb4f40 100644 --- a/frontend/src/lib/forms/Checkbox.svelte +++ b/frontend/src/lib/forms/Checkbox.svelte @@ -1,9 +1,7 @@