Skip to content

Conversation

@michaelmkraus
Copy link
Contributor

Proposed changes

  • clean up names of examples to get string without blanks and special characters

Types of changes

  • Bugfix (non-breaking change that fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Refactoring (improvements to existing components or architectural decisions)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation Update (if none of the other choices apply)

Fixes #4985

@changeset-bot
Copy link

changeset-bot bot commented Sep 17, 2025

⚠️ No Changeset found

Latest commit: 5d02c07

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions github-actions bot added the 📺showcases Changes to 1-n showcases label Sep 17, 2025
@mfranzke mfranzke changed the title Fix html example code in showcases fix: HTML example code in showcases Sep 17, 2025
@github-actions
Copy link
Contributor

@michaelmkraus michaelmkraus marked this pull request as ready for review September 17, 2025 09:46
mfranzke
mfranzke previously approved these changes Sep 17, 2025
@mfranzke mfranzke merged commit c4a7411 into main Sep 17, 2025
55 checks passed
@mfranzke mfranzke deleted the 4985-fix-showcase-html-example-code branch September 17, 2025 11:11
@github-project-automation github-project-automation bot moved this from 🏗 In development to ✅ Done in UX Engineering Team Backlog Sep 17, 2025
@mfranzke mfranzke changed the title fix: HTML example code in showcases fix(docs): HTML example code in showcases Sep 17, 2025
@mfranzke mfranzke requested a review from Copilot September 17, 2025 20:39
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes HTML example code generation in the design system showcases by cleaning up example names to remove spaces and special characters, ensuring valid JavaScript property names for the allExamples object keys.

  • Introduces utility functions to sanitize component variant and example names
  • Updates example key generation to use consistent cleaned names
  • Refactors code to use the new key generation function across multiple files

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
showcases/patternhub/scripts/utils.js Adds cleanupName and generateExampleKey utility functions for sanitizing names
showcases/patternhub/scripts/get-code-files.js Updates HTML example code retrieval to use the new key generation function
showcases/patternhub/scripts/generate-example-jsx.js Refactors example JSX generation to use consistent key naming

*/
export const cleanupName = (name) => {
if (!name) return '';
return name.replaceAll(/\s+/g, '').replaceAll(/\W/g, '');
Copy link

Copilot AI Sep 17, 2025

Choose a reason for hiding this comment

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

The regex /\W/g removes all non-word characters including underscores, which are valid in JavaScript property names. Consider using /[^\w]/g or a more specific pattern like /[^a-zA-Z0-9_]/g to preserve underscores.

Suggested change
return name.replaceAll(/\s+/g, '').replaceAll(/\W/g, '');
return name.replaceAll(/\s+/g, '').replaceAll(/[^a-zA-Z0-9_]/g, '');

Copilot uses AI. Check for mistakes.
variant.name,
example.name
);
examples.push(`"${exampleKey}":renderToString(${[code]})`);
Copy link

Copilot AI Sep 17, 2025

Choose a reason for hiding this comment

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

The array syntax ${[code]} will convert the code to a string representation of an array. This should be ${code} to properly interpolate the code content.

Suggested change
examples.push(`"${exampleKey}":renderToString(${[code]})`);
examples.push(`"${exampleKey}":renderToString(${code})`);

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

📺showcases Changes to 1-n showcases

Projects

Status: ✅ Done

Development

Successfully merging this pull request may close these issues.

HTML examples of showcases show "undefined" instead of HTML code

3 participants