misc: add media bias button to embed card
This commit is contained in:
1 parent
e30a9a2ea0
commit
8216901429
2 files changed
+32
-11
No files matched your search
@@ -1,7 +1,12 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import Link, { parseURL } from '$lib/components/input/Link.svelte'
|
import Link, { parseURL } from '$lib/components/input/Link.svelte'
|
||||||
import { Button, Material } from 'mono-svelte'
|
import { Button, Material } from 'mono-svelte'
|
||||||
import { ChevronDown, Icon, Link as LinkIcon } from 'svelte-hero-icons'
|
import {
|
||||||
|
CheckBadge,
|
||||||
|
ChevronDown,
|
||||||
|
Icon,
|
||||||
|
Link as LinkIcon,
|
||||||
|
} from 'svelte-hero-icons'
|
||||||
import { optimizeImageURL } from '../helpers'
|
import { optimizeImageURL } from '../helpers'
|
||||||
import PostLinkSources from './PostLinkSources.svelte'
|
import PostLinkSources from './PostLinkSources.svelte'
|
||||||
import { t } from '$lib/translations'
|
import { t } from '$lib/translations'
|
||||||
@@ -14,6 +19,8 @@
|
|||||||
export let embed_description: string | undefined = undefined
|
export let embed_description: string | undefined = undefined
|
||||||
export let view: View = 'cozy'
|
export let view: View = 'cozy'
|
||||||
|
|
||||||
|
let openMediaBias = false
|
||||||
|
|
||||||
$: richURL = parseURL(url)
|
$: richURL = parseURL(url)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@@ -93,7 +100,7 @@
|
|||||||
border-slate-200 dark:border-zinc-800
|
border-slate-200 dark:border-zinc-800
|
||||||
flex flex-row items-center overflow-auto"
|
flex flex-row items-center overflow-auto"
|
||||||
>
|
>
|
||||||
<PostLinkSources {url}>
|
<PostLinkSources {url} {view} bind:openMediaBias>
|
||||||
<Button
|
<Button
|
||||||
color="tertiary"
|
color="tertiary"
|
||||||
slot="target"
|
slot="target"
|
||||||
@@ -105,10 +112,20 @@
|
|||||||
{$t('post.actions.link.actions')}
|
{$t('post.actions.link.actions')}
|
||||||
</Button>
|
</Button>
|
||||||
</PostLinkSources>
|
</PostLinkSources>
|
||||||
|
<Button
|
||||||
|
color="tertiary"
|
||||||
|
size="sm"
|
||||||
|
class="w-max text-slate-600 dark:text-zinc-400 block
|
||||||
|
text-xs"
|
||||||
|
on:click={() => (openMediaBias = !openMediaBias)}
|
||||||
|
>
|
||||||
|
<Icon src={CheckBadge} size="16" micro slot="prefix" />
|
||||||
|
{$t('post.actions.more.mediaBias')}
|
||||||
|
</Button>
|
||||||
</Material>
|
</Material>
|
||||||
{:else}
|
{:else}
|
||||||
<div class="flex items-center gap-1">
|
<div class="flex items-center gap-1">
|
||||||
<PostLinkSources {url}>
|
<PostLinkSources {url} {view}>
|
||||||
<Button
|
<Button
|
||||||
color="ghost"
|
color="ghost"
|
||||||
slot="target"
|
slot="target"
|
||||||
|
|||||||
@@ -36,19 +36,21 @@
|
|||||||
import { Menu, MenuButton, MenuDivider } from 'mono-svelte'
|
import { Menu, MenuButton, MenuDivider } from 'mono-svelte'
|
||||||
import type { MediaType } from '../helpers'
|
import type { MediaType } from '../helpers'
|
||||||
import { CheckBadge, Icon } from 'svelte-hero-icons'
|
import { CheckBadge, Icon } from 'svelte-hero-icons'
|
||||||
|
import type { View } from '$lib/settings'
|
||||||
|
|
||||||
export let url: string
|
export let url: string
|
||||||
export let type: MediaType = 'embed'
|
export let type: MediaType = 'embed'
|
||||||
|
export let view: View = 'cozy'
|
||||||
|
|
||||||
let mediaBias = false
|
export let openMediaBias = false
|
||||||
|
|
||||||
const stripSubdomain = (url: string) =>
|
const stripSubdomain = (url: string) =>
|
||||||
new URL(url).hostname.split('.').slice(-2).join('.')
|
new URL(url).hostname.split('.').slice(-2).join('.')
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if mediaBias}
|
{#if openMediaBias}
|
||||||
{#await import('$lib/components/mbfc/MBFCModal.svelte') then { default: MbfcModal }}
|
{#await import('$lib/components/mbfc/MBFCModal.svelte') then { default: MbfcModal }}
|
||||||
<MbfcModal domain={stripSubdomain(url)} bind:open={mediaBias} />
|
<MbfcModal domain={stripSubdomain(url)} bind:open={openMediaBias} />
|
||||||
{/await}
|
{/await}
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
@@ -63,9 +65,11 @@
|
|||||||
</MenuButton>
|
</MenuButton>
|
||||||
{/if}
|
{/if}
|
||||||
{/each}
|
{/each}
|
||||||
<MenuDivider>{$t('post.actions.link.actions')}</MenuDivider>
|
{#if view == 'compact'}
|
||||||
<MenuButton on:click={() => (mediaBias = !mediaBias)}>
|
<MenuDivider>{$t('post.actions.link.actions')}</MenuDivider>
|
||||||
<Icon src={CheckBadge} size="16" micro slot="prefix" />
|
<MenuButton on:click={() => (openMediaBias = !openMediaBias)}>
|
||||||
{$t('post.actions.more.mediaBias')}
|
<Icon src={CheckBadge} size="16" micro slot="prefix" />
|
||||||
</MenuButton>
|
{$t('post.actions.more.mediaBias')}
|
||||||
|
</MenuButton>
|
||||||
|
{/if}
|
||||||
</Menu>
|
</Menu>
|
||||||
Reference in new issue
Block a user