Enhancement: Add SvelteKit Integration — new wrapper component and demo page section

Aperta
#47 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

  • #123 di @Divine-P-77777 — chiusa senza merge

Valutazione

Difficoltà
3/5
Tempo stimato
1-2 giorni
Idoneità per principianti
68/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Tranquilla
Stack tecnologico
javascript, typescript

Direzione di ricerca

Inizia leggendo src/social-share-button-react.jsx e le sezioni di integrazione esistenti in index.html, quindi esamina l’elenco dei framework nel README. Crea il wrapper Svelte con i requisiti indicati per il ciclo di vita, SSR e gli aggiornamenti reattivi, aggiorna la demo e il README e verifica che i nuovi blocchi di codice includano pulsanti di copia e che tutti i criteri di accettazione siano soddisfatti.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

🎯 Direction

SocialShareButton is a lightweight, zero-dependency, framework-agnostic social sharing component. The goal of this issue is to extend first-class support to SvelteKit, which shares the same philosophy: minimal runtime overhead, compiles to pure JS. Since SvelteKit supports SSR (Server-Side Rendering), the wrapper must guard all browser APIs with typeof window !== 'undefined' checks.

📹 See the button in action: https://youtu.be/cLJaT-8rEvQ?si=CLipA0Db4WL0EqKM


📁 Files to Create / Modify

✅ New File: src/social-share-button-svelte.svelte

A Svelte component that wraps the core vanilla JS library, following the same pattern as src/social-share-button-react.jsx:

<script>
  import { onMount, onDestroy } from 'svelte';

  export let url = '';
  export let title = '';
  export let description = '';
  export let hashtags = [];
  export let via = '';
  export let platforms = ['whatsapp', 'facebook', 'twitter', 'linkedin', 'telegram', 'reddit'];
  export let theme = 'dark';
  export let buttonText = 'Share';
  export let customClass = '';
  export let onShare = null;
  export let onCopy = null;
  export let buttonStyle = 'default';
  export let modalPosition = 'center';

  let container;
  let shareButton;

  onMount(() => {
    // SSR guard — SvelteKit pre-renders on the server
    if (typeof window !== 'undefined' && window.SocialShareButton) {
      shareButton = new window.SocialShareButton({
        container,
        url: url || window.location.href,
        title: title || document.title,
        description,
        hashtags,
        via,
        platforms,
        theme,
        buttonText,
        customClass,
        onShare,
        onCopy,
        buttonStyle,
        modalPosition
      });
    }
  });

  onDestroy(() => {
    if (shareButton) {
      shareButton.destroy();
      shareButton = null;
    }
  });

  // Reactive update when props change (e.g. SvelteKit route transitions)
  $: if (shareButton) {
    shareButton.updateOptions({
      url, title, description, hashtags, via,
      platforms, theme, buttonText, customClass,
      onShare, onCopy, buttonStyle, modalPosition
    });
  }
</script>

<div bind:this={container}></div>

✅ Existing File: index.html — Add SvelteKit Integration Section

Mirror the existing ⚛️ React Integration section. Add a new section block with:

  • Section heading: 🟠 SvelteKit Integration
  • Step 1: Include CSS and JS via CDN (same as Quick Start)
  • Step 2: Import and use the SocialShareButton.svelte component
  • Step 3: Show usage inside a +page.svelte file with props

Example code snippet to display in the demo section:

<!-- +page.svelte -->
<script>
  import SocialShareButton from 'social-share-button-svelte';
<\/script>

<SocialShareButton
  url="https://your-website.com"
  title="Check this out!"
  description="An amazing website"
  theme="dark"
  buttonText="Share"
/>

✅ Acceptance Criteria

  • src/social-share-button-svelte.svelte created following the React wrapper pattern
  • SSR guard (typeof window !== 'undefined') present on all browser API usages
  • onMount used for initialization, onDestroy calls destroy() to prevent memory leaks
  • Reactive statement ($:) calls updateOptions() on prop changes
  • index.html updated with a SvelteKit section containing install + usage code snippets
  • Copy-to-clipboard button present on new code blocks in index.html
  • README updated to list SvelteKit as a supported framework
Lingua principale
TypeScript
Stelle
29
Fork
74
Merge medio
8h 52m
PR unite (30g)
4

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di AOSSIE-Org/SocialShareButton

Tutte le issue di AOSSIE-Org/SocialShareButton

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.