Skip to content

Add compact reactions layout option#1687

Open
javatarz wants to merge 3 commits into
giscus:mainfrom
javatarz:feature/compact-reactions-layout
Open

Add compact reactions layout option#1687
javatarz wants to merge 3 commits into
giscus:mainfrom
javatarz:feature/compact-reactions-layout

Conversation

@javatarz
Copy link
Copy Markdown

@javatarz javatarz commented Jan 2, 2026

Summary

Implements #1686 - Adds a configuration option to display reactions inline with the comment count for a cleaner, more compact layout.

Screenshots

Configuration UI

Here's a screenshot, with a red box around the part I changed
config-ui

Changes

Core Feature Implementation

  • New Configuration Option: data-reactions-layout with values:

    • "default" (default): Current behavior - reactions displayed prominently above comments
    • "compact": Reactions displayed inline with comment count in header
  • Type System:

    • Added ReactionsLayout type ('default' | 'compact')
    • Updated ISetConfigMessage and ConfigContext interfaces
  • Implementation:

    • client.ts: Reads data-reactions-layout attribute from script tag
    • pages/widget.tsx: Parses and passes config to React context
    • components/Giscus.tsx: Conditionally renders compact layout
    • styles/base.css: Adds .gsc-reactions-compact styling for inline display

Configuration UI

  • Added giscus.app Configuration Page UI:

    • Radio buttons to select reactions layout (default/compact)
    • Only shown when "Enable reactions" is checked
    • Indented for visual hierarchy
    • Updates live preview in iframe
    • Included in generated script tag output
  • Files Modified:

    • components/Configuration.tsx: Added reactionsLayout to IDirectConfig, added UI controls
    • pages/index.tsx: Initialize and manage reactionsLayout state
    • Integrated with live preview system

Internationalization

  • Full Translation Coverage:
    • Added config strings to all 35 supported locales
    • Translations for: reactionsLayout, reactionsLayoutDefault, reactionsLayoutCompact, reactionsLayoutDescription
    • Languages: Arabic, Belarusian, Bulgarian, Catalan, Czech, Danish, German, English, Esperanto, Spanish, Basque, Persian, French, Greek, Serbo-Croatian, Hebrew, Hungarian, Indonesian, Italian, Japanese, Khmer, Korean, Dutch, Polish, Portuguese, Romanian, Russian, Thai, Turkish, Ukrainian, Uzbek, Vietnamese, Chinese (Simplified, Hong Kong, Traditional)
    • Widget display already uses existing translated "reactions" text - no changes needed

Layout Comparison

Default layout (unchanged):

0 reactions
    😊
    
23 comments - powered by giscus

Compact layout (new):

0 reactions 😊 · 23 comments - powered by giscus

Usage

Manual Integration

Add the new data-reactions-layout attribute to your existing giscus script tag:

<script src="https://giscus.app/client.js"
        data-repo="[REPO]"
        data-repo-id="[REPO_ID]"
        data-category="[CATEGORY]"
        data-category-id="[CATEGORY_ID]"
        data-mapping="pathname"
        data-reactions-enabled="1"
        data-reactions-layout="compact"    👈 NEW: Set to "compact" for inline layout
        data-emit-metadata="0"
        data-input-position="bottom"
        data-theme="preferred_color_scheme"
        data-lang="en"
        crossorigin="anonymous"
        async>
</script>

Options for data-reactions-layout:

  • "default" (or omit the attribute) - Shows reactions above comments (current behavior)
  • "compact" - Shows reactions inline with comment count (new)

Using giscus.app

  1. Go to https://giscus.app
  2. Enable "Enable reactions for the main post"
  3. Select layout under "Reactions layout":
    • Default (above comments) - Current behavior
    • Compact (inline with comments) - New compact layout

The generated script will automatically include data-reactions-layout.

Testing

  • ✅ TypeScript compilation successful (no type errors)
  • ✅ Backward compatible - defaults to current behavior
  • ✅ Works with existing reaction functionality
  • ✅ Responsive design maintained
  • ✅ Configuration UI integrated with live preview
  • ✅ All 35 locales translated

Benefits

  • Cleaner, more compact comment section header
  • Better visual hierarchy (reactions and comments grouped together)
  • Reduced vertical space usage
  • Better UX on mobile/smaller viewports
  • Fully backward compatible
  • Easy to configure via giscus.app UI
  • Fully internationalized

Commits

  1. 511159c - Core functionality (types, context, rendering, styling)
  2. 609c136 - Configuration UI (English strings and UI controls)
  3. 2675799 - Full internationalization (all 35 locales)

Add data-reactions-layout configuration option to display reactions
inline with comment count for a cleaner, more compact layout.

When set to "compact", reactions appear in the header alongside
comment count instead of in a separate section above comments.
Default behavior ("default") remains unchanged.

Changes:
- Add ReactionsLayout type with "default" and "compact" values
- Add reactionsLayout to ConfigContext and ISetConfigMessage
- Update client.ts to read data-reactions-layout attribute
- Update widget.tsx to parse and pass reactionsLayout config
- Modify Giscus.tsx to conditionally render compact layout
- Add CSS styling for inline reactions display
@vercel
Copy link
Copy Markdown

vercel Bot commented Jan 2, 2026

@javatarz is attempting to deploy a commit to the giscus Team on Vercel.

A member of the Team first needs to authorize it.

Add UI to the giscus.app configuration page for selecting
reactions layout option (default or compact).

Changes:
- Add reactionsLayout to IDirectConfig interface
- Add radio buttons for choosing layout in Configuration.tsx
- Include reactionsLayout in generated script tag
- Update pages/index.tsx to initialize and manage reactionsLayout state
- Add i18n strings for reactions layout options in English

The reactions layout option is only shown when reactions are enabled,
appearing as an indented sub-option for better visual hierarchy.
Add translated configuration strings for the reactions layout option
to all 35 supported locales. This ensures the giscus.app configuration
page displays properly for all languages.

Translations added for:
- reactionsLayout: Label for the layout option
- reactionsLayoutDefault: Label for default layout option
- reactionsLayoutCompact: Label for compact layout option
- reactionsLayoutDescription: Help text explaining the option

Languages covered: Arabic, Belarusian, Bulgarian, Catalan, Czech,
Danish, German, English, Esperanto, Spanish, Basque, Persian, French,
Greek, Serbo-Croatian, Hebrew, Hungarian, Indonesian, Italian,
Japanese, Khmer, Korean, Dutch, Polish, Portuguese, Romanian, Russian,
Thai, Turkish, Ukrainian, Uzbek, Vietnamese, Chinese (Simplified,
Hong Kong, Traditional)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant