Skip to content

Conversation

@ari-launchdarkly
Copy link
Contributor

@ari-launchdarkly ari-launchdarkly commented Oct 27, 2025

Summary

The original module work breaks the existing UI since we can't apply a direct mapping from styles to the children

Screenshots (if appropriate):

Screenshot 2025-10-27 at 12 58 40

Testing approaches


Related Jira issue: REL-10382: Fix snippet highlight colors

@ari-launchdarkly ari-launchdarkly requested a review from a team as a code owner October 27, 2025 19:59
@changeset-bot
Copy link

changeset-bot bot commented Oct 27, 2025

🦋 Changeset detected

Latest commit: 6103ef6

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@launchpad-ui/components Patch

Not sure what this means? Click here to learn what changesets are.

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

@ari-launchdarkly ari-launchdarkly changed the title REL-10382: update the way snippet CSS is applied so that children get colors all set fix(components): REL-10382 - update the way snippet CSS is applied so that children get colors all set Oct 27, 2025
@pkg-pr-new
Copy link

pkg-pr-new bot commented Oct 27, 2025

yarn add https://pkg.pr.new/@launchpad-ui/[email protected]
yarn add https://pkg.pr.new/@launchpad-ui/[email protected]
yarn add https://pkg.pr.new/@launchpad-ui/[email protected]

commit: 33810d0

@github-actions
Copy link
Contributor

Size Change: -655 B (-0.11%)

Total Size: 601 kB

Filename Size Change
packages/components/dist/index.es.js 52.6 kB -263 B (-0.5%)
packages/components/dist/index.js 53.4 kB -252 B (-0.47%)
packages/components/dist/style.css 9.51 kB -140 B (-1.45%)
ℹ️ View Unchanged
Filename Size
apps/vscode/dist/client.js 111 kB
apps/vscode/dist/server.js 261 kB
packages/box/dist/index.es.js 7.26 kB
packages/box/dist/index.js 7.82 kB
packages/box/dist/style.css 2.67 kB
packages/button/dist/index.es.js 1.89 kB
packages/button/dist/index.js 2.32 kB
packages/button/dist/style.css 3 kB
packages/core/dist/index.es.js 512 B
packages/core/dist/index.js 1.27 kB
packages/drawer/dist/index.es.js 1.76 kB
packages/drawer/dist/index.js 2.22 kB
packages/drawer/dist/style.css 497 B
packages/dropdown/dist/index.es.js 1.15 kB
packages/dropdown/dist/index.js 1.59 kB
packages/filter/dist/index.es.js 2.23 kB
packages/filter/dist/index.js 2.68 kB
packages/filter/dist/style.css 881 B
packages/focus-trap/dist/index.es.js 418 B
packages/focus-trap/dist/index.js 852 B
packages/form/dist/index.es.js 4.25 kB
packages/form/dist/index.js 4.73 kB
packages/form/dist/style.css 2.21 kB
packages/icons/dist/index.es.js 2.8 kB
packages/icons/dist/index.js 3.23 kB
packages/icons/dist/style.css 532 B
packages/menu/dist/index.es.js 3.69 kB
packages/menu/dist/index.js 4.16 kB
packages/menu/dist/style.css 872 B
packages/modal/dist/index.es.js 3.08 kB
packages/modal/dist/index.js 3.55 kB
packages/modal/dist/style.css 903 B
packages/navigation/dist/index.es.js 2.75 kB
packages/navigation/dist/index.js 3.21 kB
packages/navigation/dist/style.css 874 B
packages/overlay/dist/index.es.js 1.02 kB
packages/overlay/dist/index.js 1.42 kB
packages/popover/dist/index.es.js 3.01 kB
packages/popover/dist/index.js 3.43 kB
packages/popover/dist/style.css 529 B
packages/portal/dist/index.es.js 420 B
packages/portal/dist/index.js 835 B
packages/table/dist/index.es.js 1.01 kB
packages/table/dist/index.js 1.44 kB
packages/table/dist/style.css 700 B
packages/tokens/dist/fonts.css 183 B
packages/tokens/dist/index.css 1.47 kB
packages/tokens/dist/index.es.js 3.07 kB
packages/tokens/dist/index.js 3.11 kB
packages/tokens/dist/media-queries.css 113 B
packages/tokens/dist/themes.css 2.27 kB
packages/tooltip/dist/index.es.js 598 B
packages/tooltip/dist/index.js 1.02 kB
packages/tooltip/dist/style.css 337 B
packages/vars/dist/index.es.js 2.66 kB
packages/vars/dist/index.js 2.66 kB

