mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-18 19:46:36 +00:00
feat(code-snippet): support disabled state for single and multi-line types
This commit is contained in:
parent
524b5080a6
commit
3dde418398
6 changed files with 37 additions and 2 deletions
|
@ -18,6 +18,12 @@
|
|||
/** Set to `true` to hide the copy button */
|
||||
export let hideCopyButton = false;
|
||||
|
||||
/**
|
||||
* Set to `true` for the disabled variant
|
||||
* Only applies to the "single", "multi" types
|
||||
*/
|
||||
export let disabled = false;
|
||||
|
||||
/**
|
||||
* Set to `true` to wrap the text
|
||||
* Note that `type` must be "multi"
|
||||
|
@ -149,6 +155,7 @@
|
|||
class:bx--snippet--single="{type === 'single'}"
|
||||
class:bx--snippet--inline="{type === 'inline'}"
|
||||
class:bx--snippet--multi="{type === 'multi'}"
|
||||
class:bx--snippet--disabled="{type !== 'inline' && disabled}"
|
||||
{...$$restProps}
|
||||
on:mouseover
|
||||
on:mouseenter
|
||||
|
@ -156,7 +163,7 @@
|
|||
>
|
||||
<div
|
||||
role="{type === 'single' ? 'textbox' : undefined}"
|
||||
tabindex="{type === 'single' ? '0' : undefined}"
|
||||
tabindex="{type === 'single' && !disabled ? '0' : undefined}"
|
||||
aria-label="{$$restProps['aria-label'] || copyLabel || 'code-snippet'}"
|
||||
class:bx--snippet-container="{true}"
|
||||
>
|
||||
|
@ -168,6 +175,7 @@
|
|||
</div>
|
||||
{#if !hideCopyButton}
|
||||
<CopyButton
|
||||
disabled="{disabled}"
|
||||
feedback="{feedback}"
|
||||
feedbackTimeout="{feedbackTimeout}"
|
||||
iconDescription="{copyButtonDescription}"
|
||||
|
@ -180,6 +188,7 @@
|
|||
kind="ghost"
|
||||
size="small"
|
||||
class="bx--snippet-btn--expand"
|
||||
disabled="{disabled}"
|
||||
on:click="{() => {
|
||||
expanded = !expanded;
|
||||
}}"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue