Skip to content

feat(repo): Add theme export from gallery - #147

Open
renefloor wants to merge 3 commits into
mainfrom
feat/gallery-theme-export
Open

feat(repo): Add theme export from gallery#147
renefloor wants to merge 3 commits into
mainfrom
feat/gallery-theme-export

Conversation

@renefloor

@renefloor renefloor commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

Submit a pull request

CLA

  • I have signed the Stream CLA (required).
  • The code changes follow best practices
  • Code changes are tested (add some information if not applicable)

Description of the pull request

This is a new feature that adds an export button which gives you code for the theme settings.
It's also possible to manage a couple of component themes, but we can add more components in a next PR.

It also refactors the regular Theme Studio panel to make it more maintainable.

Screenshots / Videos

(export in top right)
image
image

Summary by CodeRabbit

  • New Features

    • Added a theme export workspace for editing light and dark themes side by side.
    • Added linked or independent color and seed editing, component theme customization, live previews, and generated Dart code.
    • Added responsive layouts, code copying, color pickers, and configurable component theme sections.
    • Added toolbar access to the theme export experience.
  • Bug Fixes

    • Improved narrow-screen layouts, nullable color handling, and text overflow behavior.
  • Documentation

    • Expanded guidance for configuring and exporting themes.
  • Tests

    • Added coverage for theme editing, exporting, linking, previews, code generation, and responsive layouts.

@renefloor
renefloor requested a review from a team as a code owner August 12, 2026 12:46
@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: ef6a4c6b-feba-49ba-bc6a-a3a4ec249e96

📥 Commits

Reviewing files that changed from the base of the PR and between 0e44b64 and ed9af1c.

📒 Files selected for processing (15)
  • .gitignore
  • apps/design_system_gallery/AGENTS.md
  • apps/design_system_gallery/lib/app/theme_export_page.dart
  • apps/design_system_gallery/lib/config/component_theme_descriptors.dart
  • apps/design_system_gallery/lib/config/theme_configuration.dart
  • apps/design_system_gallery/lib/core/theme_code_generator.dart
  • apps/design_system_gallery/lib/widgets/theme_export/export_column_row.dart
  • apps/design_system_gallery/lib/widgets/theme_export/theme_export_code_pane.dart
  • apps/design_system_gallery/lib/widgets/theme_studio/add_component_theme_button.dart
  • apps/design_system_gallery/lib/widgets/theme_studio/color_picker_tile.dart
  • apps/design_system_gallery/lib/widgets/theme_studio/theme_customization_panel.dart
  • apps/design_system_gallery/test/app/theme_export_page_test.dart
  • apps/design_system_gallery/test/core/theme_code_generator_compiles_test.dart
  • apps/design_system_gallery/test/core/theme_code_generator_test.dart
  • apps/design_system_gallery/test/widgets/theme_studio/color_picker_tile_test.dart
🚧 Files skipped from review as they are similar to previous changes (8)
  • apps/design_system_gallery/lib/widgets/theme_export/theme_export_code_pane.dart
  • apps/design_system_gallery/test/app/theme_export_page_test.dart
  • apps/design_system_gallery/test/core/theme_code_generator_test.dart
  • apps/design_system_gallery/AGENTS.md
  • apps/design_system_gallery/lib/app/theme_export_page.dart
  • apps/design_system_gallery/test/widgets/theme_studio/color_picker_tile_test.dart
  • apps/design_system_gallery/lib/config/theme_configuration.dart
  • apps/design_system_gallery/lib/widgets/theme_studio/color_picker_tile.dart

📝 Walkthrough

Walkthrough

Changes

Theme Studio and Export

Layer / File(s) Summary
Theme contracts and configuration
apps/design_system_gallery/lib/config/*, apps/design_system_gallery/test/config/*, apps/design_system_gallery/AGENTS.md
Added slot-based colors, seeds, sections, component descriptors, override APIs, and configuration tests.
Export state and code generation
apps/design_system_gallery/lib/config/theme_export_configuration.dart, apps/design_system_gallery/lib/core/theme_code_generator.dart, apps/design_system_gallery/test/core/*, apps/design_system_gallery/pubspec.yaml
Added linked light/dark export state, cache handling, disposal, formatted Dart generation, and generator tests.
Studio controls and responsive tiles
apps/design_system_gallery/lib/widgets/theme_studio/*, apps/design_system_gallery/test/widgets/theme_studio/*
Updated the customization panel for registered sections and component themes. Added compact and nullable color tile behavior.
Export interface and responsive page
apps/design_system_gallery/lib/app/theme_export_page.dart, apps/design_system_gallery/lib/widgets/theme_export/*, apps/design_system_gallery/lib/widgets/toolbar/toolbar.dart, apps/design_system_gallery/test/app/theme_export_page_test.dart
Added responsive export settings, linked editing rows, previews, code display, navigation, and widget tests.

macOS build integration

Layer / File(s) Summary
Runner package wiring
apps/design_system_gallery/macos/Runner.xcodeproj/project.pbxproj, apps/design_system_gallery/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme
Registered the generated Flutter Swift package and added a macOS framework preparation pre-action.

Estimated code review effort: 5 (Critical) | ~120 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Toolbar
  participant ThemeExportPage
  participant ThemeExportConfiguration
  participant ThemeExportCodePane
  Toolbar->>ThemeExportPage: Open Export Theme
  ThemeExportPage->>ThemeExportConfiguration: Seed light and dark configurations
  ThemeExportPage->>ThemeExportConfiguration: Apply linked or independent edits
  ThemeExportConfiguration->>ThemeExportCodePane: Provide refreshed generated Dart code
  ThemeExportPage->>ThemeExportCodePane: Render selectable code
Loading
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main change: adding theme export functionality to the gallery.
Description check ✅ Passed The description explains the feature, component-theme support, refactor, testing, and includes screenshots demonstrating the changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/gallery-theme-export

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.

@codecov

codecov Bot commented Aug 12, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 93.88954% with 52 lines in your changes missing coverage. Please review.
✅ Project coverage is 62.31%. Comparing base (d79db82) to head (ed9af1c).

Files with missing lines Patch % Lines
...gallery/lib/config/theme_export_configuration.dart 80.45% 17 Missing ⚠️
...ry/lib/widgets/theme_export/linked_color_rows.dart 83.33% 13 Missing ⚠️
...allery/lib/config/component_theme_descriptors.dart 71.42% 6 Missing ⚠️
...system_gallery/lib/config/theme_configuration.dart 95.58% 6 Missing ⚠️
...b/widgets/theme_export/theme_export_code_pane.dart 90.00% 5 Missing ⚠️
..._system_gallery/lib/core/theme_code_generator.dart 96.77% 4 Missing ⚠️
...sign_system_gallery/lib/app/theme_export_page.dart 99.19% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #147      +/-   ##
==========================================
+ Coverage   58.17%   62.31%   +4.13%     
==========================================
  Files         187      202      +15     
  Lines        7615     8650    +1035     
==========================================
+ Hits         4430     5390     +960     
- Misses       3185     3260      +75     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@renefloor renefloor changed the title feat(samples): Add theme export from gallery feat(repo): Add theme export from gallery Aug 12, 2026

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 7

🧹 Nitpick comments (5)
apps/design_system_gallery/test/core/theme_code_generator_test.dart (1)

211-294: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Add a case where one component property differs between light and dark.

The component tests cover equal-on-both-sides and light-only. They do not cover the split case, which produces two suffixed consts for the same component property. That path is the default in ThemeExportConfiguration, because component property colors start unlinked.

test('a component property with different colors per side becomes two suffixed consts', () {
  final code = generateThemeCode(
    light: const ThemeExportSide(
      componentOverrides: {'Online Indicator': {'backgroundOnline': Color(0xFF111111)}},
    ),
    dark: const ThemeExportSide(
      componentOverrides: {'Online Indicator': {'backgroundOnline': Color(0xFF222222)}},
    ),
  );

  expect(code, contains('const onlineIndicatorBackgroundOnlineLight = '));
  expect(code, contains('const onlineIndicatorBackgroundOnlineDark = '));
  expect(code, contains('backgroundOnline: onlineIndicatorBackgroundOnlineLight'));
  expect(code, contains('backgroundOnline: onlineIndicatorBackgroundOnlineDark'));
});
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/design_system_gallery/test/core/theme_code_generator_test.dart` around
lines 211 - 294, Add a test alongside the existing component theme tests
covering different light and dark values for the same Online Indicator
backgroundOnline property. In the new test, use distinct colors on each
ThemeExportSide and assert that generateThemeCode emits Light and Dark suffixed
constants and passes each corresponding constant to the light and dark
StreamOnlineIndicatorThemeData constructors.
apps/design_system_gallery/lib/app/theme_export_page.dart (1)

210-227: 🩺 Stability & Availability | 🔵 Trivial | 💤 Low value

firstWhere throws when an active component name has no descriptor.

Line 211 uses firstWhere with no orElse. It throws StateError during build if activeComponentThemes ever contains a name that is not in componentThemeDescriptors. Today both come from the same descriptor list, so the invariant holds. It breaks silently if a descriptor is renamed or removed while state persists.

A lookup map also removes the O(components × descriptors) scan from every rebuild:

♻️ Proposed lookup
+    final descriptorsByName = {for (final d in componentThemeDescriptors) d.name: d};
     for (final component in export.activeComponentThemes) {
-      final descriptor = componentThemeDescriptors.firstWhere((d) => d.name == component);
+      final descriptor = descriptorsByName[component];
+      if (descriptor == null) continue;
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/design_system_gallery/lib/app/theme_export_page.dart` around lines 210 -
227, Update the component-theme rendering loop around activeComponentThemes to
use a name-keyed descriptor lookup instead of firstWhere, and safely skip or
otherwise handle active components with no matching descriptor without throwing
during build. Preserve rendering for components with valid descriptors and avoid
rescanning componentThemeDescriptors on each rebuild.
apps/design_system_gallery/lib/config/theme_configuration.dart (1)

244-249: 🩺 Stability & Availability | 🔵 Trivial | ⚡ Quick win

Component themes are keyed by a free-form String with no total name-to-descriptor lookup. addComponentTheme and setComponentColor accept any String, but both consumers resolve that name with componentThemeDescriptors.firstWhere(...) and no orElse. An unknown name therefore throws StateError — once inside _rebuildTheme, and once inside build. Add one shared resolver (for example a Map<String, ComponentThemeDescriptor> built from componentThemeDescriptors, or a descriptorFor(String name) helper returning a nullable descriptor) and use it at both sites.

  • apps/design_system_gallery/lib/config/theme_configuration.dart#L244-L249: replace the firstWhere in _buildComponentTheme with the shared lookup and return null (with an assert) for an unknown name.
  • apps/design_system_gallery/lib/widgets/theme_studio/theme_customization_panel.dart#L102-L108: use the same lookup and skip rendering a section whose name has no descriptor, so an unknown name never breaks the panel's build.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/design_system_gallery/lib/config/theme_configuration.dart` around lines
244 - 249, The component theme name lookup can throw for unknown free-form
names. In
apps/design_system_gallery/lib/config/theme_configuration.dart#L244-L249, add a
shared nullable resolver for componentThemeDescriptors and update
_buildComponentTheme to assert and return null when no descriptor exists; in
apps/design_system_gallery/lib/widgets/theme_studio/theme_customization_panel.dart#L102-L108,
reuse that resolver and skip sections without descriptors so build remains safe.
apps/design_system_gallery/lib/widgets/theme_export/export_column_row.dart (1)

51-51: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Replace the hardcoded seam width with a spacing token.

Line 51 hardcodes a 40 px layout value. Read this value from context.streamSpacing so the export layout follows the configured spacing scale.

As per coding guidelines, use StreamTheme tokens for styling instead of hardcoded values.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@apps/design_system_gallery/lib/widgets/theme_export/export_column_row.dart`
at line 51, Update the SizedBox in the export column row to use
context.streamSpacing instead of the hardcoded width of 40, preserving the
existing middle widget fallback and aligning the layout with StreamTheme spacing
tokens.

Source: Coding guidelines

apps/design_system_gallery/lib/widgets/theme_export/theme_export_code_pane.dart (1)

71-75: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Paint the border with foregroundDecoration.

Line 74 paints the border in decoration. Move the border to Container.foregroundDecoration and keep the background and radius in decoration.

As per coding guidelines, use foregroundDecoration for borders to prevent clipping.

Proposed fix
                       decoration: BoxDecoration(
                         color: colorScheme.backgroundElevation0,
                         borderRadius: BorderRadius.all(context.streamRadius.sm),
-                        border: Border.all(color: colorScheme.borderSubtle),
                       ),
+                      foregroundDecoration: BoxDecoration(
+                        borderRadius: BorderRadius.all(context.streamRadius.sm),
+                        border: Border.all(color: colorScheme.borderSubtle),
+                      ),
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In
`@apps/design_system_gallery/lib/widgets/theme_export/theme_export_code_pane.dart`
around lines 71 - 75, Update the Container decoration in the theme export code
pane so decoration retains only color and borderRadius, while the border is
supplied through Container.foregroundDecoration. Preserve the existing border
color and radius values.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@apps/design_system_gallery/AGENTS.md`:
- Around line 59-73: Update the config structure list to include
component_theme_descriptors.dart and theme_export_configuration.dart with
accurate descriptions. Revise the test coverage sentence to clearly state that
tests cover StreamColorScheme in theme_color_slot.dart, component themes, export
configuration, the color picker tile, and the export page.

In `@apps/design_system_gallery/lib/app/theme_export_page.dart`:
- Around line 278-304: Update the Row containing the title and subtitle so the
title Text uses Expanded and receives the remaining width, while the subtitle
chip’s Flexible uses flex: 0 to size to its content. Preserve the existing gap,
styling, and ellipsis truncation, then verify spacing and truncation against the
Figma section-header specification.

In `@apps/design_system_gallery/lib/core/theme_code_generator.dart`:
- Around line 83-86: In
apps/design_system_gallery/lib/core/theme_code_generator.dart lines 83-86,
rewrite the comment to state that ThemeExportConfiguration edits component
property colors independently per brightness and leaves them initially unlinked.
In apps/design_system_gallery/test/core/theme_code_generator_test.dart lines
211-294, add coverage for a component property with different light and dark
colors, asserting both brightness-suffixed constants and their corresponding
references.

In
`@apps/design_system_gallery/lib/widgets/theme_studio/add_component_theme_button.dart`:
- Around line 33-38: Update the button Container’s border styling to use
foregroundDecoration instead of decoration, matching ToolbarButton’s existing
approach and the project guideline; preserve the current rounded border
appearance and padding.

In `@apps/design_system_gallery/lib/widgets/theme_studio/color_picker_tile.dart`:
- Around line 178-187: Update the placeholder Text caption in the color picker
tile so it remains laid out for height alignment but is excluded from the
semantics tree, preventing customized tiles from announcing “default.”

In
`@apps/design_system_gallery/lib/widgets/theme_studio/theme_customization_panel.dart`:
- Around line 102-108: Add a shared name-based component theme resolution helper
in ThemeConfiguration that safely returns no descriptor when a name is absent,
then use it in both the panel’s activeComponentThemes rendering and the lookup
near setComponentColor/addComponentTheme instead of firstWhere. Skip or
otherwise preserve valid behavior for unresolved names so build never throws
StateError.

In `@apps/design_system_gallery/test/app/theme_export_page_test.dart`:
- Around line 129-131: Update the Avatar exclusion assertion in the theme export
page test to search for text containing “Avatar” within a SimpleDialog
descendant, rather than matching the exact unscoped text. Keep the existing
Online Indicator assertion unchanged.

---

Nitpick comments:
In `@apps/design_system_gallery/lib/app/theme_export_page.dart`:
- Around line 210-227: Update the component-theme rendering loop around
activeComponentThemes to use a name-keyed descriptor lookup instead of
firstWhere, and safely skip or otherwise handle active components with no
matching descriptor without throwing during build. Preserve rendering for
components with valid descriptors and avoid rescanning componentThemeDescriptors
on each rebuild.

In `@apps/design_system_gallery/lib/config/theme_configuration.dart`:
- Around line 244-249: The component theme name lookup can throw for unknown
free-form names. In
apps/design_system_gallery/lib/config/theme_configuration.dart#L244-L249, add a
shared nullable resolver for componentThemeDescriptors and update
_buildComponentTheme to assert and return null when no descriptor exists; in
apps/design_system_gallery/lib/widgets/theme_studio/theme_customization_panel.dart#L102-L108,
reuse that resolver and skip sections without descriptors so build remains safe.

In `@apps/design_system_gallery/lib/widgets/theme_export/export_column_row.dart`:
- Line 51: Update the SizedBox in the export column row to use
context.streamSpacing instead of the hardcoded width of 40, preserving the
existing middle widget fallback and aligning the layout with StreamTheme spacing
tokens.

In
`@apps/design_system_gallery/lib/widgets/theme_export/theme_export_code_pane.dart`:
- Around line 71-75: Update the Container decoration in the theme export code
pane so decoration retains only color and borderRadius, while the border is
supplied through Container.foregroundDecoration. Preserve the existing border
color and radius values.

In `@apps/design_system_gallery/test/core/theme_code_generator_test.dart`:
- Around line 211-294: Add a test alongside the existing component theme tests
covering different light and dark values for the same Online Indicator
backgroundOnline property. In the new test, use distinct colors on each
ThemeExportSide and assert that generateThemeCode emits Light and Dark suffixed
constants and passes each corresponding constant to the light and dark
StreamOnlineIndicatorThemeData constructors.
🪄 Autofix

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: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: d0098e22-ae9a-4b59-9c22-241b39487486

📥 Commits

Reviewing files that changed from the base of the PR and between d79db82 and 0e44b64.

📒 Files selected for processing (29)
  • apps/design_system_gallery/AGENTS.md
  • apps/design_system_gallery/lib/app/theme_export_page.dart
  • apps/design_system_gallery/lib/config/component_theme_descriptors.dart
  • apps/design_system_gallery/lib/config/theme_color_slot.dart
  • apps/design_system_gallery/lib/config/theme_configuration.dart
  • apps/design_system_gallery/lib/config/theme_export_configuration.dart
  • apps/design_system_gallery/lib/config/theme_studio_sections.dart
  • apps/design_system_gallery/lib/core/theme_code_generator.dart
  • apps/design_system_gallery/lib/widgets/theme_export/export_column_row.dart
  • apps/design_system_gallery/lib/widgets/theme_export/link_toggle_button.dart
  • apps/design_system_gallery/lib/widgets/theme_export/linked_color_rows.dart
  • apps/design_system_gallery/lib/widgets/theme_export/message_bubble_preview.dart
  • apps/design_system_gallery/lib/widgets/theme_export/theme_export_code_pane.dart
  • apps/design_system_gallery/lib/widgets/theme_export/theme_export_preview_bar.dart
  • apps/design_system_gallery/lib/widgets/theme_export/theme_export_widgets.dart
  • apps/design_system_gallery/lib/widgets/theme_studio/add_component_theme_button.dart
  • apps/design_system_gallery/lib/widgets/theme_studio/color_picker_tile.dart
  • apps/design_system_gallery/lib/widgets/theme_studio/theme_customization_panel.dart
  • apps/design_system_gallery/lib/widgets/theme_studio/theme_studio_widgets.dart
  • apps/design_system_gallery/lib/widgets/toolbar/toolbar.dart
  • apps/design_system_gallery/macos/Runner.xcodeproj/project.pbxproj
  • apps/design_system_gallery/macos/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme
  • apps/design_system_gallery/pubspec.yaml
  • apps/design_system_gallery/test/app/theme_export_page_test.dart
  • apps/design_system_gallery/test/config/component_theme_test.dart
  • apps/design_system_gallery/test/config/theme_color_slot_test.dart
  • apps/design_system_gallery/test/config/theme_export_configuration_test.dart
  • apps/design_system_gallery/test/core/theme_code_generator_test.dart
  • apps/design_system_gallery/test/widgets/theme_studio/color_picker_tile_test.dart

Comment thread apps/design_system_gallery/AGENTS.md
Comment thread apps/design_system_gallery/lib/app/theme_export_page.dart
Comment thread apps/design_system_gallery/lib/core/theme_code_generator.dart Outdated
Comment thread apps/design_system_gallery/test/app/theme_export_page_test.dart
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