@r2digisolutions/components 0.22.2 → 0.23.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/atoms/Avatar/Avatar.stories.d.ts +1 -1
- package/dist/components/atoms/Avatar/Avatar.stories.js +1 -1
- package/dist/components/atoms/Avatar/Avatar.svelte +5 -3
- package/dist/components/atoms/Avatar/Avatar.svelte.d.ts +1 -1
- package/dist/components/atoms/Avatar/AvatarStory.svelte +1 -1
- package/dist/components/atoms/Avatar/AvatarStory.svelte.d.ts +1 -1
- package/dist/components/atoms/Container/Container.stories.d.ts +1 -1
- package/dist/components/atoms/Container/ContainerStory.svelte.d.ts +1 -1
- package/dist/components/atoms/Input/Input.svelte +5 -4
- package/dist/components/molecules/AdSlot/AdSlot.stories.js +10 -0
- package/dist/components/molecules/AdSlot/AdSlot.svelte +16 -0
- package/dist/components/molecules/AdSlot/AdSlot.svelte.d.ts +8 -0
- package/dist/components/molecules/AdSlot/AdSlotStory.svelte +23 -0
- package/dist/components/molecules/AdSlot/AdSlotStory.svelte.d.ts +18 -0
- package/dist/components/molecules/AdUnit/AdUnit.stories.js +28 -0
- package/dist/components/molecules/AdUnit/AdUnit.svelte +151 -0
- package/dist/components/molecules/AdUnit/AdUnit.svelte.d.ts +15 -0
- package/dist/components/molecules/AdUnit/AdUnitStory.svelte +36 -0
- package/dist/components/molecules/AdUnit/AdUnitStory.svelte.d.ts +7 -0
- package/dist/components/molecules/AvatarGroup/AvatarGroup.svelte +1 -1
- package/dist/components/molecules/AvatarGroup/AvatarGroup.svelte.d.ts +1 -1
- package/dist/components/molecules/AvatarLabel/AvatarLabel.svelte +1 -1
- package/dist/components/molecules/AvatarLabel/AvatarLabel.svelte.d.ts +1 -1
- package/dist/components/molecules/Card/Card.svelte +6 -15
- package/dist/components/molecules/ChipBar/ChipBar.svelte +18 -5
- package/dist/components/molecules/ChipBar/ChipBar.svelte.d.ts +1 -1
- package/dist/components/molecules/FeatureList/FeatureList.svelte +26 -7
- package/dist/components/molecules/FeatureList/FeatureList.svelte.d.ts +2 -0
- package/dist/components/molecules/KnowledgeCard/KnowledgeCard.stories.js +25 -0
- package/dist/components/molecules/KnowledgeCard/KnowledgeCard.svelte +95 -0
- package/dist/components/molecules/KnowledgeCard/KnowledgeCard.svelte.d.ts +15 -0
- package/dist/components/molecules/KnowledgeCard/KnowledgeCardStory.svelte +56 -0
- package/dist/components/molecules/KnowledgeCard/KnowledgeCardStory.svelte.d.ts +6 -0
- package/dist/components/molecules/LocaleSwitcher/LocaleSwitcher.svelte +5 -5
- package/dist/components/molecules/MediaCard/MediaCard.svelte +101 -24
- package/dist/components/molecules/MediaCard/MediaCard.svelte.d.ts +25 -6
- package/dist/components/molecules/MediaCard/MediaCardStory.svelte +34 -1
- package/dist/components/molecules/SearchBar/SearchBar.svelte +7 -1
- package/dist/components/molecules/SearchInput/SearchInput.svelte +77 -18
- package/dist/components/molecules/SearchInput/SearchInput.svelte.d.ts +4 -0
- package/dist/components/molecules/SearchInput/SearchInputStory.svelte +1 -0
- package/dist/components/molecules/SearchResultRow/SearchResultRow.stories.js +25 -0
- package/dist/components/molecules/SearchResultRow/SearchResultRow.svelte +74 -0
- package/dist/components/molecules/SearchResultRow/SearchResultRow.svelte.d.ts +18 -0
- package/dist/components/molecules/SearchResultRow/SearchResultRowStory.svelte +85 -0
- package/dist/components/molecules/SearchResultRow/SearchResultRowStory.svelte.d.ts +6 -0
- package/dist/components/molecules/StatCard/StatCard.svelte +7 -1
- package/dist/components/molecules/StatCard/StatCard.svelte.d.ts +2 -0
- package/dist/components/organisms/Drawer/Drawer.svelte +120 -37
- package/dist/components/organisms/Drawer/Drawer.svelte.d.ts +6 -0
- package/dist/components/organisms/MapExplorer/MapExplorer.stories.d.ts +12 -0
- package/dist/components/organisms/MapExplorer/MapExplorer.stories.js +11 -0
- package/dist/components/organisms/MapExplorer/MapExplorer.svelte +928 -0
- package/dist/components/organisms/MapExplorer/MapExplorer.svelte.d.ts +96 -0
- package/dist/components/organisms/MapExplorer/MapExplorerStory.svelte +124 -0
- package/dist/components/organisms/MapExplorer/MapExplorerStory.svelte.d.ts +3 -0
- package/dist/components/organisms/Navbar/Navbar.stories.d.ts +1 -1
- package/dist/components/organisms/Navbar/Navbar.stories.js +1 -1
- package/dist/components/organisms/Navbar/Navbar.svelte +137 -64
- package/dist/components/organisms/Navbar/Navbar.svelte.d.ts +5 -1
- package/dist/components/organisms/Navbar/NavbarStory.svelte +1 -1
- package/dist/components/organisms/Navbar/NavbarStory.svelte.d.ts +1 -1
- package/dist/index.d.ts +8 -0
- package/dist/index.js +5 -0
- package/package.json +12 -8
|
@@ -12,35 +12,54 @@
|
|
|
12
12
|
interface FeatureListProps {
|
|
13
13
|
title?: string;
|
|
14
14
|
items?: FeatureListItem[];
|
|
15
|
+
/** Brand tint (default) or gray circles */
|
|
16
|
+
iconTone?: 'brand' | 'neutral';
|
|
15
17
|
class?: string;
|
|
16
18
|
}
|
|
17
19
|
|
|
18
|
-
const {
|
|
20
|
+
const {
|
|
21
|
+
title,
|
|
22
|
+
items = [],
|
|
23
|
+
iconTone = 'brand',
|
|
24
|
+
class: className = ''
|
|
25
|
+
}: FeatureListProps = $props();
|
|
19
26
|
|
|
20
27
|
const icons: Record<NonNullable<FeatureListItem['icon']>, string> = {
|
|
21
28
|
check: 'M5 13l4 4L19 7',
|
|
22
29
|
bolt: 'M13 2L3 14h7l-1 8 10-12h-7l1-8z',
|
|
23
30
|
shield: 'M12 3l8 4v5c0 5-3.5 8.5-8 10-4.5-1.5-8-5-8-10V7l8-4z',
|
|
24
|
-
spark:
|
|
31
|
+
spark:
|
|
32
|
+
'M12 3v3m0 12v3M3 12h3m12 0h3M5.6 5.6l2.1 2.1m8.6 8.6l2.1 2.1M18.4 5.6l-2.1 2.1M7.7 16.3l-2.1 2.1'
|
|
25
33
|
};
|
|
26
34
|
</script>
|
|
27
35
|
|
|
28
|
-
<div class={['
|
|
36
|
+
<div class={['space-y-3 w-full', className]}>
|
|
29
37
|
{#if title}
|
|
30
38
|
<Heading level={3} size="md">{title}</Heading>
|
|
31
39
|
{/if}
|
|
32
40
|
<Stack gap="md">
|
|
33
41
|
{#each items as item (item.id)}
|
|
34
|
-
<div class=
|
|
42
|
+
<div class={['gap-3 flex', item.description ? 'items-start' : 'items-center']}>
|
|
35
43
|
<span
|
|
36
|
-
class=
|
|
44
|
+
class={[
|
|
45
|
+
'h-9 w-9 rounded-xl flex shrink-0 items-center justify-center',
|
|
46
|
+
iconTone === 'neutral'
|
|
47
|
+
? 'bg-surface-overlay text-secondary'
|
|
48
|
+
: 'bg-brand-50 text-brand-600 dark:bg-brand-950/50 dark:text-brand-400'
|
|
49
|
+
]}
|
|
37
50
|
aria-hidden="true"
|
|
38
51
|
>
|
|
39
|
-
<svg
|
|
52
|
+
<svg
|
|
53
|
+
class="h-4 w-4"
|
|
54
|
+
viewBox="0 0 24 24"
|
|
55
|
+
fill="none"
|
|
56
|
+
stroke="currentColor"
|
|
57
|
+
stroke-width="2"
|
|
58
|
+
>
|
|
40
59
|
<path stroke-linecap="round" stroke-linejoin="round" d={icons[item.icon ?? 'check']} />
|
|
41
60
|
</svg>
|
|
42
61
|
</span>
|
|
43
|
-
<div class=
|
|
62
|
+
<div class={item.description ? 'min-w-0' : 'min-h-9 min-w-0 flex flex-col justify-center'}>
|
|
44
63
|
<p class="text-sm font-medium text-primary">{item.title}</p>
|
|
45
64
|
{#if item.description}
|
|
46
65
|
<p class="mt-0.5 text-xs leading-relaxed text-muted">{item.description}</p>
|
|
@@ -7,6 +7,8 @@ export interface FeatureListItem {
|
|
|
7
7
|
interface FeatureListProps {
|
|
8
8
|
title?: string;
|
|
9
9
|
items?: FeatureListItem[];
|
|
10
|
+
/** Brand tint (default) or gray circles */
|
|
11
|
+
iconTone?: 'brand' | 'neutral';
|
|
10
12
|
class?: string;
|
|
11
13
|
}
|
|
12
14
|
declare const FeatureList: import("svelte").Component<FeatureListProps, {}, "">;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import KnowledgeCardStory from './KnowledgeCardStory.svelte';
|
|
2
|
+
const meta = {
|
|
3
|
+
title: 'Molecules/KnowledgeCard',
|
|
4
|
+
component: KnowledgeCardStory,
|
|
5
|
+
tags: ['autodocs'],
|
|
6
|
+
argTypes: {
|
|
7
|
+
example: {
|
|
8
|
+
control: 'select',
|
|
9
|
+
options: ['basic', 'with-cover', 'with-actions', 'minimal']
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
export default meta;
|
|
14
|
+
export const Default = {
|
|
15
|
+
args: { example: 'basic' }
|
|
16
|
+
};
|
|
17
|
+
export const WithCover = {
|
|
18
|
+
args: { example: 'with-cover' }
|
|
19
|
+
};
|
|
20
|
+
export const WithActions = {
|
|
21
|
+
args: { example: 'with-actions' }
|
|
22
|
+
};
|
|
23
|
+
export const Minimal = {
|
|
24
|
+
args: { example: 'minimal' }
|
|
25
|
+
};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import type { Snippet } from 'svelte'
|
|
3
|
+
import Avatar from '../../atoms/Avatar/Avatar.svelte'
|
|
4
|
+
import Image from '../../atoms/Image/Image.svelte'
|
|
5
|
+
|
|
6
|
+
interface KnowledgeCardProps {
|
|
7
|
+
title: string
|
|
8
|
+
subtitle?: string
|
|
9
|
+
coverUrl?: string
|
|
10
|
+
avatarUrl?: string
|
|
11
|
+
href?: string
|
|
12
|
+
class?: string
|
|
13
|
+
/** Snippet for action buttons below title/subtitle */
|
|
14
|
+
actions?: Snippet
|
|
15
|
+
children?: Snippet
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
let {
|
|
19
|
+
title,
|
|
20
|
+
subtitle,
|
|
21
|
+
coverUrl,
|
|
22
|
+
avatarUrl,
|
|
23
|
+
href,
|
|
24
|
+
class: className = '',
|
|
25
|
+
actions,
|
|
26
|
+
children
|
|
27
|
+
}: KnowledgeCardProps = $props()
|
|
28
|
+
|
|
29
|
+
const hasCover = $derived(!!coverUrl)
|
|
30
|
+
const hasAvatar = $derived(!!avatarUrl || !!title)
|
|
31
|
+
</script>
|
|
32
|
+
|
|
33
|
+
<div
|
|
34
|
+
class={[
|
|
35
|
+
'overflow-hidden rounded-xl border border-border bg-surface-elevated',
|
|
36
|
+
className
|
|
37
|
+
]}
|
|
38
|
+
>
|
|
39
|
+
<!-- Cover area -->
|
|
40
|
+
{#if hasCover}
|
|
41
|
+
<div class="relative w-full" style="aspect-ratio: 3/1">
|
|
42
|
+
<Image
|
|
43
|
+
src={coverUrl!}
|
|
44
|
+
alt={title}
|
|
45
|
+
aspectRatio="3/1"
|
|
46
|
+
class="absolute inset-0 h-full w-full"
|
|
47
|
+
rounded={false}
|
|
48
|
+
/>
|
|
49
|
+
</div>
|
|
50
|
+
{:else}
|
|
51
|
+
<div class="h-16 w-full bg-surface-overlay" style="aspect-ratio: 3/1"></div>
|
|
52
|
+
{/if}
|
|
53
|
+
|
|
54
|
+
<!-- Avatar overlapping -->
|
|
55
|
+
{#if hasAvatar}
|
|
56
|
+
<div class={['-mt-5 px-4', hasCover ? '-mt-6' : '-mt-5']}>
|
|
57
|
+
<Avatar
|
|
58
|
+
src={avatarUrl}
|
|
59
|
+
name={title}
|
|
60
|
+
size="lg"
|
|
61
|
+
class="ring-2 ring-surface-elevated"
|
|
62
|
+
/>
|
|
63
|
+
</div>
|
|
64
|
+
{/if}
|
|
65
|
+
|
|
66
|
+
<!-- Body -->
|
|
67
|
+
<div class="px-4 pb-4" class:pt-2={hasAvatar} class:pt-4={!hasAvatar}>
|
|
68
|
+
{#if href}
|
|
69
|
+
<a
|
|
70
|
+
{href}
|
|
71
|
+
class="block text-base font-semibold leading-snug text-primary hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-brand-500/30"
|
|
72
|
+
>
|
|
73
|
+
{title}
|
|
74
|
+
</a>
|
|
75
|
+
{:else}
|
|
76
|
+
<p class="text-base font-semibold leading-snug text-primary">{title}</p>
|
|
77
|
+
{/if}
|
|
78
|
+
|
|
79
|
+
{#if subtitle}
|
|
80
|
+
<p class="mt-0.5 text-sm text-muted">{subtitle}</p>
|
|
81
|
+
{/if}
|
|
82
|
+
|
|
83
|
+
{#if children}
|
|
84
|
+
<div class="mt-3 border-t border-border/70 pt-3">
|
|
85
|
+
{@render children()}
|
|
86
|
+
</div>
|
|
87
|
+
{/if}
|
|
88
|
+
|
|
89
|
+
{#if actions}
|
|
90
|
+
<div class="mt-3">
|
|
91
|
+
{@render actions()}
|
|
92
|
+
</div>
|
|
93
|
+
{/if}
|
|
94
|
+
</div>
|
|
95
|
+
</div>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { Snippet } from 'svelte';
|
|
2
|
+
interface KnowledgeCardProps {
|
|
3
|
+
title: string;
|
|
4
|
+
subtitle?: string;
|
|
5
|
+
coverUrl?: string;
|
|
6
|
+
avatarUrl?: string;
|
|
7
|
+
href?: string;
|
|
8
|
+
class?: string;
|
|
9
|
+
/** Snippet for action buttons below title/subtitle */
|
|
10
|
+
actions?: Snippet;
|
|
11
|
+
children?: Snippet;
|
|
12
|
+
}
|
|
13
|
+
declare const KnowledgeCard: import("svelte").Component<KnowledgeCardProps, {}, "">;
|
|
14
|
+
type KnowledgeCard = ReturnType<typeof KnowledgeCard>;
|
|
15
|
+
export default KnowledgeCard;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
<script lang="ts">
|
|
2
|
+
import KnowledgeCard from './KnowledgeCard.svelte'
|
|
3
|
+
import Button from '../../atoms/Button/Button.svelte'
|
|
4
|
+
import Badge from '../../atoms/Badge/Badge.svelte'
|
|
5
|
+
import Text from '../../atoms/Text/Text.svelte'
|
|
6
|
+
|
|
7
|
+
interface Props {
|
|
8
|
+
example?: 'basic' | 'with-cover' | 'with-actions' | 'minimal'
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
let { example = 'basic' }: Props = $props()
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<div class="mx-auto w-full max-w-xs space-y-4 p-4">
|
|
15
|
+
{#if example === 'basic'}
|
|
16
|
+
<p class="text-[11px] font-medium uppercase tracking-wide text-muted">Basic entity card</p>
|
|
17
|
+
<KnowledgeCard
|
|
18
|
+
title="Rafael González"
|
|
19
|
+
subtitle="Fundador · R2 Digisolutions"
|
|
20
|
+
href="#"
|
|
21
|
+
/>
|
|
22
|
+
{:else if example === 'with-cover'}
|
|
23
|
+
<p class="text-[11px] font-medium uppercase tracking-wide text-muted">With cover image</p>
|
|
24
|
+
<KnowledgeCard
|
|
25
|
+
title="Evoteg"
|
|
26
|
+
subtitle="Plataforma SaaS para empresas"
|
|
27
|
+
coverUrl="https://images.unsplash.com/photo-1497366216548-37526070297c?w=600&q=80"
|
|
28
|
+
avatarUrl="https://evoteg.com/favicon.ico"
|
|
29
|
+
href="#"
|
|
30
|
+
/>
|
|
31
|
+
{:else if example === 'with-actions'}
|
|
32
|
+
<p class="text-[11px] font-medium uppercase tracking-wide text-muted">With actions + children</p>
|
|
33
|
+
<KnowledgeCard
|
|
34
|
+
title="EvoFact CRM"
|
|
35
|
+
subtitle="Software de gestión empresarial"
|
|
36
|
+
coverUrl="https://images.unsplash.com/photo-1551434678-e076c223a692?w=600&q=80"
|
|
37
|
+
>
|
|
38
|
+
{#snippet actions()}
|
|
39
|
+
<div class="flex gap-2">
|
|
40
|
+
<Button size="sm" variant="primary">Ver producto</Button>
|
|
41
|
+
<Button size="sm" variant="secondary">Más info</Button>
|
|
42
|
+
</div>
|
|
43
|
+
{/snippet}
|
|
44
|
+
{#snippet children()}
|
|
45
|
+
<div class="flex flex-wrap gap-1">
|
|
46
|
+
<Badge size="sm" variant="secondary" rounded>CRM</Badge>
|
|
47
|
+
<Badge size="sm" variant="secondary" rounded>Facturación</Badge>
|
|
48
|
+
<Badge size="sm" variant="secondary" rounded>VeriFactu</Badge>
|
|
49
|
+
</div>
|
|
50
|
+
{/snippet}
|
|
51
|
+
</KnowledgeCard>
|
|
52
|
+
{:else}
|
|
53
|
+
<p class="text-[11px] font-medium uppercase tracking-wide text-muted">Minimal (no cover)</p>
|
|
54
|
+
<KnowledgeCard title="Atom Gym" subtitle="Gestión de centros deportivos" />
|
|
55
|
+
{/if}
|
|
56
|
+
</div>
|
|
@@ -74,10 +74,10 @@
|
|
|
74
74
|
const triggerSize = $derived(
|
|
75
75
|
stacked
|
|
76
76
|
? size === 'sm'
|
|
77
|
-
? '
|
|
77
|
+
? 'h-8 gap-1.5 px-2.5'
|
|
78
78
|
: size === 'lg'
|
|
79
|
-
? '
|
|
80
|
-
: '
|
|
79
|
+
? 'h-11 gap-2.5 px-3.5'
|
|
80
|
+
: 'h-10 gap-2 px-3'
|
|
81
81
|
: size === 'sm'
|
|
82
82
|
? 'h-8 gap-1.5 px-2.5 text-xs'
|
|
83
83
|
: size === 'lg'
|
|
@@ -216,11 +216,11 @@
|
|
|
216
216
|
<Globe class="h-4 w-4 shrink-0 text-muted" />
|
|
217
217
|
{/if}
|
|
218
218
|
{#if stacked}
|
|
219
|
-
<span class="min-w-0 max-w-
|
|
219
|
+
<span class="min-w-0 max-w-24 flex-1 text-left leading-none" dir={current?.dir ?? 'ltr'}>
|
|
220
220
|
<span class="text-primary block truncate text-xs font-medium"
|
|
221
221
|
>{current?.label ?? value}</span
|
|
222
222
|
>
|
|
223
|
-
<span class="text-
|
|
223
|
+
<span class="text-muted mt-px block truncate text-[9px] font-medium tracking-wide"
|
|
224
224
|
>{shortCode}</span
|
|
225
225
|
>
|
|
226
226
|
</span>
|
|
@@ -1,20 +1,43 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
2
|
import type { Snippet } from 'svelte';
|
|
3
|
+
import type { ClassValue } from 'svelte/elements';
|
|
3
4
|
import Card from '../Card/Card.svelte';
|
|
4
5
|
import type { CardVariant } from '../Card/Card.svelte';
|
|
5
6
|
import AspectRatio from '../../atoms/AspectRatio/AspectRatio.svelte';
|
|
6
7
|
import Image from '../../atoms/Image/Image.svelte';
|
|
7
8
|
import Button from '../../atoms/Button/Button.svelte';
|
|
9
|
+
import Eyebrow from '../../atoms/Eyebrow/Eyebrow.svelte';
|
|
10
|
+
import Heading from '../../atoms/Heading/Heading.svelte';
|
|
11
|
+
import Text from '../../atoms/Text/Text.svelte';
|
|
12
|
+
import FeatureList from '../FeatureList/FeatureList.svelte';
|
|
13
|
+
import type { FeatureListItem } from '../FeatureList/FeatureList.svelte';
|
|
14
|
+
|
|
15
|
+
export type { FeatureListItem };
|
|
8
16
|
|
|
9
17
|
interface MediaCardProps {
|
|
10
|
-
src
|
|
11
|
-
alt
|
|
12
|
-
|
|
13
|
-
description?: string;
|
|
18
|
+
src?: string;
|
|
19
|
+
alt?: string;
|
|
20
|
+
/** Numeric aspect (16/9 ≈ 1.778). Ignored when `aspectRatio` is set. */
|
|
14
21
|
ratio?: number;
|
|
22
|
+
/** CSS aspect-ratio, e.g. `'16 / 10'`. */
|
|
23
|
+
aspectRatio?: string;
|
|
24
|
+
eyebrow?: string;
|
|
25
|
+
title?: string;
|
|
26
|
+
description?: string;
|
|
27
|
+
itemsTitle?: string;
|
|
28
|
+
items?: FeatureListItem[];
|
|
29
|
+
iconTone?: 'brand' | 'neutral';
|
|
15
30
|
variant?: CardVariant;
|
|
16
31
|
actionLabel?: string;
|
|
17
|
-
|
|
32
|
+
actionHref?: string;
|
|
33
|
+
/** Stick under the site header from `lg` up. */
|
|
34
|
+
sticky?: boolean;
|
|
35
|
+
chrome?: boolean;
|
|
36
|
+
class?: ClassValue;
|
|
37
|
+
/** Replace the photo region (image, gallery, video…). */
|
|
38
|
+
media?: Snippet;
|
|
39
|
+
/** Extra body below title / feature list. */
|
|
40
|
+
children?: Snippet;
|
|
18
41
|
footer?: Snippet;
|
|
19
42
|
onaction?: () => void;
|
|
20
43
|
onclick?: (e: MouseEvent) => void;
|
|
@@ -22,39 +45,93 @@
|
|
|
22
45
|
|
|
23
46
|
const {
|
|
24
47
|
src,
|
|
25
|
-
alt,
|
|
48
|
+
alt = '',
|
|
49
|
+
ratio = 1.777777778,
|
|
50
|
+
aspectRatio,
|
|
51
|
+
eyebrow,
|
|
26
52
|
title,
|
|
27
53
|
description,
|
|
28
|
-
|
|
54
|
+
itemsTitle,
|
|
55
|
+
items = [],
|
|
56
|
+
iconTone = 'brand',
|
|
29
57
|
variant = 'default',
|
|
30
58
|
actionLabel,
|
|
59
|
+
actionHref,
|
|
60
|
+
sticky = false,
|
|
61
|
+
chrome = true,
|
|
31
62
|
class: className = '',
|
|
63
|
+
media,
|
|
64
|
+
children,
|
|
32
65
|
footer,
|
|
33
66
|
onaction,
|
|
34
67
|
onclick
|
|
35
68
|
}: MediaCardProps = $props();
|
|
36
|
-
</script>
|
|
37
69
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
70
|
+
const hasMedia = $derived(!!media || !!src);
|
|
71
|
+
const hasList = $derived(items.length > 0);
|
|
72
|
+
const hasBody = $derived(
|
|
73
|
+
!!eyebrow || !!title || !!description || !!itemsTitle || hasList || !!children
|
|
74
|
+
);
|
|
75
|
+
const hasFooter = $derived(!!footer || !!actionLabel);
|
|
76
|
+
</script>
|
|
42
77
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
{#if
|
|
46
|
-
|
|
47
|
-
{
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
78
|
+
{#snippet cardFooter()}
|
|
79
|
+
<div class="px-5 py-4 sm:px-6">
|
|
80
|
+
{#if footer}
|
|
81
|
+
{@render footer()}
|
|
82
|
+
{:else if actionLabel}
|
|
83
|
+
<Button
|
|
84
|
+
size="sm"
|
|
85
|
+
href={actionHref}
|
|
86
|
+
variant={actionHref ? 'primary' : 'secondary'}
|
|
87
|
+
onclick={() => onaction?.()}>{actionLabel}</Button
|
|
88
|
+
>
|
|
52
89
|
{/if}
|
|
53
90
|
</div>
|
|
91
|
+
{/snippet}
|
|
54
92
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
93
|
+
<Card
|
|
94
|
+
{variant}
|
|
95
|
+
{chrome}
|
|
96
|
+
{onclick}
|
|
97
|
+
padding="none"
|
|
98
|
+
hoverable={!!onclick}
|
|
99
|
+
footer={hasFooter ? cardFooter : undefined}
|
|
100
|
+
class={['h-fit overflow-hidden', sticky && 'lg:sticky lg:top-24', className]}
|
|
101
|
+
>
|
|
102
|
+
{#if hasMedia}
|
|
103
|
+
{#if media}
|
|
104
|
+
{@render media()}
|
|
105
|
+
{:else if src && aspectRatio}
|
|
106
|
+
<Image {src} {alt} {aspectRatio} objectFit="cover" rounded={false} class="w-full" />
|
|
107
|
+
{:else if src}
|
|
108
|
+
<AspectRatio {ratio}>
|
|
109
|
+
<Image {src} {alt} objectFit="cover" class="h-full w-full" />
|
|
110
|
+
</AspectRatio>
|
|
111
|
+
{/if}
|
|
112
|
+
{/if}
|
|
113
|
+
|
|
114
|
+
{#if hasBody}
|
|
115
|
+
<div class="min-w-0 gap-4 px-5 py-5 sm:px-6 sm:py-6 flex flex-1 flex-col">
|
|
116
|
+
{#if eyebrow || title || description}
|
|
117
|
+
<div class="space-y-2">
|
|
118
|
+
{#if eyebrow}
|
|
119
|
+
<Eyebrow>{eyebrow}</Eyebrow>
|
|
120
|
+
{/if}
|
|
121
|
+
{#if title}
|
|
122
|
+
<Heading level={3} size="md">{title}</Heading>
|
|
123
|
+
{/if}
|
|
124
|
+
{#if description}
|
|
125
|
+
<Text size="sm" tone="muted">{description}</Text>
|
|
126
|
+
{/if}
|
|
127
|
+
</div>
|
|
128
|
+
{/if}
|
|
129
|
+
{#if hasList || itemsTitle}
|
|
130
|
+
<FeatureList title={itemsTitle} {items} {iconTone} />
|
|
131
|
+
{/if}
|
|
132
|
+
{#if children}
|
|
133
|
+
{@render children()}
|
|
134
|
+
{/if}
|
|
58
135
|
</div>
|
|
59
136
|
{/if}
|
|
60
137
|
</Card>
|
|
@@ -1,18 +1,37 @@
|
|
|
1
1
|
import type { Snippet } from 'svelte';
|
|
2
|
+
import type { ClassValue } from 'svelte/elements';
|
|
2
3
|
import type { CardVariant } from '../Card/Card.svelte';
|
|
4
|
+
import type { FeatureListItem } from '../FeatureList/FeatureList.svelte';
|
|
3
5
|
interface MediaCardProps {
|
|
4
|
-
src
|
|
5
|
-
alt
|
|
6
|
-
|
|
7
|
-
description?: string;
|
|
6
|
+
src?: string;
|
|
7
|
+
alt?: string;
|
|
8
|
+
/** Numeric aspect (16/9 ≈ 1.778). Ignored when `aspectRatio` is set. */
|
|
8
9
|
ratio?: number;
|
|
10
|
+
/** CSS aspect-ratio, e.g. `'16 / 10'`. */
|
|
11
|
+
aspectRatio?: string;
|
|
12
|
+
eyebrow?: string;
|
|
13
|
+
title?: string;
|
|
14
|
+
description?: string;
|
|
15
|
+
itemsTitle?: string;
|
|
16
|
+
items?: FeatureListItem[];
|
|
17
|
+
iconTone?: 'brand' | 'neutral';
|
|
9
18
|
variant?: CardVariant;
|
|
10
19
|
actionLabel?: string;
|
|
11
|
-
|
|
20
|
+
actionHref?: string;
|
|
21
|
+
/** Stick under the site header from `lg` up. */
|
|
22
|
+
sticky?: boolean;
|
|
23
|
+
chrome?: boolean;
|
|
24
|
+
class?: ClassValue;
|
|
25
|
+
/** Replace the photo region (image, gallery, video…). */
|
|
26
|
+
media?: Snippet;
|
|
27
|
+
/** Extra body below title / feature list. */
|
|
28
|
+
children?: Snippet;
|
|
12
29
|
footer?: Snippet;
|
|
13
30
|
onaction?: () => void;
|
|
14
31
|
onclick?: (e: MouseEvent) => void;
|
|
15
32
|
}
|
|
16
|
-
declare const MediaCard: import("svelte").Component<MediaCardProps, {
|
|
33
|
+
declare const MediaCard: import("svelte").Component<MediaCardProps, {
|
|
34
|
+
FeatureListItem: typeof FeatureListItem;
|
|
35
|
+
}, "">;
|
|
17
36
|
type MediaCard = ReturnType<typeof MediaCard>;
|
|
18
37
|
export default MediaCard;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
<script lang="ts">
|
|
2
|
+
import Button from '../../atoms/Button/Button.svelte';
|
|
2
3
|
import MediaCard from './MediaCard.svelte';
|
|
3
4
|
|
|
4
5
|
let props = $props<{
|
|
@@ -8,7 +9,7 @@
|
|
|
8
9
|
}>();
|
|
9
10
|
</script>
|
|
10
11
|
|
|
11
|
-
<div class="max-w-
|
|
12
|
+
<div class="max-w-5xl gap-6 md:grid-cols-2 grid">
|
|
12
13
|
<MediaCard
|
|
13
14
|
src="https://images.unsplash.com/photo-1618005182384-a83a8bd57fbe?w=800&q=80"
|
|
14
15
|
alt="Abstract gradient"
|
|
@@ -17,4 +18,36 @@
|
|
|
17
18
|
'Reusable atoms and molecules compose into full product surfaces.'}
|
|
18
19
|
actionLabel={props.actionLabel ?? 'Read more'}
|
|
19
20
|
/>
|
|
21
|
+
<MediaCard
|
|
22
|
+
src="https://images.unsplash.com/photo-1501281668745-f7f57925c3b4?w=800&q=80"
|
|
23
|
+
alt="Crowd at a show"
|
|
24
|
+
aspectRatio="16 / 10"
|
|
25
|
+
eyebrow="Connector"
|
|
26
|
+
itemsTitle="What ships, what stays"
|
|
27
|
+
iconTone="neutral"
|
|
28
|
+
items={[
|
|
29
|
+
{
|
|
30
|
+
id: 'toggle',
|
|
31
|
+
title: 'Opt-in per event',
|
|
32
|
+
description: 'No dump. The toggle publishes the listing.',
|
|
33
|
+
icon: 'check'
|
|
34
|
+
},
|
|
35
|
+
{
|
|
36
|
+
id: 'sync',
|
|
37
|
+
title: 'Signed webhook',
|
|
38
|
+
description: 'Create, update and cancel. Invalid secret, nothing comes in.',
|
|
39
|
+
icon: 'bolt'
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
id: 'soon',
|
|
43
|
+
title: 'Other sellers later',
|
|
44
|
+
description: 'This marketplace ships first.',
|
|
45
|
+
icon: 'spark'
|
|
46
|
+
}
|
|
47
|
+
]}
|
|
48
|
+
>
|
|
49
|
+
{#snippet footer()}
|
|
50
|
+
<Button href="#docs" size="sm">Open docs</Button>
|
|
51
|
+
{/snippet}
|
|
52
|
+
</MediaCard>
|
|
20
53
|
</div>
|
|
@@ -59,7 +59,13 @@
|
|
|
59
59
|
|
|
60
60
|
function submit() {
|
|
61
61
|
if (busy) return;
|
|
62
|
-
|
|
62
|
+
const el =
|
|
63
|
+
typeof document !== 'undefined'
|
|
64
|
+
? (document.getElementById(inputId) as HTMLInputElement | null)
|
|
65
|
+
: null;
|
|
66
|
+
const live = el?.value ?? value;
|
|
67
|
+
value = live;
|
|
68
|
+
onsubmit?.(live);
|
|
63
69
|
}
|
|
64
70
|
|
|
65
71
|
function clear() {
|