remove unused element
This commit is contained in:
@@ -30,4 +30,3 @@ export * from './multiple-color-picker-input/index.js';
|
||||
export * from './multiple-text-string-input/index.js';
|
||||
export * from './popover-layout/index.js';
|
||||
export * from './table/index.js';
|
||||
export * from './tooltip-menu/index.js';
|
||||
|
||||
@@ -1 +0,0 @@
|
||||
export * from './tooltip-menu.element.js';
|
||||
@@ -1,94 +0,0 @@
|
||||
import { UmbTextStyles } from '@umbraco-cms/backoffice/style';
|
||||
import { css, html, LitElement, nothing, repeat, customElement, property } from '@umbraco-cms/backoffice/external/lit';
|
||||
|
||||
export interface TooltipMenuItem {
|
||||
label: string;
|
||||
icon?: string;
|
||||
action: () => void;
|
||||
}
|
||||
|
||||
@customElement('umb-tooltip-menu')
|
||||
export class UmbTooltipMenuElement extends LitElement {
|
||||
@property({ type: Boolean, reflect: true, attribute: 'icon-only' })
|
||||
public iconOnly = false;
|
||||
|
||||
@property()
|
||||
public items: Array<TooltipMenuItem> = [];
|
||||
|
||||
private _handleItemClick(item: TooltipMenuItem) {
|
||||
item.action();
|
||||
}
|
||||
|
||||
private _handleItemKeyDown(event: KeyboardEvent, item: TooltipMenuItem) {
|
||||
if (event.key === 'Enter') {
|
||||
item.action();
|
||||
}
|
||||
}
|
||||
|
||||
private _renderItem(item: TooltipMenuItem) {
|
||||
if (this.iconOnly && item.icon) {
|
||||
return html`<div
|
||||
@click=${() => this._handleItemClick(item)}
|
||||
@keydown=${(e: KeyboardEvent) => this._handleItemKeyDown(e, item)}
|
||||
class="item icon">
|
||||
<uui-icon .name=${item.icon}></uui-icon>
|
||||
</div>`;
|
||||
}
|
||||
|
||||
return html`<div
|
||||
@click=${() => this._handleItemClick(item)}
|
||||
@keydown=${(e: KeyboardEvent) => this._handleItemKeyDown(e, item)}
|
||||
class="item ${this.iconOnly ? 'icon' : 'label'}">
|
||||
${item.icon ? html`<uui-icon .name=${item.icon}></uui-icon>` : nothing}
|
||||
${!this.iconOnly ? html`<span>${item.label}</span>` : nothing}
|
||||
</div>`;
|
||||
}
|
||||
|
||||
render() {
|
||||
return repeat(
|
||||
this.items,
|
||||
(item) => item.label,
|
||||
(item) => this._renderItem(item),
|
||||
);
|
||||
}
|
||||
|
||||
static styles = [
|
||||
UmbTextStyles,
|
||||
css`
|
||||
:host {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
width: max-content;
|
||||
background-color: var(--uui-color-surface);
|
||||
box-shadow: var(--uui-shadow-depth-3);
|
||||
border-radius: var(--uui-border-radius);
|
||||
overflow: clip;
|
||||
}
|
||||
.item {
|
||||
color: var(--uui-color-interactive);
|
||||
align-items: center;
|
||||
display: flex;
|
||||
gap: var(--uui-size-space-2);
|
||||
cursor: pointer;
|
||||
}
|
||||
.item:hover {
|
||||
color: var(--uui-color-interactive-emphasis);
|
||||
background-color: var(--uui-color-surface-emphasis);
|
||||
}
|
||||
.item.label {
|
||||
padding: var(--uui-size-space-2) var(--uui-size-space-4);
|
||||
}
|
||||
.item.icon {
|
||||
padding: var(--uui-size-space-4);
|
||||
aspect-ratio: 1/1;
|
||||
justify-content: center;
|
||||
}
|
||||
`,
|
||||
];
|
||||
}
|
||||
|
||||
declare global {
|
||||
interface HTMLElementTagNameMap {
|
||||
'umb-tooltip-menu': UmbTooltipMenuElement;
|
||||
}
|
||||
}
|
||||
@@ -1,38 +0,0 @@
|
||||
import type { Meta, StoryObj } from '@storybook/web-components';
|
||||
import './tooltip-menu.element.js';
|
||||
import type { UmbTooltipMenuElement, TooltipMenuItem } from './tooltip-menu.element.js';
|
||||
|
||||
const meta: Meta<UmbTooltipMenuElement> = {
|
||||
title: 'Components/Tooltip Menu',
|
||||
component: 'umb-tooltip-menu',
|
||||
};
|
||||
|
||||
export default meta;
|
||||
type Story = StoryObj<UmbTooltipMenuElement>;
|
||||
|
||||
const items: Array<TooltipMenuItem> = [
|
||||
{
|
||||
label: 'Item 1',
|
||||
icon: 'icon-document',
|
||||
action: () => alert('Item 1 clicked'),
|
||||
},
|
||||
{
|
||||
label: 'Item 2',
|
||||
icon: 'icon-home',
|
||||
action: () => alert('Item 2 clicked'),
|
||||
},
|
||||
];
|
||||
|
||||
export const Overview: Story = {
|
||||
args: {
|
||||
items: items,
|
||||
iconOnly: false,
|
||||
},
|
||||
};
|
||||
|
||||
export const WithIconsOnly: Story = {
|
||||
args: {
|
||||
items: items,
|
||||
iconOnly: true,
|
||||
},
|
||||
};
|
||||
Reference in New Issue
Block a user