Skip to content

Conversation

@ari-launchdarkly
Copy link
Contributor

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

Summary

  • Ports over the CopyToClipboard component and utility methods from gonfalon to LP
  • Ports over the Snippet component and styling to LP
  • Adds the requisite dependencies as part of porting over the components

https://launchdarkly.atlassian.net/browse/REL-10213

Screenshots (if appropriate):

Screenshot 2025-10-20 at 13 13 03

Testing approaches


Related Jira issue: REL-10213: Move Snippet and CopyToClipboard to launchpad-ui

@ari-launchdarkly ari-launchdarkly requested review from a team and matthewferry October 20, 2025 20:13
@ari-launchdarkly ari-launchdarkly requested a review from a team as a code owner October 20, 2025 20:13
@changeset-bot
Copy link

changeset-bot bot commented Oct 20, 2025

🦋 Changeset detected

Latest commit: 93ac482

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 Minor

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

@@ -0,0 +1,132 @@
@import 'prism-themes/themes/prism-ghcolors.css';

.snippet {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

renamed this from Snippet to snippet

width: 100%;
}

.copyable [class*='_CopyToClipboard'] {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

renamed this from Snippet--copyable to copyable

border: none;
}

.snippet:not(.useDefaultHighlighting) .line-highlight {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

renamed Snippet--useDefaultHighlighting to useDefaultHighlighting

}: SnippetProps) {
const codeEl = useRef<HTMLElement>(null);

// biome-ignore lint/correctness/useExhaustiveDependencies: children and lang are intentionally included to re-highlight when they change
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added the biome-ignore to maintain the existing dependency list so we don't cause any unintended regressions with this migration

return true;
} catch (error) {
announce('Failed to copy', 'polite', 300);
console.error(`Unable to copy: ${error}`);
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'm not sure what to do about this, we were previously sending up a trackError and throwing this error message. Is there a pattern we want to establish where we can throw a CustomEvent that the consumer listens for if there's a failure?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the previous trackError solution wasn't very useful anyway so I think we can safely just announce and remove the console.error and not do anything else.

@pkg-pr-new
Copy link

pkg-pr-new bot commented Oct 20, 2025

yarn add https://pkg.pr.new/@launchpad-ui/components@1795.tgz
yarn add https://pkg.pr.new/@launchpad-ui/icons@1795.tgz
yarn add https://pkg.pr.new/@launchpad-ui/tokens@1795.tgz

commit: 93ac482

@github-actions
Copy link
Contributor

github-actions bot commented Oct 20, 2025

Size Change: -9 B (0%)

Total Size: 533 kB

Filename Size Change
packages/components/dist/index.es.js 19 kB -18 B (-0.09%)
packages/components/dist/index.js 19.9 kB -3 B (-0.02%)
packages/components/dist/style.css 8.42 kB +12 B (+0.14%)
ℹ️ 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

"@launchpad-ui/icons": "workspace:~",
"@launchpad-ui/tokens": "workspace:~",
"class-variance-authority": "0.7.0"
"@react-aria/live-announcer": "3.4.4",
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be in devDep? I see all the other @react-aria deps are devDeps. I'm not sure why, but best to stay consistent. Better still find out why they are devDep and not dep.

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'm not sure on that one. The reason being that we had originally had it as a dependency in the dependencies list and I didn't want to stray from that. What'd you think?

https://github.com/launchdarkly/gonfalon/blob/main/packages/forms-experimental/package.json#L6-L28

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

@yusinto yusinto left a comment

Choose a reason for hiding this comment

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

Couple of comments, but otherwise lgtm.

"@react-aria/live-announcer": "3.4.4",
"class-variance-authority": "0.7.0",
"prism-themes": "1.9.0",
"prismjs": "1.30.0"
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you know how big prismjs is? Do we want to package this into @launchpad-ui/components like this? (I'm not sure yet, but curious if this is something you all thought about already.)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@yusinto and I talked about it. I'm not sure if we want is a peer dependency, or as a direct dependency. The package size for a minified bundle is at 18.7K (minified and gzipped at 6.9K)

Copy link
Contributor

Choose a reason for hiding this comment

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

i feel like a peer dependency would work well here? Curious what @vezaynk thinks too.

Copy link
Contributor

Choose a reason for hiding this comment

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

Snippet should be a share-able LP component. It's been living in launchpad-experimental for 3 years or so with that prismjs dependency. I did look at the size yes ari is correct. That dep must exist somewhere.

Screenshot 2025-10-22 at 11 10 18 AM

Copy link
Contributor

Choose a reason for hiding this comment

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

My general idea around making everything react-aria into peer dependencies is because having differing versions actually broke things.

I don't think the situation is the same with prismjs. The other argument for peers is that we want to force dedupping to save on size. I think that's valid too.

More generally, I think erring on the side of peer dependencies might be cool because it will avoid needing to do dependency version bumps here.

tldr: No strong feelings from me, but I have been enjoying peer dependencies lately (especially post-PNPM).

Copy link
Contributor

Choose a reason for hiding this comment

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

No strong feelings. Peer dep is fine with me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sounds good. I'll set it as a peer dependency

@apucacao
Copy link
Contributor

Is this related to us trying to share onboarding code between different code bases?

@ari-launchdarkly
Copy link
Contributor Author

Is this related to us trying to share onboarding code between different code bases?

It is! We're looking to share the Snippet in our docs site too

@ari-launchdarkly ari-launchdarkly force-pushed the ari-launchdarkly/REL-10213-snippet-copy branch from c2c24d8 to a714c81 Compare October 22, 2025 18:45
@ari-launchdarkly ari-launchdarkly merged commit 9ec37fc into main Oct 22, 2025
16 checks passed
@ari-launchdarkly ari-launchdarkly deleted the ari-launchdarkly/REL-10213-snippet-copy branch October 22, 2025 20:22
This was referenced Oct 22, 2025
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.

5 participants