@r2digisolutions/components 0.22.2 → 0.23.0

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.
Files changed (57) hide show
  1. package/dist/components/atoms/Avatar/Avatar.stories.d.ts +1 -1
  2. package/dist/components/atoms/Avatar/Avatar.svelte +5 -3
  3. package/dist/components/atoms/Avatar/Avatar.svelte.d.ts +1 -1
  4. package/dist/components/atoms/Avatar/AvatarStory.svelte +1 -1
  5. package/dist/components/atoms/Avatar/AvatarStory.svelte.d.ts +1 -1
  6. package/dist/components/atoms/Container/Container.stories.d.ts +1 -1
  7. package/dist/components/atoms/Container/ContainerStory.svelte.d.ts +1 -1
  8. package/dist/components/molecules/AdSlot/AdSlot.stories.js +10 -0
  9. package/dist/components/molecules/AdSlot/AdSlot.svelte +16 -0
  10. package/dist/components/molecules/AdSlot/AdSlot.svelte.d.ts +8 -0
  11. package/dist/components/molecules/AdSlot/AdSlotStory.svelte +23 -0
  12. package/dist/components/molecules/AdSlot/AdSlotStory.svelte.d.ts +18 -0
  13. package/dist/components/molecules/AdUnit/AdUnit.stories.js +28 -0
  14. package/dist/components/molecules/AdUnit/AdUnit.svelte +151 -0
  15. package/dist/components/molecules/AdUnit/AdUnit.svelte.d.ts +15 -0
  16. package/dist/components/molecules/AdUnit/AdUnitStory.svelte +36 -0
  17. package/dist/components/molecules/AdUnit/AdUnitStory.svelte.d.ts +7 -0
  18. package/dist/components/molecules/AvatarGroup/AvatarGroup.svelte +1 -1
  19. package/dist/components/molecules/AvatarGroup/AvatarGroup.svelte.d.ts +1 -1
  20. package/dist/components/molecules/AvatarLabel/AvatarLabel.svelte +1 -1
  21. package/dist/components/molecules/AvatarLabel/AvatarLabel.svelte.d.ts +1 -1
  22. package/dist/components/molecules/Card/Card.svelte +6 -15
  23. package/dist/components/molecules/FeatureList/FeatureList.svelte +26 -7
  24. package/dist/components/molecules/FeatureList/FeatureList.svelte.d.ts +2 -0
  25. package/dist/components/molecules/KnowledgeCard/KnowledgeCard.stories.js +25 -0
  26. package/dist/components/molecules/KnowledgeCard/KnowledgeCard.svelte +95 -0
  27. package/dist/components/molecules/KnowledgeCard/KnowledgeCard.svelte.d.ts +15 -0
  28. package/dist/components/molecules/KnowledgeCard/KnowledgeCardStory.svelte +56 -0
  29. package/dist/components/molecules/KnowledgeCard/KnowledgeCardStory.svelte.d.ts +6 -0
  30. package/dist/components/molecules/LocaleSwitcher/LocaleSwitcher.svelte +5 -5
  31. package/dist/components/molecules/MediaCard/MediaCard.svelte +101 -24
  32. package/dist/components/molecules/MediaCard/MediaCard.svelte.d.ts +25 -6
  33. package/dist/components/molecules/MediaCard/MediaCardStory.svelte +34 -1
  34. package/dist/components/molecules/SearchResultRow/SearchResultRow.stories.js +25 -0
  35. package/dist/components/molecules/SearchResultRow/SearchResultRow.svelte +74 -0
  36. package/dist/components/molecules/SearchResultRow/SearchResultRow.svelte.d.ts +18 -0
  37. package/dist/components/molecules/SearchResultRow/SearchResultRowStory.svelte +85 -0
  38. package/dist/components/molecules/SearchResultRow/SearchResultRowStory.svelte.d.ts +6 -0
  39. package/dist/components/molecules/StatCard/StatCard.svelte +7 -1
  40. package/dist/components/molecules/StatCard/StatCard.svelte.d.ts +2 -0
  41. package/dist/components/organisms/Drawer/Drawer.svelte +120 -37
  42. package/dist/components/organisms/Drawer/Drawer.svelte.d.ts +6 -0
  43. package/dist/components/organisms/MapExplorer/MapExplorer.stories.d.ts +12 -0
  44. package/dist/components/organisms/MapExplorer/MapExplorer.stories.js +11 -0
  45. package/dist/components/organisms/MapExplorer/MapExplorer.svelte +928 -0
  46. package/dist/components/organisms/MapExplorer/MapExplorer.svelte.d.ts +96 -0
  47. package/dist/components/organisms/MapExplorer/MapExplorerStory.svelte +124 -0
  48. package/dist/components/organisms/MapExplorer/MapExplorerStory.svelte.d.ts +3 -0
  49. package/dist/components/organisms/Navbar/Navbar.stories.d.ts +1 -1
  50. package/dist/components/organisms/Navbar/Navbar.stories.js +1 -1
  51. package/dist/components/organisms/Navbar/Navbar.svelte +137 -64
  52. package/dist/components/organisms/Navbar/Navbar.svelte.d.ts +5 -1
  53. package/dist/components/organisms/Navbar/NavbarStory.svelte +1 -1
  54. package/dist/components/organisms/Navbar/NavbarStory.svelte.d.ts +1 -1
  55. package/dist/index.d.ts +8 -0
  56. package/dist/index.js +5 -0
  57. package/package.json +12 -8
