@fluid-topics/ft-floating-menu 0.3.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +22 -0
- package/build/ft-floating-menu-item.css.d.ts +5 -0
- package/build/ft-floating-menu-item.css.js +31 -0
- package/build/ft-floating-menu-item.d.ts +14 -0
- package/build/ft-floating-menu-item.js +53 -0
- package/build/ft-floating-menu-item.properties.d.ts +5 -0
- package/build/ft-floating-menu-item.properties.js +2 -0
- package/build/ft-floating-menu.css.d.ts +8 -0
- package/build/ft-floating-menu.css.js +44 -0
- package/build/ft-floating-menu.d.ts +15 -0
- package/build/ft-floating-menu.js +75 -0
- package/build/ft-floating-menu.light.js +615 -0
- package/build/ft-floating-menu.min.js +732 -0
- package/build/ft-floating-menu.properties.d.ts +3 -0
- package/build/ft-floating-menu.properties.js +2 -0
- package/build/index.d.ts +7 -0
- package/build/index.js +12 -0
- package/package.json +30 -0
package/README.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
Floating menu component
|
|
2
|
+
|
|
3
|
+
## Install
|
|
4
|
+
|
|
5
|
+
```shell
|
|
6
|
+
npm install @fluid-topics/ft-floating-menu
|
|
7
|
+
yarn add @fluid-topics/ft-floating-menu
|
|
8
|
+
```
|
|
9
|
+
|
|
10
|
+
## Usage
|
|
11
|
+
|
|
12
|
+
```typescript
|
|
13
|
+
import { html } from "lit"
|
|
14
|
+
import "@fluid-topics/ft-floating-menu"
|
|
15
|
+
|
|
16
|
+
function render() {
|
|
17
|
+
return html` <ft-floating-menu>
|
|
18
|
+
<ft-floating-menu-item icon="help" value="1">help</ft-floating-menu-item>
|
|
19
|
+
<ft-floating-menu-item icon="check" value="2">check</ft-floating-menu-item>
|
|
20
|
+
</ft-floating-menu> `
|
|
21
|
+
}
|
|
22
|
+
```
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { css } from "lit";
|
|
2
|
+
import { designSystemVariables, FtCssVariableFactory } from "@fluid-topics/ft-wc-utils";
|
|
3
|
+
export const FtFloatingMenuItemCssVariables = {
|
|
4
|
+
iconColor: FtCssVariableFactory.extend("--ft-floating-menu-icon-color", designSystemVariables.colorOnSurfaceMedium)
|
|
5
|
+
};
|
|
6
|
+
// language=CSS
|
|
7
|
+
export const itemStyles = css `
|
|
8
|
+
.ft-floating-menu-item {
|
|
9
|
+
cursor: pointer;
|
|
10
|
+
display: flex;
|
|
11
|
+
position: relative;
|
|
12
|
+
align-items: center;
|
|
13
|
+
justify-content: flex-start;
|
|
14
|
+
overflow: hidden;
|
|
15
|
+
padding: 0 16px;
|
|
16
|
+
outline: none;
|
|
17
|
+
height: 48px;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
ft-typography {
|
|
21
|
+
white-space: nowrap;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.ft-floating-menu-item ft-icon {
|
|
25
|
+
--ft-icon-font-size: 24px;
|
|
26
|
+
color: ${FtFloatingMenuItemCssVariables.iconColor};
|
|
27
|
+
margin-left: 0;
|
|
28
|
+
margin-right: 32px;
|
|
29
|
+
}
|
|
30
|
+
`;
|
|
31
|
+
//# sourceMappingURL=ft-floating-menu-item.css.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ElementDefinitionsMap, FtLitElement } from "@fluid-topics/ft-wc-utils";
|
|
2
|
+
import { FtFloatingMenuItemProperties } from "./ft-floating-menu-item.properties";
|
|
3
|
+
export declare class FtFloatingMenuItemSelect extends CustomEvent<string> {
|
|
4
|
+
constructor(value: string);
|
|
5
|
+
}
|
|
6
|
+
export declare class FtFloatingMenuItem extends FtLitElement implements FtFloatingMenuItemProperties {
|
|
7
|
+
static elementDefinitions: ElementDefinitionsMap;
|
|
8
|
+
static styles: import("lit").CSSResult;
|
|
9
|
+
icon?: string;
|
|
10
|
+
value: string;
|
|
11
|
+
protected render(): import("lit-html").TemplateResult<1>;
|
|
12
|
+
private onClick;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=ft-floating-menu-item.d.ts.map
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { html } from "lit";
|
|
8
|
+
import { property } from "lit/decorators.js";
|
|
9
|
+
import { FtLitElement } from "@fluid-topics/ft-wc-utils";
|
|
10
|
+
import { itemStyles } from "./ft-floating-menu-item.css";
|
|
11
|
+
import { FtIcon } from "@fluid-topics/ft-icon";
|
|
12
|
+
import { FtRipple } from "@fluid-topics/ft-ripple";
|
|
13
|
+
import { FtTypography } from "@fluid-topics/ft-typography";
|
|
14
|
+
export class FtFloatingMenuItemSelect extends CustomEvent {
|
|
15
|
+
constructor(value) {
|
|
16
|
+
super("select", { detail: value, bubbles: true, composed: true });
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
export class FtFloatingMenuItem extends FtLitElement {
|
|
20
|
+
constructor() {
|
|
21
|
+
super(...arguments);
|
|
22
|
+
this.value = "";
|
|
23
|
+
}
|
|
24
|
+
render() {
|
|
25
|
+
return html `
|
|
26
|
+
<div class="ft-floating-menu-item"
|
|
27
|
+
@click=${this.onClick}>
|
|
28
|
+
<ft-ripple></ft-ripple>
|
|
29
|
+
<ft-icon variant="material">${this.icon}</ft-icon>
|
|
30
|
+
<ft-typography variant="body2">
|
|
31
|
+
<slot></slot>
|
|
32
|
+
</ft-typography>
|
|
33
|
+
</div>
|
|
34
|
+
`;
|
|
35
|
+
}
|
|
36
|
+
onClick(event) {
|
|
37
|
+
this.dispatchEvent(new FtFloatingMenuItemSelect(this.value));
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
FtFloatingMenuItem.elementDefinitions = {
|
|
41
|
+
"ft-icon": FtIcon,
|
|
42
|
+
"ft-ripple": FtRipple,
|
|
43
|
+
"ft-typography": FtTypography,
|
|
44
|
+
};
|
|
45
|
+
// language=CSS
|
|
46
|
+
FtFloatingMenuItem.styles = itemStyles;
|
|
47
|
+
__decorate([
|
|
48
|
+
property({ type: String })
|
|
49
|
+
], FtFloatingMenuItem.prototype, "icon", void 0);
|
|
50
|
+
__decorate([
|
|
51
|
+
property({ type: String })
|
|
52
|
+
], FtFloatingMenuItem.prototype, "value", void 0);
|
|
53
|
+
//# sourceMappingURL=ft-floating-menu-item.js.map
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const FtFloatingMenuCssVariables: {
|
|
2
|
+
textColor: import("@fluid-topics/ft-wc-utils").FtCssVariable;
|
|
3
|
+
colorSurface: import("@fluid-topics/ft-wc-utils").FtCssVariable;
|
|
4
|
+
menuElevation: import("@fluid-topics/ft-wc-utils").FtCssVariable;
|
|
5
|
+
borderRadiusS: import("@fluid-topics/ft-wc-utils").FtCssVariable;
|
|
6
|
+
};
|
|
7
|
+
export declare const styles: import("lit").CSSResult;
|
|
8
|
+
//# sourceMappingURL=ft-floating-menu.css.d.ts.map
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { css } from "lit";
|
|
2
|
+
import { designSystemVariables, FtCssVariableFactory } from "@fluid-topics/ft-wc-utils";
|
|
3
|
+
export const FtFloatingMenuCssVariables = {
|
|
4
|
+
textColor: FtCssVariableFactory.extend("--ft-floating-menu-text-color", designSystemVariables.colorOnSurfaceHigh),
|
|
5
|
+
colorSurface: FtCssVariableFactory.external(designSystemVariables.colorSurface, "Design system"),
|
|
6
|
+
menuElevation: FtCssVariableFactory.external(designSystemVariables.elevation02, "Design system"),
|
|
7
|
+
borderRadiusS: FtCssVariableFactory.external(designSystemVariables.borderRadiusS, "Design system"),
|
|
8
|
+
};
|
|
9
|
+
// language=CSS
|
|
10
|
+
export const styles = css `
|
|
11
|
+
.ft-floating-menu {
|
|
12
|
+
color: ${FtFloatingMenuCssVariables.textColor};
|
|
13
|
+
position: relative;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.ft-floating-menu--options {
|
|
17
|
+
box-shadow: ${FtFloatingMenuCssVariables.menuElevation};
|
|
18
|
+
background-color: ${FtFloatingMenuCssVariables.colorSurface};
|
|
19
|
+
border-radius: ${FtFloatingMenuCssVariables.borderRadiusS};
|
|
20
|
+
color: ${FtFloatingMenuCssVariables.textColor};
|
|
21
|
+
display: none;
|
|
22
|
+
list-style: none;
|
|
23
|
+
left: 0;
|
|
24
|
+
max-width: calc(100vw - 32px);
|
|
25
|
+
max-height: calc(100vh - 32px);
|
|
26
|
+
margin: 0;
|
|
27
|
+
padding-left: 0;
|
|
28
|
+
position: absolute;
|
|
29
|
+
transform: scale(1);
|
|
30
|
+
transform-origin: left top;
|
|
31
|
+
overflow: auto;
|
|
32
|
+
top: 0;
|
|
33
|
+
transition: opacity 0.03s linear 0s, transform 0.12s cubic-bezier(0, 0, 0.2, 1) 0s, height 250ms cubic-bezier(0, 0, 0.2, 1) 0s;
|
|
34
|
+
opacity: 0;
|
|
35
|
+
will-change: transform, opacity;
|
|
36
|
+
z-index: 8;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
.ft-floating-menu--open .ft-floating-menu--options {
|
|
40
|
+
display: inline-block;
|
|
41
|
+
opacity: 1;
|
|
42
|
+
}
|
|
43
|
+
`;
|
|
44
|
+
//# sourceMappingURL=ft-floating-menu.css.js.map
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ElementDefinitionsMap, FtLitElement } from "@fluid-topics/ft-wc-utils";
|
|
2
|
+
import { FtFloatingMenuProperties } from "./ft-floating-menu.properties";
|
|
3
|
+
export declare class FtFloatingMenu extends FtLitElement implements FtFloatingMenuProperties {
|
|
4
|
+
static elementDefinitions: ElementDefinitionsMap;
|
|
5
|
+
static styles: import("lit").CSSResult;
|
|
6
|
+
private menuOpen;
|
|
7
|
+
private container;
|
|
8
|
+
private menuContainer;
|
|
9
|
+
protected render(): import("lit-html").TemplateResult<1>;
|
|
10
|
+
private onClick;
|
|
11
|
+
private onClickItem;
|
|
12
|
+
private hideOptions;
|
|
13
|
+
disconnectedCallback(): void;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=ft-floating-menu.d.ts.map
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { html } from "lit";
|
|
8
|
+
import { query, state } from "lit/decorators.js";
|
|
9
|
+
import { FtLitElement } from "@fluid-topics/ft-wc-utils";
|
|
10
|
+
import { styles } from "./ft-floating-menu.css";
|
|
11
|
+
import { FtButton } from "@fluid-topics/ft-button";
|
|
12
|
+
import { classMap } from "lit/directives/class-map.js";
|
|
13
|
+
import { FtFloatingMenuItem } from "./ft-floating-menu-item";
|
|
14
|
+
export class FtFloatingMenu extends FtLitElement {
|
|
15
|
+
constructor() {
|
|
16
|
+
super(...arguments);
|
|
17
|
+
this.menuOpen = false;
|
|
18
|
+
this.hideOptions = (e) => {
|
|
19
|
+
this.menuOpen = this.menuOpen && e.composedPath().includes(this.menuContainer);
|
|
20
|
+
if (!this.menuOpen) {
|
|
21
|
+
document.removeEventListener("click", this.hideOptions);
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
render() {
|
|
26
|
+
const classes = {
|
|
27
|
+
"ft-floating-menu": true,
|
|
28
|
+
"ft-floating-menu--open": this.menuOpen,
|
|
29
|
+
};
|
|
30
|
+
return html `
|
|
31
|
+
<div class="${classMap(classes)}">
|
|
32
|
+
<ft-button part="button"
|
|
33
|
+
dense round
|
|
34
|
+
icon="more_vert"
|
|
35
|
+
id="actions-button"
|
|
36
|
+
@click=${this.onClick}
|
|
37
|
+
label="Menu">
|
|
38
|
+
</ft-button>
|
|
39
|
+
<div class="ft-floating-menu--options"
|
|
40
|
+
@select="${this.onClickItem}">
|
|
41
|
+
<slot></slot>
|
|
42
|
+
</div>
|
|
43
|
+
</div>
|
|
44
|
+
`;
|
|
45
|
+
}
|
|
46
|
+
onClick(event) {
|
|
47
|
+
console.log("open");
|
|
48
|
+
this.menuOpen = true;
|
|
49
|
+
setTimeout(() => document.addEventListener("click", this.hideOptions));
|
|
50
|
+
}
|
|
51
|
+
onClickItem(event) {
|
|
52
|
+
console.log("close");
|
|
53
|
+
this.menuOpen = false;
|
|
54
|
+
}
|
|
55
|
+
disconnectedCallback() {
|
|
56
|
+
super.disconnectedCallback();
|
|
57
|
+
document.removeEventListener("click", this.hideOptions);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
FtFloatingMenu.elementDefinitions = {
|
|
61
|
+
"ft-button": FtButton,
|
|
62
|
+
"ft-floating-menu-item": FtFloatingMenuItem,
|
|
63
|
+
};
|
|
64
|
+
// language=CSS
|
|
65
|
+
FtFloatingMenu.styles = styles;
|
|
66
|
+
__decorate([
|
|
67
|
+
state()
|
|
68
|
+
], FtFloatingMenu.prototype, "menuOpen", void 0);
|
|
69
|
+
__decorate([
|
|
70
|
+
query(".ft-floating-menu")
|
|
71
|
+
], FtFloatingMenu.prototype, "container", void 0);
|
|
72
|
+
__decorate([
|
|
73
|
+
query(".ft-floating-menu--options")
|
|
74
|
+
], FtFloatingMenu.prototype, "menuContainer", void 0);
|
|
75
|
+
//# sourceMappingURL=ft-floating-menu.js.map
|