Skip to content

Added Qwiks/ QwikCity Integration — new wrapper component and demo pa…#120

Open
HackerAaditya wants to merge 2 commits intoAOSSIE-Org:mainfrom
HackerAaditya:Adding-Qwiks
Open

Added Qwiks/ QwikCity Integration — new wrapper component and demo pa…#120
HackerAaditya wants to merge 2 commits intoAOSSIE-Org:mainfrom
HackerAaditya:Adding-Qwiks

Conversation

@HackerAaditya
Copy link
Copy Markdown

@HackerAaditya HackerAaditya commented Mar 20, 2026

Addressed Issues:

Fixes #57
This PR adds Qwik support for the SocialShareButton component by introducing a lightweight wrapper compatible with Qwik's resumability model and SSR-first architecture.

Screenshots/Recordings:

Screenshot 2026-03-20 at 11 28 12 PM Screenshot 2026-03-20 at 11 29 05 PM Screenshot 2026-03-20 at 11 29 16 PM

Additional Notes:

  • Implemented a Qwik wrapper for SocialShareButton
  • Used useVisibleTask$ to ensure client-side execution only when needed
  • Guarded all browser-specific APIs to prevent SSR/runtime issues
  • Maintained zero-dependency and framework-agnostic design principles

Now we have qwik integration along with react js .

  • src/social-share-button-qwik.tsx created using useVisibleTask$ (Qwik's client-only hook)
  • cleanup() callback calls destroy() to prevent memory leaks
  • No browser APIs accessed outside useVisibleTask$
  • index.html updated with a Qwik section containing install + usage code snippets
  • Copy-to-clipboard button present on new code blocks in index.html
  • README updated to list Qwik as a supported framework

Checklist

  • My code follows the project's code style and conventions
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings or errors
  • I have joined the Discord server and I will share a link to this PR with the project maintainers there
  • I have read the Contributing Guidelines

⚠️ AI Notice - Important!

We encourage contributors to use AI tools responsibly when creating Pull Requests. While AI can be a valuable aid, it is essential to ensure that your contributions meet the task requirements, build successfully, include relevant tests, and pass all linters. Submissions that do not meet these standards may be closed without warning to maintain the quality and integrity of the project. Please take the time to understand the changes you are proposing and their impact. AI slop is strongly discouraged and may lead to banning and blocking. Do not spam our repos with AI slop.

Check one of the checkboxes below:

  • This PR does not contain AI-generated code at all.
  • This PR contains AI-generated code. I have read the AI Usage Policy and this PR complies with this policy. I have tested the code locally and I am responsible for it.

I have used the following AI models and tools: TODO

Summary by CodeRabbit

  • New Features

    • Added Qwik framework support with a new Qwik social sharing component
    • Introduced an interactive Qwik / QwikCity demo on the homepage
  • Documentation

    • Updated README features to list Qwik as a supported framework
  • Chores

    • Added Qwik dependency and TypeScript type definitions in project configuration

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 20, 2026

Walkthrough

Adds Qwik/QwikCity integration: new Qwik wrapper component that initializes the global SocialShareButton client-side via useVisibleTask$, updates README and index demo to mention Qwik, and adds @builder.io/qwik to package.json. Minor ESLint comment and CSS spacing tweak in index.html.

Changes

Cohort / File(s) Summary
Docs
README.md
Added Qwik to the "Framework support" list.
Config comments
eslint.config.js
Added two inline comments near existing rule blocks (no functional changes).
Dependencies
package.json
Added @builder.io/qwik to dependencies and @types/react to devDependencies.
Demo & Page
index.html
Inserted "Qwik / QwikCity Integration" demo section, example Qwik usage snippet, inline module script loading Qwik from CDN and instantiating window.SocialShareButton, added <!-- Badges --> comment, and removed extra space in gradient CSS.
Qwik wrapper
src/social-share-button-qwik.tsx
New exported SocialShareButton Qwik component using useSignal and useVisibleTask$ to lazily instantiate window.SocialShareButton with props and register cleanup(() => shareButton.destroy()); adds Props interface and a global Window augmentation.

Sequence Diagram(s)

sequenceDiagram
  participant SSR as Server-rendered page
  participant Browser as Browser (Client)
  participant QwikComp as SocialShareButton (Qwik component)
  participant Global as window.SocialShareButton (Global constructor)

  SSR->>Browser: Serve HTML with demo section and Qwik script
  Browser->>QwikComp: hydrate / mount (client)
  QwikComp->>QwikComp: useVisibleTask$ runs (client-only)
  QwikComp->>Global: check existence
  alt Global exists
    QwikComp->>Global: new SocialShareButton({container, options})
    Global-->>QwikComp: instance
    QwikComp-->>Browser: renders button UI into container
    Note right of QwikComp: cleanup registers destroy()
  else Global missing
    QwikComp-->>Browser: no-op (no instantiation)
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • Social share button #1 — Adds a Qwik wrapper component and demo integration using the same global SocialShareButton pattern.

Suggested labels

Typescript Lang, Documentation

Suggested reviewers

  • kpj2006
  • Zahnentferner

Poem

🐰
A tiny rabbit hops with delight,
Qwik blooms fast in morning light.
useVisibleTask$ wakes the scene,
Share buttons gleam — clean and keen! 🎉

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding Qwik/QwikCity integration with a new wrapper component and demo page updates, which aligns with the primary objectives of the changeset.
Linked Issues check ✅ Passed All coding requirements from issue #57 are met: Qwik wrapper component created using useVisibleTask$, cleanup() calls destroy(), no browser APIs outside client hook, index.html updated with Qwik section and copy buttons, README updated with Qwik framework support.
Out of Scope Changes check ✅ Passed All changes are directly aligned with issue #57 objectives. Minor additions like eslint.config.js comments and package.json formatting adjustments are consistent with supporting the Qwik integration implementation.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Tip

You can generate walkthrough in a markdown collapsible section to save space.

Enable the reviews.collapse_walkthrough setting to generate walkthrough in a markdown collapsible section.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 9

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
package.json (1)

6-13: ⚠️ Potential issue | 🟠 Major

New Qwik wrapper file missing from npm files array.

The new src/social-share-button-qwik.tsx file is not included in the files array, so it won't be published to npm. Users installing via npm won't be able to use the Qwik wrapper.

Based on learnings: new wrapper files added in a PR are not part of any CDN release until the next version tag is cut, and acquisition instructions should be provided for the new file itself.

🔧 Proposed fix
   "files": [
     "src/social-share-button.js",
     "src/social-share-button.css",
     "src/social-share-button-react.jsx",
+    "src/social-share-button-qwik.tsx",
     "src/social-share-analytics.js",
     "README.md",
     "LICENSE"
   ],
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@package.json` around lines 6 - 13, The package.json "files" array is missing
the new Qwik wrapper file; add "src/social-share-button-qwik.tsx" to the "files"
array so the new Qwik wrapper (src/social-share-button-qwik.tsx) is included in
npm publishes, and update any release/acquisition docs or README references to
note the new file name so consumers can install/use the Qwik wrapper after
publishing.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@index.html`:
- Around line 447-449: The empty <div class="demo-grid"> indicates an unfinished
demo area; either remove this container or populate it with a clear placeholder
message indicating the Qwik demo requires a Qwik app context (e.g., a short
explanatory paragraph or a link to the live demo) so users aren't shown an empty
block; update the HTML where the demo-grid element is defined (class
"demo-grid") to include the chosen placeholder or remove the element entirely.
- Line 452: The <button class="copy-btn" aria-label="Copy code"> element
defaults to type="submit", which can trigger form submission; update the element
referenced by class "copy-btn" (the Copy button) to include type="button" so it
does not submit forms accidentally, i.e., add the type="button" attribute to
that button element.
- Around line 470-487: The inline Qwik hook usage (useVisibleTask$, component$,
useSignal) is invalid at module scope and will throw at runtime; remove the
entire Qwik module script or replace it with a vanilla DOM-ready initializer
that uses window.SocialShareButton instead; if you choose the vanilla path,
ensure an actual container element with id "demo-qwik" is added to the demo grid
and instantiate SocialShareButton on DOMContentLoaded using the same options
(container '#demo-qwik', url, title, description, buttonText, theme) so the demo
works without a Qwik runtime.

In `@package.json`:
- Around line 51-53: The package currently lists "@builder.io/qwik" under
"dependencies" which forces consumers to install Qwik; move "@builder.io/qwik"
from the "dependencies" object into "peerDependencies" (and optionally add it to
"devDependencies" for local tests) so Qwik is optional for consumers while
preserving the project's zero-deps design; update the package.json entries
accordingly and run npm/yarn install to validate the change.
- Line 45: TypeScript is defaulting to React's JSX namespace due to the presence
of "@types/react", causing type conflicts in the Qwik component (e.g.,
social-share-button-qwik.tsx); add a tsconfig.json at the repository root with
compilerOptions that set "jsx" to "react-jsx" and "jsxImportSource" to
"@builder.io/qwik" so the Qwik JSX namespace is used for .tsx files, then commit
that tsconfig.json to the repo.

In `@README.md`:
- Line 76: Fix the missing space in the framework list string "⚛️ Framework
support: React, Next.js, Vue, Angular,Qwik or plain HTML" by adding a space
after the comma so it reads "Angular, Qwik"; update the README line that
contains that exact string to include the space.

In `@src/social-share-button-qwik.tsx`:
- Around line 40-48: The default platforms array in the Qwik wrapper is missing
'pinterest', causing inconsistency with the core SocialShareButton; update the
default value for props.platforms in src/social-share-button-qwik.tsx (the
object where platforms: props.platforms || [...]) to include 'pinterest'
alongside 'whatsapp','facebook','twitter','linkedin','telegram','reddit' so the
Qwik SocialShareButton mirrors the core SocialShareButton defaults.
- Around line 16-17: Props interface defines onShare and onCopy but those
callbacks aren't forwarded into the options for new window.SocialShareButton;
update the SocialShareButton instantiation to include onShare: props.onShare and
onCopy: props.onCopy (or the local variables holding those QRLs) in the options
object passed to the constructor so the SocialShareButton instance receives and
can invoke them.
- Around line 27-61: Add inline JSDoc-style comments above the SocialShareButton
component and inside the useVisibleTask$ callback: describe what the
SocialShareButton component does, list its Props (url, title, description,
hashtags, via, platforms, theme, buttonText, customClass, buttonStyle,
modalPosition) and its return value (a div container ref), and explain the
useVisibleTask$ logic (checks for window.SocialShareButton, initializes the
external widget via new window.SocialShareButton with the mapped props, and
registers cleanup by calling shareButton.destroy()). Also comment the container
signal (container: useSignal<HTMLDivElement | null>) to note why null is used
and its role as the widget mount point.

---

Outside diff comments:
In `@package.json`:
- Around line 6-13: The package.json "files" array is missing the new Qwik
wrapper file; add "src/social-share-button-qwik.tsx" to the "files" array so the
new Qwik wrapper (src/social-share-button-qwik.tsx) is included in npm
publishes, and update any release/acquisition docs or README references to note
the new file name so consumers can install/use the Qwik wrapper after
publishing.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 348d691d-3f9e-48ac-80df-b8a6c5ea1277

📥 Commits

Reviewing files that changed from the base of the PR and between 7ffef0f and cf28824.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (5)
  • README.md
  • eslint.config.js
  • index.html
  • package.json
  • src/social-share-button-qwik.tsx

Comment on lines +447 to +449
<div class="demo-grid">

</div>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Empty demo-grid suggests incomplete implementation.

The demo-grid div is empty. If a live Qwik demo isn't feasible on this static page, consider either removing the empty container or adding a placeholder explaining that the Qwik demo requires a Qwik application context.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@index.html` around lines 447 - 449, The empty <div class="demo-grid">
indicates an unfinished demo area; either remove this container or populate it
with a clear placeholder message indicating the Qwik demo requires a Qwik app
context (e.g., a short explanatory paragraph or a link to the live demo) so
users aren't shown an empty block; update the HTML where the demo-grid element
is defined (class "demo-grid") to include the chosen placeholder or remove the
element entirely.

</div>

<div class="code-block">
<button class="copy-btn" aria-label="Copy code">Copy</button>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Add type="button" to prevent accidental form submission.

Per HTMLHint: the type attribute should be present on <button> elements. Without it, buttons default to type="submit" which can cause unexpected form submissions.

🔧 Proposed fix
-    <button class="copy-btn" aria-label="Copy code">Copy</button>
+    <button type="button" class="copy-btn" aria-label="Copy code">Copy</button>
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<button class="copy-btn" aria-label="Copy code">Copy</button>
<button type="button" class="copy-btn" aria-label="Copy code">Copy</button>
🧰 Tools
🪛 HTMLHint (1.9.2)

[warning] 452-452: The type attribute must be present on elements.

(button-type-require)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@index.html` at line 452, The <button class="copy-btn" aria-label="Copy code">
element defaults to type="submit", which can trigger form submission; update the
element referenced by class "copy-btn" (the Copy button) to include
type="button" so it does not submit forms accidentally, i.e., add the
type="button" attribute to that button element.

Comment on lines +470 to +487
<!-- Load Qwik for the demo -->
<script type="module">
import { component$, useVisibleTask$, useSignal } from 'https://cdn.jsdelivr.net/npm/@builder.io/qwik@1.0.0/dist/qwik.mjs';
// Demo
useVisibleTask$(() => {
const container = document.querySelector('#demo-qwik');
if (container && window.SocialShareButton) {
new window.SocialShareButton({
container,
url: 'https://github.com/AOSSIE-Org/SocialShareButton',
title: 'SocialShareButton - Qwik Demo',
description: 'Demo of SocialShareButton in Qwik',
buttonText: 'Share',
theme: 'dark'
});
}
});
</script>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🔴 Critical

Broken Qwik demo script: useVisibleTask$ cannot be used outside a component.

The inline script attempts to call useVisibleTask$ at module scope, but Qwik hooks must be called inside a component$ function. This code will throw a runtime error. Additionally, the #demo-qwik container referenced doesn't exist in the HTML.

Since this is a demo page (not a real Qwik app), the Qwik framework hooks won't work without a full Qwik runtime setup. Consider either:

  1. Removing this script entirely since the code-block documentation above already shows proper usage.
  2. Adding a simple vanilla JS demo similar to other sections using DOMContentLoaded.
🔧 Proposed fix: Remove broken script or use vanilla JS

Option 1: Remove the broken script entirely

-<!-- Load Qwik for the demo -->
-<script type="module">
-  import { component$, useVisibleTask$, useSignal } from 'https://cdn.jsdelivr.net/npm/@builder.io/qwik@1.0.0/dist/qwik.mjs';
-  // Demo 
-  useVisibleTask$(() => {
-    const container = document.querySelector('#demo-qwik');
-    if (container && window.SocialShareButton) {
-      new window.SocialShareButton({
-        container,
-        url: 'https://github.com/AOSSIE-Org/SocialShareButton',
-        title: 'SocialShareButton - Qwik Demo',
-        description: 'Demo of SocialShareButton in Qwik',
-        buttonText: 'Share',
-        theme: 'dark'
-      });
-    }
-  });
-</script>

Option 2: If you want a live demo, add container and use vanilla JS

Add this to the demo-grid:

<div class="demo-item">
  <h3>Qwik Demo</h3>
  <p>SSR-safe integration</p>
  <div id="demo-qwik"></div>
</div>

Then in the existing DOMContentLoaded script block, add:

// Qwik Demo
new SocialShareButton({
  container: '#demo-qwik',
  url: demoUrl,
  title: demoTitle,
  description: demoDescription,
  buttonText: 'Share',
  theme: 'dark'
});
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
<!-- Load Qwik for the demo -->
<script type="module">
import { component$, useVisibleTask$, useSignal } from 'https://cdn.jsdelivr.net/npm/@builder.io/qwik@1.0.0/dist/qwik.mjs';
// Demo
useVisibleTask$(() => {
const container = document.querySelector('#demo-qwik');
if (container && window.SocialShareButton) {
new window.SocialShareButton({
container,
url: 'https://github.com/AOSSIE-Org/SocialShareButton',
title: 'SocialShareButton - Qwik Demo',
description: 'Demo of SocialShareButton in Qwik',
buttonText: 'Share',
theme: 'dark'
});
}
});
</script>
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@index.html` around lines 470 - 487, The inline Qwik hook usage
(useVisibleTask$, component$, useSignal) is invalid at module scope and will
throw at runtime; remove the entire Qwik module script or replace it with a
vanilla DOM-ready initializer that uses window.SocialShareButton instead; if you
choose the vanilla path, ensure an actual container element with id "demo-qwik"
is added to the demo grid and instantiate SocialShareButton on DOMContentLoaded
using the same options (container '#demo-qwik', url, title, description,
buttonText, theme) so the demo works without a Qwik runtime.

"homepage": "https://github.com/AOSSIE-Org/SocialShareButton#readme",
"devDependencies": {
"@eslint/js": "^9.39.4",
"@types/react": "^19.2.14",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🌐 Web query:

How to configure tsconfig.json for Qwik JSX with @builder.io/qwik``

💡 Result:

To configure tsconfig.json for Qwik JSX with @builder.io/qwik, use the standard TypeScript configuration from Qwik starter projects. The key settings for Qwik JSX support are "jsx": "react-jsx" and "jsxImportSource": "@builder.io/qwik". Example tsconfig.json: { "compilerOptions": { "target": "ES2022", "lib": ["es2022", "DOM", "DOM.Iterable"], "module": "ESNext", "moduleResolution": "bundler", "allowImportingTsExtensions": true, "verbatimModuleSyntax": true, "noEmit": true, "isolatedModules": true, "jsx": "react-jsx", "jsxImportSource": "@builder.io/qwik", "strict": true, "noUnusedLocals": true, "noUnusedParameters": true, "noFallthroughCasesInSwitch": true, "skipLibCheck": true, "baseUrl": ".", "paths": { "~/": ["./src/"] } }, "include": ["src//.ts", "src//.tsx", "src//.js", "src//.jsx"], "exclude": ["node_modules"] } This configuration enables Qwik's JSX transform via the react-jsx preset pointing to @builder.io/qwik. The Qwik Vite plugin handles the optimization and references tsconfig.json for linting/ESLint during development. Generate a new Qwik project with npm create qwik@latest to get the exact current starter tsconfig.json.

Citations:


🏁 Script executed:

# Check if tsconfig.json exists and read it
if [ -f "tsconfig.json" ]; then
  echo "=== tsconfig.json exists ==="
  cat -n tsconfig.json
else
  echo "=== tsconfig.json does NOT exist ==="
fi

Repository: AOSSIE-Org/SocialShareButton

Length of output: 108


🏁 Script executed:

# Read package.json to check dependencies and devDependencies
cat -n package.json | head -100

Repository: AOSSIE-Org/SocialShareButton

Length of output: 1868


🏁 Script executed:

# Search for JSX configuration in the codebase
rg "jsxImportSource|jsx.*react" --type ts --type tsx --type json

Repository: AOSSIE-Org/SocialShareButton

Length of output: 99


🏁 Script executed:

# Search for `@builder.io/qwik` imports and usage
rg "@builder.io/qwik|qwik" --type js --type jsx

Repository: AOSSIE-Org/SocialShareButton

Length of output: 99


🏁 Script executed:

# Check the React wrapper file
cat -n src/social-share-button-react.jsx

Repository: AOSSIE-Org/SocialShareButton

Length of output: 3967


🏁 Script executed:

# Look for all files that use JSX
fd "\.(jsx|tsx)$" src/

Repository: AOSSIE-Org/SocialShareButton

Length of output: 138


🏁 Script executed:

# Check the Qwik wrapper file
cat -n src/social-share-button-qwik.tsx

Repository: AOSSIE-Org/SocialShareButton

Length of output: 2249


🏁 Script executed:

# Search for `@builder.io/qwik` usage without relying on file type
rg "@builder.io/qwik|from.*qwik"

Repository: AOSSIE-Org/SocialShareButton

Length of output: 731


🏁 Script executed:

# Check if there's any TypeScript configuration elsewhere (tsconfig, tsc, build scripts)
rg "tsconfig|typescript" package.json

Repository: AOSSIE-Org/SocialShareButton

Length of output: 54


Add tsconfig.json to configure Qwik JSX namespace.

The project includes both @types/react and a Qwik wrapper file (src/social-share-button-qwik.tsx) that uses Qwik JSX. Without a tsconfig.json specifying the JSX configuration, TypeScript will default to React's JSX namespace, causing type conflicts in the .tsx file.

Create a tsconfig.json with:

{
  "compilerOptions": {
    "jsx": "react-jsx",
    "jsxImportSource": "@builder.io/qwik"
  }
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@package.json` at line 45, TypeScript is defaulting to React's JSX namespace
due to the presence of "@types/react", causing type conflicts in the Qwik
component (e.g., social-share-button-qwik.tsx); add a tsconfig.json at the
repository root with compilerOptions that set "jsx" to "react-jsx" and
"jsxImportSource" to "@builder.io/qwik" so the Qwik JSX namespace is used for
.tsx files, then commit that tsconfig.json to the repo.

Comment on lines +51 to +53
"dependencies": {
"@builder.io/qwik": "^1.19.2"
}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Runtime dependency contradicts "Zero Dependencies" design goal.

Adding @builder.io/qwik as a runtime dependency means all users of this package will install Qwik, even if they don't use the Qwik wrapper. This contradicts the project's core "Zero Dependencies" value proposition shown in the README badges.

The Qwik package should be a peerDependency instead, making it optional for consumers who want Qwik support while keeping the library dependency-free for vanilla JS, React, and Vue users.

🔧 Proposed fix: Move to peerDependencies
-  "dependencies": {
-    "@builder.io/qwik": "^1.19.2"
-  }
+  "peerDependencies": {
+    "@builder.io/qwik": "^1.19.2"
+  },
+  "peerDependenciesMeta": {
+    "@builder.io/qwik": {
+      "optional": true
+    }
+  }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"dependencies": {
"@builder.io/qwik": "^1.19.2"
}
"peerDependencies": {
"@builder.io/qwik": "^1.19.2"
},
"peerDependenciesMeta": {
"@builder.io/qwik": {
"optional": true
}
}
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@package.json` around lines 51 - 53, The package currently lists
"@builder.io/qwik" under "dependencies" which forces consumers to install Qwik;
move "@builder.io/qwik" from the "dependencies" object into "peerDependencies"
(and optionally add it to "devDependencies" for local tests) so Qwik is optional
for consumers while preserving the project's zero-deps design; update the
package.json entries accordingly and run npm/yarn install to validate the
change.

Comment on lines +16 to +17
onShare?: QRL<() => void>;
onCopy?: QRL<() => void>;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

onShare and onCopy callbacks are defined but never passed to the constructor.

The Props interface accepts onShare and onCopy callbacks (lines 16-17), but they are not included in the options object passed to new window.SocialShareButton() (lines 33-54). Users expecting these callbacks to work will experience silent failures.

🔧 Proposed fix: Wire callbacks to constructor
       const shareButton = new window.SocialShareButton({
         container: container.value,
         url: props.url || window.location.href,
         title: props.title || document.title,
         description: props.description || '',
         hashtags: props.hashtags || [],
         via: props.via || '',
         platforms:
           props.platforms || [
             'whatsapp',
             'facebook',
             'twitter',
             'linkedin',
             'telegram',
             'reddit',
+            'pinterest',
           ],
         theme: props.theme || 'dark',
         buttonText: props.buttonText || 'Share',
         customClass: props.customClass || '',
         buttonStyle: props.buttonStyle || 'default',
         modalPosition: props.modalPosition || 'center',
+        onShare: props.onShare,
+        onCopy: props.onCopy,
       });

Also applies to: 31-54

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/social-share-button-qwik.tsx` around lines 16 - 17, Props interface
defines onShare and onCopy but those callbacks aren't forwarded into the options
for new window.SocialShareButton; update the SocialShareButton instantiation to
include onShare: props.onShare and onCopy: props.onCopy (or the local variables
holding those QRLs) in the options object passed to the constructor so the
SocialShareButton instance receives and can invoke them.

Comment on lines +27 to +61
export const SocialShareButton = component$<Props>((props) => {
// Use null instead of undefined to satisfy ref typing
const container = useSignal<HTMLDivElement | null>(null);

useVisibleTask$(({ cleanup }) => {
if (typeof window !== 'undefined' && window.SocialShareButton && container.value) {
const shareButton = new window.SocialShareButton({
container: container.value,
url: props.url || window.location.href,
title: props.title || document.title,
description: props.description || '',
hashtags: props.hashtags || [],
via: props.via || '',
platforms:
props.platforms || [
'whatsapp',
'facebook',
'twitter',
'linkedin',
'telegram',
'reddit',
],
theme: props.theme || 'dark',
buttonText: props.buttonText || 'Share',
customClass: props.customClass || '',
buttonStyle: props.buttonStyle || 'default',
modalPosition: props.modalPosition || 'center',
});

cleanup(() => shareButton.destroy());
}
});

return <div ref={container}></div>;
}); No newline at end of file
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

Add inline comments to the component and task function.

Per repository guidelines, library source files should have proper inline comments explaining what functions do, why they exist, and their parameters/return values.

📝 Proposed documentation improvements
+/**
+ * Qwik wrapper component for SocialShareButton.
+ * Initializes the vanilla SocialShareButton library only on the client side
+ * using useVisibleTask$ to remain SSR-safe and compatible with Qwik's resumability model.
+ *
+ * `@param` props - Configuration options for the share button (url, title, theme, etc.)
+ * `@returns` A div element that serves as the container for the share button
+ */
 export const SocialShareButton = component$<Props>((props) => {
-  // Use null instead of undefined to satisfy ref typing
+  // Container ref - initialized to null, populated when div mounts
   const container = useSignal<HTMLDivElement | null>(null);

+  // useVisibleTask$ runs only on the client when the component becomes visible,
+  // ensuring browser APIs (window, document) are safely accessible
   useVisibleTask$(({ cleanup }) => {
     if (typeof window !== 'undefined' && window.SocialShareButton && container.value) {
       const shareButton = new window.SocialShareButton({
         // ... options
       });

+      // Register cleanup to destroy the instance and prevent memory leaks
+      // when the component unmounts or the task re-runs
       cleanup(() => shareButton.destroy());
     }
   });

   return <div ref={container}></div>;
 });

Based on learnings: flag any newly added or modified function that lacks a descriptive comment explaining what it does, why it exists, and its parameters/return values.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
export const SocialShareButton = component$<Props>((props) => {
// Use null instead of undefined to satisfy ref typing
const container = useSignal<HTMLDivElement | null>(null);
useVisibleTask$(({ cleanup }) => {
if (typeof window !== 'undefined' && window.SocialShareButton && container.value) {
const shareButton = new window.SocialShareButton({
container: container.value,
url: props.url || window.location.href,
title: props.title || document.title,
description: props.description || '',
hashtags: props.hashtags || [],
via: props.via || '',
platforms:
props.platforms || [
'whatsapp',
'facebook',
'twitter',
'linkedin',
'telegram',
'reddit',
],
theme: props.theme || 'dark',
buttonText: props.buttonText || 'Share',
customClass: props.customClass || '',
buttonStyle: props.buttonStyle || 'default',
modalPosition: props.modalPosition || 'center',
});
cleanup(() => shareButton.destroy());
}
});
return <div ref={container}></div>;
});
/**
* Qwik wrapper component for SocialShareButton.
* Initializes the vanilla SocialShareButton library only on the client side
* using useVisibleTask$ to remain SSR-safe and compatible with Qwik's resumability model.
*
* `@param` props - Configuration options for the share button (url, title, theme, etc.)
* `@returns` A div element that serves as the container for the share button
*/
export const SocialShareButton = component$<Props>((props) => {
// Container ref - initialized to null, populated when div mounts
const container = useSignal<HTMLDivElement | null>(null);
// useVisibleTask$ runs only on the client when the component becomes visible,
// ensuring browser APIs (window, document) are safely accessible
useVisibleTask$(({ cleanup }) => {
if (typeof window !== 'undefined' && window.SocialShareButton && container.value) {
const shareButton = new window.SocialShareButton({
container: container.value,
url: props.url || window.location.href,
title: props.title || document.title,
description: props.description || '',
hashtags: props.hashtags || [],
via: props.via || '',
platforms:
props.platforms || [
'whatsapp',
'facebook',
'twitter',
'linkedin',
'telegram',
'reddit',
],
theme: props.theme || 'dark',
buttonText: props.buttonText || 'Share',
customClass: props.customClass || '',
buttonStyle: props.buttonStyle || 'default',
modalPosition: props.modalPosition || 'center',
});
// Register cleanup to destroy the instance and prevent memory leaks
// when the component unmounts or the task re-runs
cleanup(() => shareButton.destroy());
}
});
return <div ref={container}></div>;
});
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/social-share-button-qwik.tsx` around lines 27 - 61, Add inline
JSDoc-style comments above the SocialShareButton component and inside the
useVisibleTask$ callback: describe what the SocialShareButton component does,
list its Props (url, title, description, hashtags, via, platforms, theme,
buttonText, customClass, buttonStyle, modalPosition) and its return value (a div
container ref), and explain the useVisibleTask$ logic (checks for
window.SocialShareButton, initializes the external widget via new
window.SocialShareButton with the mapped props, and registers cleanup by calling
shareButton.destroy()). Also comment the container signal (container:
useSignal<HTMLDivElement | null>) to note why null is used and its role as the
widget mount point.

Comment on lines +40 to +48
platforms:
props.platforms || [
'whatsapp',
'facebook',
'twitter',
'linkedin',
'telegram',
'reddit',
],
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Default platforms list is missing 'pinterest' compared to core library.

The core SocialShareButton constructor (in src/social-share-button.js) includes 'pinterest' in the default platforms array, but this Qwik wrapper omits it. This creates an inconsistent experience between vanilla JS and Qwik users.

🔧 Proposed fix
         platforms:
           props.platforms || [
             'whatsapp',
             'facebook',
             'twitter',
             'linkedin',
             'telegram',
             'reddit',
+            'pinterest',
           ],
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
platforms:
props.platforms || [
'whatsapp',
'facebook',
'twitter',
'linkedin',
'telegram',
'reddit',
],
platforms:
props.platforms || [
'whatsapp',
'facebook',
'twitter',
'linkedin',
'telegram',
'reddit',
'pinterest',
],
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/social-share-button-qwik.tsx` around lines 40 - 48, The default platforms
array in the Qwik wrapper is missing 'pinterest', causing inconsistency with the
core SocialShareButton; update the default value for props.platforms in
src/social-share-button-qwik.tsx (the object where platforms: props.platforms ||
[...]) to include 'pinterest' alongside
'whatsapp','facebook','twitter','linkedin','telegram','reddit' so the Qwik
SocialShareButton mirrors the core SocialShareButton defaults.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

♻️ Duplicate comments (2)
index.html (2)

474-491: ⚠️ Potential issue | 🔴 Critical

Remove the top-level Qwik hook demo; it cannot run in a plain index.html.

useVisibleTask$ must run inside a component$, so calling it at module scope will throw before any demo renders. This block also targets #demo-qwik, but the section above never creates that container. For this static page, either drop the live Qwik script entirely or replace it with a vanilla SocialShareButton initializer against a real demo container. The CDN pin (1.0.0) is also out of sync with the repo's declared @builder.io/qwik version (^1.19.2).

Qwik docs: can `useVisibleTask$` be called at module scope outside `component$`, and is loading `@builder.io/qwik@1.0.0` from a CDN consistent with a project dependency of `@builder.io/qwik@^1.19.2`?
🧹 Safer immediate fix
-<!-- Load Qwik for the demo -->
-<script type="module">
-  import { component$, useVisibleTask$, useSignal } from 'https://cdn.jsdelivr.net/npm/@builder.io/qwik@1.0.0/dist/qwik.mjs';
-  // Demo 
-  useVisibleTask$(() => {
-    const container = document.querySelector('#demo-qwik');
-    if (container && window.SocialShareButton) {
-      new window.SocialShareButton({
-        container,
-        url: 'https://github.com/AOSSIE-Org/SocialShareButton',
-        title: 'SocialShareButton - Qwik Demo',
-        description: 'Demo of SocialShareButton in Qwik',
-        buttonText: 'Share',
-        theme: 'dark'
-      });
-    }
-  });
-</script>
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@index.html` around lines 474 - 491, The Qwik demo uses useVisibleTask$ at
module scope which is invalid and will throw; remove or relocate this demo code:
either delete the top-level import and useVisibleTask$ block, or wrap the logic
inside a proper component$ (using component$ and calling useVisibleTask$ inside
it) and ensure the demo actually creates a container with id '#demo-qwik' before
instantiating new window.SocialShareButton; also update the CDN import to match
the project's Qwik version (replace the hard-coded '@builder.io/qwik@1.0.0'
import with a matching version or remove the CDN import and use a vanilla
initializer for SocialShareButton if you want a plain index.html demo).

456-456: ⚠️ Potential issue | 🟡 Minor

Set type="button" on the new copy button.

Without it, this element defaults to submit, which is the HTML lint warning already reported here and can cause accidental form submission if this block is ever embedded in a form.

🔧 Proposed fix
-    <button class="copy-btn" aria-label="Copy code">Copy</button>
+    <button type="button" class="copy-btn" aria-label="Copy code">Copy</button>
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@index.html` at line 456, The copy button element (class "copy-btn") lacks an
explicit type, causing it to default to "submit" and risk accidental form
submissions; update the <button class="copy-btn" ...> markup to include
type="button" so the element will act as a non-submitting control (locate the
button with class "copy-btn" and add the type attribute).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@index.html`:
- Around line 446-453: Add a Step 1 after the intro paragraph in the Qwik
Integration demo that explains how to acquire the Qwik wrapper: state whether to
copy the new source file src/social-share-button-qwik.tsx into their project,
install a forthcoming npm package, or wait for the next release; specifically
reference the import path ~/components/social-share-button-qwik so readers know
where to place or import the file, and clearly indicate which option is current
(e.g., "copy file from repo" if not yet published) and any command or path they
should use.

---

Duplicate comments:
In `@index.html`:
- Around line 474-491: The Qwik demo uses useVisibleTask$ at module scope which
is invalid and will throw; remove or relocate this demo code: either delete the
top-level import and useVisibleTask$ block, or wrap the logic inside a proper
component$ (using component$ and calling useVisibleTask$ inside it) and ensure
the demo actually creates a container with id '#demo-qwik' before instantiating
new window.SocialShareButton; also update the CDN import to match the project's
Qwik version (replace the hard-coded '@builder.io/qwik@1.0.0' import with a
matching version or remove the CDN import and use a vanilla initializer for
SocialShareButton if you want a plain index.html demo).
- Line 456: The copy button element (class "copy-btn") lacks an explicit type,
causing it to default to "submit" and risk accidental form submissions; update
the <button class="copy-btn" ...> markup to include type="button" so the element
will act as a non-submitting control (locate the button with class "copy-btn"
and add the type attribute).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 457dbc44-cf30-4f5d-b3e0-7ad1ea68ac19

📥 Commits

Reviewing files that changed from the base of the PR and between cf28824 and 367f6f7.

📒 Files selected for processing (2)
  • README.md
  • index.html

Comment on lines +446 to +453
<!-- Qwik Integration Demo Section -->
<div class="demo-section" >
<h2>⚡ Qwik / QwikCity Integration</h2>
<p>Use SocialShareButton with the Qwik framework, fully SSR-safe and client-only.</p>

<div class="demo-grid">

</div>
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Add the missing acquisition step for the Qwik wrapper.

After the intro paragraph, this section only leaves an empty placeholder before the usage snippet, so readers still are not told how ~/components/social-share-button-qwik gets into their app. Because the existing CDN examples in this repo predate this new wrapper, the Qwik guide is not actionable yet. Please add a Step 1 that explicitly tells users whether to copy src/social-share-button-qwik.tsx, install it from npm, or wait for the next tagged release.

Based on learnings: new wrapper files added in a PR are not part of any CDN release until the next version tag is cut, so docs need an explicit acquisition path for the new file.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@index.html` around lines 446 - 453, Add a Step 1 after the intro paragraph in
the Qwik Integration demo that explains how to acquire the Qwik wrapper: state
whether to copy the new source file src/social-share-button-qwik.tsx into their
project, install a forthcoming npm package, or wait for the next release;
specifically reference the import path ~/components/social-share-button-qwik so
readers know where to place or import the file, and clearly indicate which
option is current (e.g., "copy file from repo" if not yet published) and any
command or path they should use.

@HackerAaditya
Copy link
Copy Markdown
Author

Thanks you for your feedback . I will update everything within 2 days

@github-actions
Copy link
Copy Markdown

⚠️ This PR has merge conflicts.

Please resolve the merge conflicts before review.

Your PR will only be reviewed by a maintainer after all conflicts have been resolved.

📺 Watch this video to understand why conflicts occur and how to resolve them:
https://www.youtube.com/watch?v=Sqsz1-o7nXk

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Enhancement: Add Qwik / QwikCity Integration — new wrapper component and demo page section

1 participant