mirror of
https://github.com/carbon-design-system/carbon-components-svelte.git
synced 2025-09-18 03:26:36 +00:00
feat(context-menu): support danger kind for ContextMenuOption
This commit is contained in:
parent
05433c4fb7
commit
b19696b9f1
6 changed files with 27 additions and 0 deletions
|
@ -800,6 +800,7 @@ None.
|
||||||
| selected | <code>let</code> | Yes | <code>boolean</code> | <code>false</code> | Set to `true` to use the selected variant |
|
| selected | <code>let</code> | Yes | <code>boolean</code> | <code>false</code> | Set to `true` to use the selected variant |
|
||||||
| icon | <code>let</code> | Yes | <code>typeof import("carbon-icons-svelte").CarbonIcon</code> | -- | Specify the icon from `carbon-icons-svelte` to render<br />Icon is rendered to the left of the label text |
|
| icon | <code>let</code> | Yes | <code>typeof import("carbon-icons-svelte").CarbonIcon</code> | -- | Specify the icon from `carbon-icons-svelte` to render<br />Icon is rendered to the left of the label text |
|
||||||
| indented | <code>let</code> | Yes | <code>boolean</code> | <code>false</code> | Set to `true` to indent the label |
|
| indented | <code>let</code> | Yes | <code>boolean</code> | <code>false</code> | Set to `true` to indent the label |
|
||||||
|
| kind | <code>let</code> | No | <code>"default" | "danger"</code> | <code>"default"</code> | Specify the kind of option |
|
||||||
| disabled | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to enable the disabled state |
|
| disabled | <code>let</code> | No | <code>boolean</code> | <code>false</code> | Set to `true` to enable the disabled state |
|
||||||
| labelText | <code>let</code> | No | <code>string</code> | <code>""</code> | Specify the label text<br />Alternatively, use the "labelText" slot (e.g., <span slot="labelText">...</span>) |
|
| labelText | <code>let</code> | No | <code>string</code> | <code>""</code> | Specify the label text<br />Alternatively, use the "labelText" slot (e.g., <span slot="labelText">...</span>) |
|
||||||
| shortcutText | <code>let</code> | No | <code>string</code> | <code>""</code> | Specify the shortcut text<br />Alternatively, use the "shortcutText" slot (e.g., <span slot="shortcutText">...</span>) |
|
| shortcutText | <code>let</code> | No | <code>string</code> | <code>""</code> | Specify the shortcut text<br />Alternatively, use the "shortcutText" slot (e.g., <span slot="shortcutText">...</span>) |
|
||||||
|
|
|
@ -1656,6 +1656,16 @@
|
||||||
"moduleName": "ContextMenuOption",
|
"moduleName": "ContextMenuOption",
|
||||||
"filePath": "src/ContextMenu/ContextMenuOption.svelte",
|
"filePath": "src/ContextMenu/ContextMenuOption.svelte",
|
||||||
"props": [
|
"props": [
|
||||||
|
{
|
||||||
|
"name": "kind",
|
||||||
|
"kind": "let",
|
||||||
|
"description": "Specify the kind of option",
|
||||||
|
"type": "\"default\" | \"danger\"",
|
||||||
|
"value": "\"default\"",
|
||||||
|
"isFunction": false,
|
||||||
|
"constant": false,
|
||||||
|
"reactive": false
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"name": "disabled",
|
"name": "disabled",
|
||||||
"kind": "let",
|
"kind": "let",
|
||||||
|
|
|
@ -42,4 +42,6 @@
|
||||||
<ContextMenuOption id="1" labelText="Reduce noise" />
|
<ContextMenuOption id="1" labelText="Reduce noise" />
|
||||||
<ContextMenuOption id="2" labelText="Auto-sharpen" />
|
<ContextMenuOption id="2" labelText="Auto-sharpen" />
|
||||||
</ContextMenuGroup>
|
</ContextMenuGroup>
|
||||||
|
<ContextMenuDivider />
|
||||||
|
<ContextMenuOption indented kind="danger" labelText="Delete" />
|
||||||
</ContextMenu>
|
</ContextMenu>
|
||||||
|
|
|
@ -1,4 +1,10 @@
|
||||||
<script>
|
<script>
|
||||||
|
/**
|
||||||
|
* Specify the kind of option
|
||||||
|
* @type {"default" | "danger"}
|
||||||
|
*/
|
||||||
|
export let kind = "default";
|
||||||
|
|
||||||
/** Set to `true` to enable the disabled state */
|
/** Set to `true` to enable the disabled state */
|
||||||
export let disabled = false;
|
export let disabled = false;
|
||||||
|
|
||||||
|
@ -158,6 +164,7 @@
|
||||||
class:bx--context-menu-option="{true}"
|
class:bx--context-menu-option="{true}"
|
||||||
class:bx--context-menu-option--disabled="{true}"
|
class:bx--context-menu-option--disabled="{true}"
|
||||||
class:bx--context-menu-option--active="{subOptions && submenuOpen}"
|
class:bx--context-menu-option--active="{subOptions && submenuOpen}"
|
||||||
|
class:bx--context-menu-option--danger="{!subOptions && kind === 'danger'}"
|
||||||
indented="{indented}"
|
indented="{indented}"
|
||||||
aria-checked="{isSelectable || isRadio ? selected : undefined}"
|
aria-checked="{isSelectable || isRadio ? selected : undefined}"
|
||||||
data-nested="{ref &&
|
data-nested="{ref &&
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
|
|
||||||
<ContextMenu>
|
<ContextMenu>
|
||||||
<ContextMenuOption
|
<ContextMenuOption
|
||||||
|
kind="danger"
|
||||||
indented
|
indented
|
||||||
labelText="Copy"
|
labelText="Copy"
|
||||||
shortcutText="⌘C"
|
shortcutText="⌘C"
|
||||||
|
|
6
types/ContextMenu/ContextMenuOption.d.ts
vendored
6
types/ContextMenu/ContextMenuOption.d.ts
vendored
|
@ -3,6 +3,12 @@ import { SvelteComponentTyped } from "svelte";
|
||||||
|
|
||||||
export interface ContextMenuOptionProps
|
export interface ContextMenuOptionProps
|
||||||
extends svelte.JSX.HTMLAttributes<HTMLElementTagNameMap["li"]> {
|
extends svelte.JSX.HTMLAttributes<HTMLElementTagNameMap["li"]> {
|
||||||
|
/**
|
||||||
|
* Specify the kind of option
|
||||||
|
* @default "default"
|
||||||
|
*/
|
||||||
|
kind?: "default" | "danger";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set to `true` to enable the disabled state
|
* Set to `true` to enable the disabled state
|
||||||
* @default false
|
* @default false
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue