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">
|
||||
import Link, { parseURL } from '$lib/components/input/Link.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 PostLinkSources from './PostLinkSources.svelte'
|
||||
import { t } from '$lib/translations'
|
||||
@@ -14,6 +19,8 @@
|
||||
export let embed_description: string | undefined = undefined
|
||||
export let view: View = 'cozy'
|
||||
|
||||
let openMediaBias = false
|
||||
|
||||
$: richURL = parseURL(url)
|
||||
</script>
|
||||
|
||||
@@ -93,7 +100,7 @@
|
||||
border-slate-200 dark:border-zinc-800
|
||||
flex flex-row items-center overflow-auto"
|
||||
>
|
||||
<PostLinkSources {url}>
|
||||
<PostLinkSources {url} {view} bind:openMediaBias>
|
||||
<Button
|
||||
color="tertiary"
|
||||
slot="target"
|
||||
@@ -105,10 +112,20 @@
|
||||
{$t('post.actions.link.actions')}
|
||||
</Button>
|
||||
</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>
|
||||
{:else}
|
||||
<div class="flex items-center gap-1">
|
||||
<PostLinkSources {url}>
|
||||
<PostLinkSources {url} {view}>
|
||||
<Button
|
||||
color="ghost"
|
||||
slot="target"
|
||||
|
||||
@@ -36,19 +36,21 @@
|
||||
import { Menu, MenuButton, MenuDivider } from 'mono-svelte'
|
||||
import type { MediaType } from '../helpers'
|
||||
import { CheckBadge, Icon } from 'svelte-hero-icons'
|
||||
import type { View } from '$lib/settings'
|
||||
|
||||
export let url: string
|
||||
export let type: MediaType = 'embed'
|
||||
export let view: View = 'cozy'
|
||||
|
||||
let mediaBias = false
|
||||
export let openMediaBias = false
|
||||
|
||||
const stripSubdomain = (url: string) =>
|
||||
new URL(url).hostname.split('.').slice(-2).join('.')
|
||||
</script>
|
||||
|
||||
{#if mediaBias}
|
||||
{#if openMediaBias}
|
||||
{#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}
|
||||
{/if}
|
||||
|
||||
@@ -63,9 +65,11 @@
|
||||
</MenuButton>
|
||||
{/if}
|
||||
{/each}
|
||||
<MenuDivider>{$t('post.actions.link.actions')}</MenuDivider>
|
||||
<MenuButton on:click={() => (mediaBias = !mediaBias)}>
|
||||
<Icon src={CheckBadge} size="16" micro slot="prefix" />
|
||||
{$t('post.actions.more.mediaBias')}
|
||||
</MenuButton>
|
||||
{#if view == 'compact'}
|
||||
<MenuDivider>{$t('post.actions.link.actions')}</MenuDivider>
|
||||
<MenuButton on:click={() => (openMediaBias = !openMediaBias)}>
|
||||
<Icon src={CheckBadge} size="16" micro slot="prefix" />
|
||||
{$t('post.actions.more.mediaBias')}
|
||||
</MenuButton>
|
||||
{/if}
|
||||
</Menu>
|
||||
Reference in new issue
Block a user