Skip to content

Web-components: Export html helper for custom render functions #30982

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: next
Choose a base branch
from

Conversation

shilman
Copy link
Member

@shilman shilman commented Mar 30, 2025

Closes #30979

What I did

  • Re-export html
  • Update docs
  • Update sample components

Checklist for Contributors

Testing

The changes in this PR are covered in the following automated tests:

  • stories
  • unit tests
  • integration tests
  • end-to-end tests

Manual testing

Create a WC sandbox and run it. Add a story with a custom render function.

🦋 Canary release

This PR does not have a canary release associated. You can request a canary release of this pull request by mentioning the @storybookjs/core team here.

core team members can create a canary release here or locally with gh workflow run --repo storybookjs/storybook canary-release-pr.yml --field pr=<PR_NUMBER>

Greptile Summary

This PR re-exports the html function through @storybook/web-components to standardize custom render functions for web components.

  • Updated /code/renderers/web-components/src/index.ts to re-export html from lit-html.
  • Modified /code/renderers/web-components/template/stories/demo-wc-card.stories.js and script.stories.js to import html from @storybook/web-components.
  • Adjusted /code/renderers/web-components/package.json by switching dependency from lit to lit-html.
  • Note: Verify sample components update for consistent usage of the new html export.

@shilman shilman changed the title Web-components: Re-export html from lit-html for custom render functions Web-components: Export html helper for custom render functions Mar 30, 2025
Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

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

4 file(s) reviewed, 1 comment(s)
Edit PR Review Bot Settings | Greptile

Copy link

nx-cloud bot commented Mar 30, 2025

View your CI Pipeline Execution ↗ for commit 9e878da.

Command Status Duration Result
nx run-many -t build --parallel=3 ✅ Succeeded 1m 50s View ↗

☁️ Nx Cloud last updated this comment at 2025-03-31 08:01:51 UTC

@shilman
Copy link
Member Author

shilman commented Mar 30, 2025

The sample components still use lit's html helper:

https://github.com/storybookjs/storybook/blob/next/code/renderers/web-components/template/cli/js/Button.js#L1

This is "user" code instead of story code, so I didn't update it to use Storybook's html export. We probably should update the Button/Header/Page sample components to not use Lit at all, so that we don't need to update the user's package.json.

@shilman shilman added maintenance User-facing maintenance tasks web-components ci:normal and removed ci:normal labels Mar 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci:normal maintenance User-facing maintenance tasks web-components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants