Enhancement: Add Remix Integration — demo page section and SSR-safe usage guide

Aperta
#55 1 commento 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

  • #110 di @Muneerali199 — chiusa senza merge

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Funzionalità
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
javascript, react

Direzione di ricerca

Inizia dalla struttura dei componenti esistente ed esamina src/social-share-button-remix.jsx, quindi consulta index.html e README per i pattern di integrazione e documentazione circostanti. Il lavoro è completato quando il componente Remix, il comportamento del ciclo di vita sicuro per SSR, i controlli per copiare i blocchi di codice, la sezione di integrazione e la voce relativa al framework supportato corrispondono ai criteri di accettazione elencati; discuti prima l’ambito previsto con i maintainer.

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

Descrizione

planned

🎯 Direction

SocialShareButton is a lightweight, zero-dependency, framework-agnostic social sharing component. Remix is a full-stack React framework built on web standards with a strong SSR-first model. Since Remix always server-renders, the library must only initialize inside a useEffect hook and all browser APIs must be guarded. Unlike Next.js App Router, Remix has no 'use client' directive — client-side code runs exclusively inside useEffect.

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


📁 Files to Create / Modify

✅ New File: src/social-share-button-remix.jsx

A Remix-compatible React component that safely wraps the vanilla JS library:

import { useEffect, useRef } from 'react';

export default function SocialShareButton({
  url = '',
  title = '',
  description = '',
  hashtags = [],
  via = '',
  platforms = ['whatsapp', 'facebook', 'twitter', 'linkedin', 'telegram', 'reddit'],
  theme = 'dark',
  buttonText = 'Share',
  customClass = '',
  onShare = null,
  onCopy = null,
  buttonStyle = 'default',
  modalPosition = 'center'
}) {
  const containerRef = useRef(null);
  const shareButtonRef = useRef(null);

  useEffect(() => {
    // SSR guard — Remix always server-renders; browser APIs only available here
    if (typeof window !== 'undefined' && window.SocialShareButton) {
      shareButtonRef.current = new window.SocialShareButton({
        container: containerRef.current,
        url:   url   || window.location.href,
        title: title || document.title,
        description, hashtags, via, platforms,
        theme, buttonText, customClass,
        onShare, onCopy, buttonStyle, modalPosition
      });
    }
    return () => {
      if (shareButtonRef.current) {
        shareButtonRef.current.destroy();
        shareButtonRef.current = null;
      }
    };
  }, []);

  useEffect(() => {
    if (shareButtonRef.current) {
      shareButtonRef.current.updateOptions({
        url, title, description, hashtags, via, platforms,
        theme, buttonText, customClass, onShare, onCopy,
        buttonStyle, modalPosition
      });
    }
  }, [url, title, description, hashtags, via, platforms,
      theme, buttonText, customClass, onShare, onCopy,
      buttonStyle, modalPosition]);

  return <div ref={containerRef}></div>;
}

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

Add a new section with:

  • Section heading: 🎸 Remix Integration
  • Step 1: Include CSS via links export and JS via CDN <script> in root.tsx
  • Step 2: Import and use the component in a Remix route

Example code snippet to display:

// app/routes/_index.tsx
import SocialShareButton from '~/components/social-share-button-remix';

export default function Index() {
  return (
    <SocialShareButton
      url="https://your-website.com"
      title="Check this out!"
      description="An amazing website"
      theme="dark"
      buttonText="Share"
    />
  );
}

✅ Acceptance Criteria

  • src/social-share-button-remix.jsx created using React hooks compatible with Remix
  • Initialization inside useEffect with SSR guard (typeof window !== 'undefined')
  • Cleanup destroy() called in useEffect return function
  • Second useEffect calls updateOptions() on prop changes
  • index.html updated with a Remix section containing install + usage code snippets
  • Copy-to-clipboard button present on new code blocks in index.html
  • README updated to list Remix as a supported framework

⚠️ Planned — Not Final
This issue represents a planned enhancement and is not guaranteed to be implemented. It may be dropped if it does not align with the repository's direction. Before opening a pull request, please discuss with the maintainers in this issue thread.

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.