compressed-size-action

<>
{withHeader && (
<div className={styles.header}>
<div className="header">
Copy link

Choose a reason for hiding this comment

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

If we merge this as-is then any consumer of Launchpad will have these styles applied to any element with the classname .header, which is probably both unexpected and seems like a poor experience for a library to provide.

Copy link

Choose a reason for hiding this comment

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

One option is to better namespace these classnames if we're going to be using them directly. However, I think that should be an absolute last-resort. Can you explain more fully why CSS modules aren't working here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I hear ya. We can combine module style application and generic class application, since the intent of the PR is to enable the current setting of styles based on dynamic child HTML elements

)}
<div
className={`${styles.snippet} ${className ?? ''} ${withCopyButton ? styles.copyable : ''} ${useDefaultHighlighting ? styles.useDefaultHighlighting : ''}`}
className={`snippet ${className ?? ''} ${withCopyButton ? 'copyable' : ''} ${useDefaultHighlighting ? 'useDefaultHighlighting' : ''}`}
Copy link
Contributor

Choose a reason for hiding this comment

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

You should be using import { cx } from 'classix'; to make it readable to engineers

Also the recommended way of styling is to use css modules. If you need to update styles from a higher level, you should pass down classNames as a prop (eg: headerClassName etc)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I hear ya. The issue is that we don't control the children classes. Maybe I'm misunderstanding the application here, but we're getting a bunch of classes that the snippet is supposed to handle. So for example, children can look something like this:

<span className="token function">myFunction<span className="token parenthesis">()</span></span>

Right now, we're missing out on applying the classes, hence the global CSS file and not the module application

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@zmdavis the reason above is the issue we're encountering. It's weird. Right now the snippet is responsible for verify-specific styles on an undocumented API w/r/t what the child shape should be. Ideally we'd be passing:

<span className={cx(styles.token, styles.function)}>myFunction ...

but we're just passing in a string.

Copy link
Contributor

Choose a reason for hiding this comment

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

If you need to over-ride css from 'prismjs/plugins/line-numbers/prism-line-numbers.css';, you can use the :global operator

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So what the UI is doing is taking a txt file:

https://github.com/launchdarkly/gonfalon/blob/526da5545019bc3529d0d1d6a0818817e95557fa/packages/onboarding-components/src/assetSource/react-client-sdk.txt

and injecting that as a child of the Snippet component.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

So right now, no styles are being set for classNames that are passed into children since we're relying on a modular syntax rather than a global css like we are in the current snippet component:

https://github.com/launchdarkly/gonfalon/blob/526da5545019bc3529d0d1d6a0818817e95557fa/packages/launchpad-experimental/src/Snippet/styles.css

https://github.com/launchdarkly/gonfalon/blob/526da5545019bc3529d0d1d6a0818817e95557fa/packages/launchpad-experimental/src/Snippet/Snippet.tsx#L47

Copy link

Choose a reason for hiding this comment

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

I believe what Naomi is saying is still valid. We can combine css modules with "global" classnames as needed

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll give that a shot.

Copy link

Choose a reason for hiding this comment

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

However, I think this raises a deeper issue of how we're using this and whether this component belongs in a library like Launchpad, since it relies on global classnames that can easily conflict with styles from the consuming application.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

However, I think this raises a deeper issue of how we're using this and whether this component belongs in a library like Launchpad, since it relies on global classnames that can easily conflict with styles from the consuming application.

Ya I totally agree. I think given the current implementation, it's not correct for us to have this version of the Snippet exist for external consumption of the component. Having said that, there's a space for a well-defined version of this to consume markdown that we parse and pass classes onto, or have the consumer deal with presentational concerns. Having said that, this is something that we'll need moving forward so I'll rope @yusinto in to see if we want to localize the implementation onto the onboarding-components

Copy link

@zmdavis zmdavis left a comment

Choose a reason for hiding this comment

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

Want to make sure we don't hastily merge this

<>
{withHeader && (
<div className={styles.header}>
<div className="header">
Copy link

Choose a reason for hiding this comment

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

One option is to better namespace these classnames if we're going to be using them directly. However, I think that should be an absolute last-resort. Can you explain more fully why CSS modules aren't working here?

@ari-launchdarkly
Copy link
Contributor Author

Closing this in favor of:

#1807

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.

4 participants