carbon-design-system / carbon-components-svelte

Svelte implementation of the Carbon Design System
https://svelte.carbondesignsystem.com
Apache License 2.0
2.71k stars 261 forks source link

fix(code-snippet): `showMoreLess={false}` should hide button #1917

Closed metonym closed 8 months ago

metonym commented 8 months ago

Fixes https://github.com/carbon-design-system/carbon-components-svelte/issues/1536

Currently, the following does not work as intended:

<CodeSnippet type="multi" {code} showMoreLess={false} />

The root cause is that showMoreLess is dynamically computed based on the code snippet height (the button is shown if a multi-line code snippet exceeds 255px). Additionally, the showMoreLess prop is initialized as false when it should be the opposite (allowing the consumer to set it to false).

This PR fixes the logic:

Additionally, it adds the following examples to the docs:

metonym commented 8 months ago

Released in v0.82.11.