@@ -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 actions}
84
+ <div class="mt-3">
85
+ {@render actions()}
86
+ </div>
87
+ {/if}
88
+
89
+ {#if children}
90
+ <div class="mt-3">
91
+ {@render children()}
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>
@@ -0,0 +1,6 @@
1
+ interface Props {
2
+ example?: 'basic' | 'with-cover' | 'with-actions' | 'minimal';
3
+ }
4
+ declare const KnowledgeCardStory: import("svelte").Component<Props, {}, "">;
5
+ type KnowledgeCardStory = ReturnType<typeof KnowledgeCardStory>;
6
+ export default KnowledgeCardStory;
@@ -74,10 +74,10 @@
74
74
  const triggerSize = $derived(
75
75
  stacked
76
76
  ? size === 'sm'
77
- ? 'min-h-9 gap-1.5 px-2.5 py-1'
77
+ ? 'h-8 gap-1.5 px-2.5'
78
78
  : size === 'lg'
79
- ? 'min-h-11 gap-2.5 px-3.5 py-1.5'
80
- : 'min-h-10 gap-2 px-3 py-1'
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-28 flex-1 text-left leading-tight" dir={current?.dir ?? 'ltr'}>
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-secondary block truncate text-[10px] font-semibold tracking-wide"
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: string;
11
- alt: string;
12
- title: string;
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
- class?: string;
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
- ratio = 1.777777778,
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
- <Card {variant} padding="none" hoverable={!!onclick} {onclick} class={className} chrome={false}>
39
- <AspectRatio {ratio}>
40
- <Image {src} {alt} objectFit="cover" class="h-full w-full" />
41
- </AspectRatio>
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
- <div class="space-y-2 p-4 sm:p-5">
44
- <h3 class="text-base font-semibold text-primary">{title}</h3>
45
- {#if description}
46
- <p class="text-sm leading-relaxed text-muted">{description}</p>
47
- {/if}
48
- {#if actionLabel}
49
- <div class="pt-1">
50
- <Button size="sm" variant="secondary" onclick={() => onaction?.()}>{actionLabel}</Button>
51
- </div>
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
- {#if footer}
56
- <div class="border-t border-border px-4 py-3 sm:px-5">
57
- {@render footer()}
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: string;
5
- alt: string;
6
- title: string;
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
- class?: string;
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-sm">
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>
@@ -0,0 +1,25 @@
1
+ import SearchResultRowStory from './SearchResultRowStory.svelte';
2
+ const meta = {
3
+ title: 'Molecules/SearchResultRow',
4
+ component: SearchResultRowStory,
5
+ tags: ['autodocs'],
6
+ argTypes: {
7
+ example: {
8
+ control: 'select',
9
+ options: ['basic', 'with-favicon', 'no-href', 'leading-slot']
10
+ }
11
+ }
12
+ };
13
+ export default meta;
14
+ export const Default = {
15
+ args: { example: 'basic' }
16
+ };
17
+ export const WithFavicons = {
18
+ args: { example: 'with-favicon' }
19
+ };
20
+ export const NoHref = {
21
+ args: { example: 'no-href' }
22
+ };
23
+ export const LeadingSlot = {
24
+ args: { example: 'leading-slot' }
25
+ };
@@ -0,0 +1,74 @@
1
+ <script lang="ts">
2
+ import type { Snippet } from 'svelte'
3
+
4
+ export type SearchResultRowKind = 'doc' | 'page' | 'person' | 'file' | 'product' | string
5
+
6
+ interface SearchResultRowProps {
7
+ title: string
8
+ href?: string
9
+ /** Breadcrumb text shown below the title */
10
+ urlLabel?: string
11
+ snippet?: string
12
+ kind?: SearchResultRowKind
13
+ /** URL or path to a favicon/icon image */
14
+ favicon?: string
15
+ class?: string
16
+ /** Optional leading slot (replaces favicon when provided) */
17
+ leading?: Snippet
18
+ }
19
+
20
+ let {
21
+ title,
22
+ href,
23
+ urlLabel,
24
+ snippet,
25
+ kind: _kind,
26
+ favicon,
27
+ class: className = '',
28
+ leading
29
+ }: SearchResultRowProps = $props()
30
+
31
+ const hasLeading = $derived(!!leading || !!favicon)
32
+ </script>
33
+
34
+ <div class={['group flex min-w-0 gap-3 py-2', className]}>
35
+ {#if hasLeading}
36
+ <div class="mt-0.5 shrink-0">
37
+ {#if leading}
38
+ {@render leading()}
39
+ {:else if favicon}
40
+ <img
41
+ src={favicon}
42
+ alt=""
43
+ aria-hidden="true"
44
+ class="h-4 w-4 rounded-sm object-contain"
45
+ loading="lazy"
46
+ decoding="async"
47
+ />
48
+ {/if}
49
+ </div>
50
+ {/if}
51
+
52
+ <div class="min-w-0 flex-1">
53
+ {#if urlLabel}
54
+ <p class="mb-0.5 truncate text-xs text-muted">{urlLabel}</p>
55
+ {/if}
56
+
57
+ {#if href}
58
+ <a
59
+ {href}
60
+ class="block truncate text-lg font-medium leading-snug text-brand-600 hover:underline focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-brand-500/30"
61
+ >
62
+ {title}
63
+ </a>
64
+ {:else}
65
+ <span class="block truncate text-lg font-medium leading-snug text-brand-600">
66
+ {title}
67
+ </span>
68
+ {/if}
69
+
70
+ {#if snippet}
71
+ <p class="mt-1 line-clamp-2 text-sm text-secondary">{snippet}</p>
72
+ {/if}
73
+ </div>
74
+ </div>
@@ -0,0 +1,18 @@
1
+ import type { Snippet } from 'svelte';
2
+ export type SearchResultRowKind = 'doc' | 'page' | 'person' | 'file' | 'product' | string;
3
+ interface SearchResultRowProps {
4
+ title: string;
5
+ href?: string;
6
+ /** Breadcrumb text shown below the title */
7
+ urlLabel?: string;
8
+ snippet?: string;
9
+ kind?: SearchResultRowKind;
10
+ /** URL or path to a favicon/icon image */
11
+ favicon?: string;
12
+ class?: string;
13
+ /** Optional leading slot (replaces favicon when provided) */
14
+ leading?: Snippet;
15
+ }
16
+ declare const SearchResultRow: import("svelte").Component<SearchResultRowProps, {}, "">;
17
+ type SearchResultRow = ReturnType<typeof SearchResultRow>;
18
+ export default SearchResultRow;
@@ -0,0 +1,85 @@
1
+ <script lang="ts">
2
+ import SearchResultRow from './SearchResultRow.svelte'
3
+ import Avatar from '../../atoms/Avatar/Avatar.svelte'
4
+
5
+ interface Props {
6
+ example?: 'basic' | 'with-favicon' | 'no-href' | 'leading-slot'
7
+ }
8
+
9
+ let { example = 'basic' }: Props = $props()
10
+ </script>
11
+
12
+ <div class="mx-auto w-full max-w-2xl space-y-1 p-4">
13
+ {#if example === 'basic'}
14
+ <p class="mb-3 text-[11px] font-medium uppercase tracking-wide text-muted">Basic SERP rows</p>
15
+ <div class="divide-y divide-border">
16
+ <SearchResultRow
17
+ title="SvelteKit — The fastest way to build Svelte apps"
18
+ href="https://kit.svelte.dev"
19
+ urlLabel="kit.svelte.dev"
20
+ snippet="SvelteKit is the official application framework for Svelte. It provides everything you need to build fast, secure, and reliable web applications."
21
+ />
22
+ <SearchResultRow
23
+ title="Svelte • Cybernetically enhanced web apps"
24
+ href="https://svelte.dev"
25
+ urlLabel="svelte.dev"
26
+ snippet="Svelte is a radical new approach to building user interfaces. Whereas traditional frameworks like React and Vue do the bulk of their work in the browser, Svelte shifts that work into a compile step."
27
+ />
28
+ <SearchResultRow
29
+ title="Vite — Next Generation Frontend Tooling"
30
+ href="https://vitejs.dev"
31
+ urlLabel="vitejs.dev › guide"
32
+ snippet="Vite (French word for 'quick', pronounced /vit/) is a build tool that aims to provide a faster and leaner development experience for modern web projects."
33
+ />
34
+ </div>
35
+ {:else if example === 'with-favicon'}
36
+ <p class="mb-3 text-[11px] font-medium uppercase tracking-wide text-muted">With favicons</p>
37
+ <div class="divide-y divide-border">
38
+ <SearchResultRow
39
+ title="Evoteg — Plataforma de gestión empresarial"
40
+ href="https://evoteg.com"
41
+ urlLabel="evoteg.com"
42
+ snippet="Software CRM, gestión de gimnasios y herramientas de marketing para empresas modernas."
43
+ favicon="https://evoteg.com/favicon.ico"
44
+ />
45
+ <SearchResultRow
46
+ title="EvoFact CRM — Facturación y clientes"
47
+ href="https://crm.evoteg.com"
48
+ urlLabel="crm.evoteg.com › dashboard"
49
+ snippet="Gestiona tus clientes, facturas y oportunidades de negocio desde una única plataforma."
50
+ favicon="https://evoteg.com/favicon.ico"
51
+ />
52
+ </div>
53
+ {:else if example === 'no-href'}
54
+ <p class="mb-3 text-[11px] font-medium uppercase tracking-wide text-muted">No link (static)</p>
55
+ <SearchResultRow
56
+ title="Resultado sin enlace"
57
+ urlLabel="ejemplo.com › ruta"
58
+ snippet="Este resultado no tiene href y muestra el título como span en lugar de enlace."
59
+ />
60
+ {:else}
61
+ <p class="mb-3 text-[11px] font-medium uppercase tracking-wide text-muted">Custom leading slot</p>
62
+ <div class="divide-y divide-border">
63
+ <SearchResultRow
64
+ title="Rafael González"
65
+ href="#"
66
+ urlLabel="linkedin.com › in › rafael-gonzalez"
67
+ snippet="Founder & Developer en R2 Digisolutions. Especializado en plataformas SaaS B2B."
68
+ >
69
+ {#snippet leading()}
70
+ <Avatar name="Rafael González" size="xs" ringed={false} />
71
+ {/snippet}
72
+ </SearchResultRow>
73
+ <SearchResultRow
74
+ title="María López"
75
+ href="#"
76
+ urlLabel="linkedin.com › in › maria-lopez"
77
+ snippet="Product Designer en Evoteg. Diseño de experiencias digitales para productos SaaS."
78
+ >
79
+ {#snippet leading()}
80
+ <Avatar name="María López" size="xs" ringed={false} />
81
+ {/snippet}
82
+ </SearchResultRow>
83
+ </div>
84
+ {/if}
85
+ </div>
@@ -0,0 +1,6 @@
1
+ interface Props {
2
+ example?: 'basic' | 'with-favicon' | 'no-href' | 'leading-slot';
3
+ }
4
+ declare const SearchResultRowStory: import("svelte").Component<Props, {}, "">;
5
+ type SearchResultRowStory = ReturnType<typeof SearchResultRowStory>;
6
+ export default SearchResultRowStory;