Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 15 additions & 22 deletions apps/sim/app/(landing)/components/share-button/share-button.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
'use client'

import { useState } from 'react'
import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from '@sim/emcn'
import {
Chip,
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuTrigger,
TRIGGER_BORDER_CLASS,
useCopyToClipboard,
} from '@sim/emcn'
import { Duplicate } from '@sim/emcn/icons'
import { Share2 } from 'lucide-react'
import { LinkedInIcon, xIcon as XIcon } from '@/components/icons'
Expand All @@ -11,18 +18,9 @@ interface ShareButtonProps {
title: string
}

/** Bordered `Chip` trigger with a copy-link / X / LinkedIn share menu — the one Share control used across blog, library, integration, and model pages. */
export function ShareButton({ url, title }: ShareButtonProps) {
const [copied, setCopied] = useState(false)

const handleCopyLink = async () => {
try {
await navigator.clipboard.writeText(url)
setCopied(true)
setTimeout(() => setCopied(false), 1500)
} catch {
/* clipboard unavailable */
}
}
const { copied, copy } = useCopyToClipboard({ resetMs: 1500 })

const handleShareTwitter = () => {
const tweetUrl = `https://twitter.com/intent/tweet?url=${encodeURIComponent(url)}&text=${encodeURIComponent(title)}`
Expand All @@ -37,17 +35,12 @@ export function ShareButton({ url, title }: ShareButtonProps) {
return (
<DropdownMenu>
<DropdownMenuTrigger asChild>
<button
type='button'
className='flex items-center gap-1.5 text-[var(--text-muted)] text-sm hover:text-[var(--text-primary)]'
aria-label='Share this post'
>
<Share2 className='size-4' />
<span>Share</span>
</button>
<Chip leftIcon={Share2} className={TRIGGER_BORDER_CLASS} aria-label='Share this page'>
Share
</Chip>
</DropdownMenuTrigger>
<DropdownMenuContent align='end'>
<DropdownMenuItem onSelect={handleCopyLink}>
<DropdownMenuItem onSelect={() => copy(url)}>
<Duplicate className='size-4' />
{copied ? 'Copied!' : 'Copy link'}
</DropdownMenuItem>
Expand Down
2 changes: 2 additions & 0 deletions apps/sim/app/(landing)/integrations/(shell)/[slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
import { BackLink } from '@/app/(landing)/components'
import { JsonLd } from '@/app/(landing)/components/json-ld'
import { LandingFAQ } from '@/app/(landing)/components/landing-faq'
import { ShareButton } from '@/app/(landing)/components/share-button'
import { IntegrationCtaButton } from '@/app/(landing)/integrations/(shell)/[slug]/components/integration-cta-button'
import { TemplateCardButton } from '@/app/(landing)/integrations/(shell)/[slug]/components/template-card-button'
import { IntegrationIcon } from '@/app/(landing)/integrations/components/integration-icon'
Expand Down Expand Up @@ -494,6 +495,7 @@ export default async function IntegrationPage({ params }: { params: Promise<{ sl
>
View docs
</ChipLink>
<ShareButton url={`${baseUrl}/integrations/${slug}`} title={`${name} Integration`} />
</div>

<p className='mt-5 text-[var(--text-muted)] text-xs'>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { SITE_URL } from '@/lib/core/utils/urls'
import { BackLink } from '@/app/(landing)/components'
import { JsonLd } from '@/app/(landing)/components/json-ld'
import { LandingFAQ } from '@/app/(landing)/components/landing-faq'
import { ShareButton } from '@/app/(landing)/components/share-button'
import { FeaturedModelCard, ProviderIcon } from '@/app/(landing)/models/components/model-primitives'
import {
ALL_CATALOG_MODELS,
Expand Down Expand Up @@ -181,6 +182,7 @@ export default async function ModelPage({
<ChipLink href={provider.href} className='border border-[var(--border-1)]'>
All {provider.name} models
</ChipLink>
<ShareButton url={`${baseUrl}${model.href}`} title={model.displayName} />
</div>
</div>

Expand Down
Loading