Skip to content

Commit 8525ba5

Browse files
authored
feat(landing): add Share chip to integration and model pages (#5582)
- add a Share chip (copy link / X / LinkedIn) to integration and model detail pages, matching the bordered secondary-pill chip already used for View docs / All {provider} models - rework ShareButton to render as a Chip everywhere (blog, library, integrations, models) instead of a bespoke muted-text trigger, and switch its copy-link state to the shared useCopyToClipboard hook
1 parent 7962236 commit 8525ba5

3 files changed

Lines changed: 19 additions & 22 deletions

File tree

apps/sim/app/(landing)/components/share-button/share-button.tsx

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,14 @@
11
'use client'
22

3-
import { useState } from 'react'
4-
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from '@sim/emcn'
3+
import {
4+
Chip,
5+
DropdownMenu,
6+
DropdownMenuContent,
7+
DropdownMenuItem,
8+
DropdownMenuTrigger,
9+
TRIGGER_BORDER_CLASS,
10+
useCopyToClipboard,
11+
} from '@sim/emcn'
512
import { Duplicate } from '@sim/emcn/icons'
613
import { Share2 } from 'lucide-react'
714
import { LinkedInIcon, xIcon as XIcon } from '@/components/icons'
@@ -11,18 +18,9 @@ interface ShareButtonProps {
1118
title: string
1219
}
1320

21+
/** Bordered `Chip` trigger with a copy-link / X / LinkedIn share menu — the one Share control used across blog, library, integration, and model pages. */
1422
export function ShareButton({ url, title }: ShareButtonProps) {
15-
const [copied, setCopied] = useState(false)
16-
17-
const handleCopyLink = async () => {
18-
try {
19-
await navigator.clipboard.writeText(url)
20-
setCopied(true)
21-
setTimeout(() => setCopied(false), 1500)
22-
} catch {
23-
/* clipboard unavailable */
24-
}
25-
}
23+
const { copied, copy } = useCopyToClipboard({ resetMs: 1500 })
2624

2725
const handleShareTwitter = () => {
2826
const tweetUrl = `https://twitter.com/intent/tweet?url=${encodeURIComponent(url)}&text=${encodeURIComponent(title)}`
@@ -37,17 +35,12 @@ export function ShareButton({ url, title }: ShareButtonProps) {
3735
return (
3836
<DropdownMenu>
3937
<DropdownMenuTrigger asChild>
40-
<button
41-
type='button'
42-
className='flex items-center gap-1.5 text-[var(--text-muted)] text-sm hover:text-[var(--text-primary)]'
43-
aria-label='Share this post'
44-
>
45-
<Share2 className='size-4' />
46-
<span>Share</span>
47-
</button>
38+
<Chip leftIcon={Share2} className={TRIGGER_BORDER_CLASS} aria-label='Share this page'>
39+
Share
40+
</Chip>
4841
</DropdownMenuTrigger>
4942
<DropdownMenuContent align='end'>
50-
<DropdownMenuItem onSelect={handleCopyLink}>
43+
<DropdownMenuItem onSelect={() => copy(url)}>
5144
<Duplicate className='size-4' />
5245
{copied ? 'Copied!' : 'Copy link'}
5346
</DropdownMenuItem>

apps/sim/app/(landing)/integrations/(shell)/[slug]/page.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ import {
1717
import { BackLink } from '@/app/(landing)/components'
1818
import { JsonLd } from '@/app/(landing)/components/json-ld'
1919
import { LandingFAQ } from '@/app/(landing)/components/landing-faq'
20+
import { ShareButton } from '@/app/(landing)/components/share-button'
2021
import { IntegrationCtaButton } from '@/app/(landing)/integrations/(shell)/[slug]/components/integration-cta-button'
2122
import { TemplateCardButton } from '@/app/(landing)/integrations/(shell)/[slug]/components/template-card-button'
2223
import { IntegrationIcon } from '@/app/(landing)/integrations/components/integration-icon'
@@ -494,6 +495,7 @@ export default async function IntegrationPage({ params }: { params: Promise<{ sl
494495
>
495496
View docs
496497
</ChipLink>
498+
<ShareButton url={`${baseUrl}/integrations/${slug}`} title={`${name} Integration`} />
497499
</div>
498500

499501
<p className='mt-5 text-[var(--text-muted)] text-xs'>

apps/sim/app/(landing)/models/(shell)/[provider]/[model]/page.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { SITE_URL } from '@/lib/core/utils/urls'
55
import { BackLink } from '@/app/(landing)/components'
66
import { JsonLd } from '@/app/(landing)/components/json-ld'
77
import { LandingFAQ } from '@/app/(landing)/components/landing-faq'
8+
import { ShareButton } from '@/app/(landing)/components/share-button'
89
import { FeaturedModelCard, ProviderIcon } from '@/app/(landing)/models/components/model-primitives'
910
import {
1011
ALL_CATALOG_MODELS,
@@ -181,6 +182,7 @@ export default async function ModelPage({
181182
<ChipLink href={provider.href} className='border border-[var(--border-1)]'>
182183
All {provider.name} models
183184
</ChipLink>
185+
<ShareButton url={`${baseUrl}${model.href}`} title={model.displayName} />
184186
</div>
185187
</div>
186188

0 commit comments

Comments
 (0)