Skip to content

feat: Add Auto System Theme detection and Floating Share Bar.#152

Open
sejalkutriyar wants to merge 3 commits into
AOSSIE-Org:mainfrom
sejalkutriyar:feature-advanced-ui
Open

feat: Add Auto System Theme detection and Floating Share Bar.#152
sejalkutriyar wants to merge 3 commits into
AOSSIE-Org:mainfrom
sejalkutriyar:feature-advanced-ui

Conversation

@sejalkutriyar
Copy link
Copy Markdown

@sejalkutriyar sejalkutriyar commented Apr 23, 2026

Addressed Issues:

This PR introduces two highly requested UX feature enhancements to standard share buttons without adding any external dependencies: Auto OS-level Theme Detection and an option for a Floating Action Share Bar. It also replaces the previous closed PR (#140).

Key Changes

  • System Auto Theme: Added a theme: 'auto' capability that detects user OS preference (Light/Dark mode) using window.matchMedia('(prefers-color-scheme: light)') and auto-adapts the modal UI class. It seamlessly listens for live OS preference changes while keeping the modal reactive.
  • Floating Share Bar: Added displayMode: 'floating' alongside the standard inline configuration. When enabled, the button creates its own wrapper appended directly to document.body with position: fixed and gracefully floats in corners based on floatingPosition.
  • Addressed CodeRabbit Feedback:
    • Formatted the Advanced Features code block in index.html to be multi-line and easily readable.
    • Moved the Framework integration sections (Qwik, Next.js, Vue, Angular) inside the .container wrapper to fix the broken layout.
    • Escaped the unescaped > character in the Qwik code block.
    • Removed duplicate CTA sections.
    • Added transform-origin properties for top-right and top-left floating modes in mobile media queries.
    • Added detailed inline comments for the auto-theme detection logic.

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

Summary by CodeRabbit

  • New Features

    • Added auto theme support that adapts to system preferences
    • Introduced floating share bar positioned in corners (bottom-right, bottom-left, top-right, top-left)
    • Added demo examples showcasing new advanced features and theme modes
  • Style

    • Updated roadmap formatting and markdown presentation
    • Normalized whitespace and formatting across configuration and documentation files
  • Chores

    • Restructured ESLint configuration for improved clarity

@github-actions github-actions Bot added configuration Configuration file changes documentation Changes to documentation files labels Apr 23, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 23, 2026

Warning

Rate limit exceeded

@sejalkutriyar has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 51 minutes and 13 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 51 minutes and 13 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro

Run ID: 5ddb46e4-4aba-402c-a44b-c2f0ab2ad743

📥 Commits

Reviewing files that changed from the base of the PR and between c4fd339 and 0221a97.

📒 Files selected for processing (3)
  • docs/Roadmap.md
  • index.html
  • src/social-share-button.js

Walkthrough

The PR adds floating display mode and auto theme detection to the social share button component, alongside extensive formatting and whitespace normalization across documentation, configuration, and source files. New CSS styles support floating wrapper positioning; JavaScript enhancements enable displayMode: 'floating' with configurable positioning and theme: 'auto' with OS-level detection; ESLint config restructuring moves globals under languageOptions; HTML demo showcases new features with example instances.

Changes

Cohort / File(s) Summary
Documentation & Markdown
CONTRIBUTING.md, README.md, docs/Roadmap.md, landing-page/README.md
Whitespace normalization and blank-line adjustments; code snippet formatting in Roadmap (quote style, trailing commas, CSS value spacing); no content or logic changes.
ESLint Configuration
eslint.config.js
Restructured globals configuration to nest under languageOptions with correct indentation; removed trailing whitespace in header and rules section.
CSS Styling
src/social-share-button.css, landing-page/src/app/globals.css
Added new .social-share-floating-wrapper class with positioning variants (bottom-right, bottom-left, top-right, top-left) supporting fixed positioning, transitions, and responsive scaling; normalized whitespace in existing hover and SVG rules.
Core Component Logic
src/social-share-button.js, src/social-share-analytics.js
Added displayMode and floatingPosition options for floating UI; implemented auto theme detection via matchMedia with listener registration for OS theme changes; enhanced createModal() and destroy() lifecycle methods; normalized trailing newlines.
React & Preact Components
src/social-share-button-react.jsx, src/social-share-button-preact.jsx
Reformatted useEffect initialization and comment formatting; normalized JSDoc and trailing whitespace; no functional logic changes.
HTML Demo
index.html
Added "Advanced Features" demo section with theme: 'auto' and floating positioning examples; reworked mid-page CTA and integration sections; refactored clipboard copy implementation from chained to multi-line then/catch format.

Sequence Diagram(s)

sequenceDiagram
    participant Client as Browser/Client
    participant SSB as SocialShareButton
    participant DOM as DOM
    participant Modal as Modal Instance
    participant Media as matchMedia API

    Client->>SSB: Initialize with theme:'auto'<br/>displayMode:'floating'
    SSB->>Media: matchMedia('(prefers-color-scheme: dark)')
    Media-->>SSB: Initial theme state
    SSB->>DOM: Create floating wrapper element
    SSB->>DOM: Append wrapper to document.body
    SSB->>Modal: createModal() with resolved theme
    Modal-->>SSB: Modal instance created
    SSB->>Media: Register listener for theme changes
    Media->>SSB: OS theme changes (e.g., light→dark)
    SSB->>Modal: Update theme classes dynamically
    
    Client->>SSB: destroy()
    SSB->>Media: Unregister matchMedia listener
    SSB->>DOM: Remove floating wrapper from DOM
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested labels

Documentation, Linter, Styling

Suggested reviewers

  • kpj2006
  • Muneerali199

Poem

🐰 Floating buttons dance on screen,
Auto themes switch serene,
Prefers-color-scheme so neat,
Formatting makes code complete,
ESLint rules align with grace!

🚥 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 PR title accurately describes the two main features being added: auto system theme detection and floating share bar.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ 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.

@github-actions github-actions Bot added first-time-contributor First PR of an external contributor frontend Changes to frontend code javascript JavaScript/TypeScript code changes needs-review no-issue-linked PR is not linked to any issue size/XL Extra large PR (>500 lines changed) Stale and removed no-issue-linked PR is not linked to any issue labels Apr 23, 2026
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: 5

Caution

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

⚠️ Outside diff range comments (4)
docs/Roadmap.md (1)

1-489: 🧹 Nitpick | 🔵 Trivial

Consider separating formatting changes from feature work.

This file contains only cosmetic changes (table spacing, emphasis markers, code quote style, whitespace normalization) that are unrelated to the PR's stated objectives (Auto System Theme and Floating Share Bar). While these formatting tweaks are harmless, mixing them with feature work makes the PR diff harder to review and dilutes the git history.

For future PRs, consider keeping formatting/style cleanup in separate commits or PRs from functional changes.

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

In `@docs/Roadmap.md` around lines 1 - 489, The PR mixes unrelated cosmetic edits
in Roadmap.md (table spacing, emphasis/quote style, whitespace normalization
across sections like "Phase 0" and the top-level headings) with the functional
work (Auto System Theme and Floating Share Bar); separate these formatting-only
changes into their own commit or PR: create a new branch/commit that contains
only the Markdown/style edits for Roadmap.md (or revert them here), leave this
PR with only the functional changes, and update the PR title/description to
state clearly which commit/PR contains formatting vs feature work so reviewers
can review diffs for symbols like "Phase 0", "Target Architecture" and the
Roadmap tables independently.
src/social-share-button.js (1)

91-107: ⚠️ Potential issue | 🟡 Minor

floatingPosition is not validated — typos produce a broken CSS class.

wrapper.className = \social-share-floating-wrapper ${this.options.floatingPosition}`blindly concatenates user input. If a consumer passes"bottomRight", "BOTTOM-RIGHT", or any unknown value, no corner positioning rule matches and the wrapper will render at the viewport origin with only the base position: fixed rule. Consider validating against the allowed set (bottom-right | bottom-left | top-right | top-left`) and falling back to a default.

♻️ Suggested fix
+    const validPositions = ["bottom-right", "bottom-left", "top-right", "top-left"];
+    const position = validPositions.includes(this.options.floatingPosition)
+      ? this.options.floatingPosition
+      : "bottom-right";
     if (this.options.displayMode === "floating" && typeof document !== "undefined") {
       const wrapper = document.createElement("div");
-      wrapper.className = `social-share-floating-wrapper ${this.options.floatingPosition}`;
+      wrapper.className = `social-share-floating-wrapper ${position}`;
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/social-share-button.js` around lines 91 - 107, Validate and normalize
this.options.floatingPosition before using it in wrapper.className: ensure the
value comes from the allowed set ("bottom-right", "bottom-left", "top-right",
"top-left") (normalize common variants like "bottomRight" or uppercase by
mapping or lowercasing and inserting hyphen) and fall back to a default (e.g.,
"bottom-right") when invalid or missing; update the code around displayMode ===
"floating" where wrapper.className is set (reference symbols:
this.options.floatingPosition, wrapper.className, this.floatingWrapper) to
compute a validatedPosition and use that in the class string.
src/social-share-button-preact.jsx (1)

12-36: ⚠️ Potential issue | 🟠 Major

New displayMode / floatingPosition options not exposed through the Preact wrapper.

The PR adds displayMode: 'floating' and floatingPosition to the core library, but this wrapper's destructured props list does not include them, nor are they forwarded to new window.SocialShareButton(...) at line 92 or to updateOptions(...) at line 147. Preact consumers have no way to opt into the floating share bar feature advertised in this PR.

♻️ Proposed fix
   buttonStyle = "default",
   modalPosition = "center",
+  displayMode = "inline",
+  floatingPosition = "bottom-right",

   // Analytics props — the library emits events but never collects data itself.

Also add them to both latestOptionsRef.current and the updateOptions call plus the dependency array of the update effect.

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

In `@src/social-share-button-preact.jsx` around lines 12 - 36, The Preact wrapper
SocialShareButton is missing the new displayMode and floatingPosition props so
consumers cannot use the floating share bar; add displayMode and
floatingPosition to the component's destructured props with sensible defaults,
ensure they are included in latestOptionsRef.current when building the options
passed to new window.SocialShareButton(...) and also passed into
updateOptions(...) in the effect, and include them in the effect dependency
array so updates to displayMode/floatingPosition reconfigure the instance.
src/social-share-button-react.jsx (1)

10-71: ⚠️ Potential issue | 🟠 Major

New displayMode / floatingPosition options not exposed through the React wrapper.

Same gap as the Preact wrapper: the props destructuring and the options passed into new window.SocialShareButton(...) at lines 51-71 (and the updateOptions call at lines 93-112) do not include the new displayMode and floatingPosition options introduced in src/social-share-button.js. React consumers cannot opt into the Floating Share Bar feature this PR adds.

♻️ Proposed fix
   buttonStyle = "default",
   modalPosition = "center",
+  displayMode = "inline",
+  floatingPosition = "bottom-right",

Forward both in the new window.SocialShareButton({...}) call and in updateOptions({...}), plus add them to the second effect's dependency array.

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

In `@src/social-share-button-react.jsx` around lines 10 - 71, The React wrapper is
not forwarding the new displayMode and floatingPosition options; add displayMode
and floatingPosition to the SocialShareButton component props (with appropriate
defaults), include them in the object passed to new
window.SocialShareButton({...}) when creating shareButtonRef.current, include
them in the options passed to shareButtonRef.current.updateOptions({...}) in the
update effect, and add them to that effect's dependency array so updates to
these props reconfigure the vanilla instance; reference the SocialShareButton
React component, containerRef, shareButtonRef, new
window.SocialShareButton({...}), and updateOptions({...}) when making these
changes.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docs/Roadmap.md`:
- Around line 30-46: Update the Roadmap.md "What Already Exists" table to
include the new theme option and floating display mode: add `theme: 'auto'`
(OS-level detection) alongside `theme: 'dark' | 'light'` and add a row for
`displayMode: 'floating'` with a note about the `floatingPosition`
configuration; also update any Notes cell or add a brief remark under that
section that these capabilities were introduced in this PR so the roadmap
accurately reflects `theme` and `displayMode` features (search for the existing
table and the literals `theme: 'dark' | 'light'`, `displayMode`, and
`floatingPosition` to locate the lines to change).

In `@index.html`:
- Around line 410-414: The "Check the bottom right of your screen!" hint under
the "Floating Share Bar" heading is misleading because the floating demo is
missing its required container during initialization (the floating demo
initialization references a missing container). Remove or replace that specific
hint paragraph (the <p> whose inline style contains "font-size: 11px; opacity:
0.8; margin-top: 5px" and the text "Check the bottom right of your screen!")
with a neutral note such as "Floating demo disabled until configuration is
completed" or hide it until the floating demo's container is correctly provided
in the floating demo initialization code.
- Around line 505-536: The CDN URLs in the HTML code block reference a
non-existent tag "@v1.0.4", causing 404s; update the two jsDelivr references
(the href and script src that point to social-share-button.css and
social-share-button.js) to a valid tag such as "@main" or "@latest" (or the next
released tag) so the Qwik wrapper file social-share-button-qwik.tsx and assets
load correctly; keep the rest of the example (SocialShareButton component usage)
unchanged.
- Around line 718-727: The Floating Share Bar demo fails because
SocialShareButton's constructor only calls init() when this.options.container
exists; update the constructor logic in the SocialShareButton class so it also
auto-initializes when options.displayMode === "floating" (i.e., call this.init()
if this.options.container || this.options.displayMode === "floating"), and
ensure init()/createButton() will create and append the floating wrapper to
document.body when displayMode is "floating". Reference: SocialShareButton
constructor, init(), createButton(), and options.displayMode.

In `@src/social-share-button.js`:
- Around line 109-135: The modal's "auto" theme handling is only set in
createModal(), so updateOptions({ theme }) won't register or update the
matchMedia listener or the modal's class; modify updateOptions to detect when
this.options.theme changes (to or from "auto"), and when it does: if new theme
=== "auto" call the same setup logic used in createModal() to resolve
resolvedTheme, register themeMediaQuery and themeChangeHandler (store them on
this.themeMediaQuery / this.themeChangeHandler), and update this.modal.classList
accordingly; if changing away from "auto", remove the listener by calling
this.themeMediaQuery.removeEventListener("change", this.themeChangeHandler) and
clear stored refs, and update this.modal.classList to the explicit theme. Ensure
createModal and updateOptions share or reuse the theme setup/teardown logic so
behavior is consistent.

---

Outside diff comments:
In `@docs/Roadmap.md`:
- Around line 1-489: The PR mixes unrelated cosmetic edits in Roadmap.md (table
spacing, emphasis/quote style, whitespace normalization across sections like
"Phase 0" and the top-level headings) with the functional work (Auto System
Theme and Floating Share Bar); separate these formatting-only changes into their
own commit or PR: create a new branch/commit that contains only the
Markdown/style edits for Roadmap.md (or revert them here), leave this PR with
only the functional changes, and update the PR title/description to state
clearly which commit/PR contains formatting vs feature work so reviewers can
review diffs for symbols like "Phase 0", "Target Architecture" and the Roadmap
tables independently.

In `@src/social-share-button-preact.jsx`:
- Around line 12-36: The Preact wrapper SocialShareButton is missing the new
displayMode and floatingPosition props so consumers cannot use the floating
share bar; add displayMode and floatingPosition to the component's destructured
props with sensible defaults, ensure they are included in
latestOptionsRef.current when building the options passed to new
window.SocialShareButton(...) and also passed into updateOptions(...) in the
effect, and include them in the effect dependency array so updates to
displayMode/floatingPosition reconfigure the instance.

In `@src/social-share-button-react.jsx`:
- Around line 10-71: The React wrapper is not forwarding the new displayMode and
floatingPosition options; add displayMode and floatingPosition to the
SocialShareButton component props (with appropriate defaults), include them in
the object passed to new window.SocialShareButton({...}) when creating
shareButtonRef.current, include them in the options passed to
shareButtonRef.current.updateOptions({...}) in the update effect, and add them
to that effect's dependency array so updates to these props reconfigure the
vanilla instance; reference the SocialShareButton React component, containerRef,
shareButtonRef, new window.SocialShareButton({...}), and updateOptions({...})
when making these changes.

In `@src/social-share-button.js`:
- Around line 91-107: Validate and normalize this.options.floatingPosition
before using it in wrapper.className: ensure the value comes from the allowed
set ("bottom-right", "bottom-left", "top-right", "top-left") (normalize common
variants like "bottomRight" or uppercase by mapping or lowercasing and inserting
hyphen) and fall back to a default (e.g., "bottom-right") when invalid or
missing; update the code around displayMode === "floating" where
wrapper.className is set (reference symbols: this.options.floatingPosition,
wrapper.className, this.floatingWrapper) to compute a validatedPosition and use
that in the class string.
🪄 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: a542d4a7-22ff-4d2e-a166-0f83aa92de7b

📥 Commits

Reviewing files that changed from the base of the PR and between d0686c4 and c4fd339.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (12)
  • CONTRIBUTING.md
  • README.md
  • docs/Roadmap.md
  • eslint.config.js
  • index.html
  • landing-page/README.md
  • landing-page/src/app/globals.css
  • src/social-share-analytics.js
  • src/social-share-button-preact.jsx
  • src/social-share-button-react.jsx
  • src/social-share-button.css
  • src/social-share-button.js
💤 Files with no reviewable changes (1)
  • README.md

Comment thread docs/Roadmap.md Outdated
Comment thread index.html
Comment on lines +410 to +414
<h3>Floating Share Bar</h3>
<p>Pins the share button to the screen corner.</p>
<p style="font-size: 11px; opacity: 0.8; margin-top: 5px">
Check the bottom right of your screen!
</p>
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

Misleading hint — floating button won't actually appear.

Due to the missing container in the floating demo initialization (see comment on lines 718-727), the "Check the bottom right of your screen!" instruction will confuse users. This will be resolved automatically once the floating demo is fixed.

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

In `@index.html` around lines 410 - 414, The "Check the bottom right of your
screen!" hint under the "Floating Share Bar" heading is misleading because the
floating demo is missing its required container during initialization (the
floating demo initialization references a missing container). Remove or replace
that specific hint paragraph (the <p> whose inline style contains "font-size:
11px; opacity: 0.8; margin-top: 5px" and the text "Check the bottom right of
your screen!") with a neutral note such as "Floating demo disabled until
configuration is completed" or hide it until the floating demo's container is
correctly provided in the floating demo initialization code.

Comment thread index.html
Comment thread index.html
Comment thread src/social-share-button.js
@github-actions github-actions Bot added no-issue-linked PR is not linked to any issue and removed no-issue-linked PR is not linked to any issue Stale labels Apr 23, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 9, 2026

Hello 👋 This PR has had no activity for more than 2 weeks. If you are still working on it, please push an update or leave a comment. Ping a maintainer if you believe it is ready for review or merge! This PR will be automatically closed in 7 days if there is no further activity.

@github-actions github-actions Bot added the Stale label May 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

configuration Configuration file changes documentation Changes to documentation files first-time-contributor First PR of an external contributor frontend Changes to frontend code javascript JavaScript/TypeScript code changes needs-review size/XL Extra large PR (>500 lines changed) Stale

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant