@cfx-dev/ui-components 4.2.7 → 4.2.9

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.
@@ -3,6 +3,7 @@
3
3
  @import "./css/Avatar.css";
4
4
  @import "./css/Badge.css";
5
5
  @import "./css/Box.css";
6
+ @import "./css/BurgerMenu.css";
6
7
  @import "./css/Button.css";
7
8
  @import "./css/ButtonBar.css";
8
9
  @import "./css/Center.css";
@@ -0,0 +1 @@
1
+ .cfxui__BurgerMenu__burgerButton__cc9ab{width:calc(var(--quant) * 3.25);height:calc(var(--quant) * 3.25);cursor:pointer}.cfxui__BurgerMenu__burgerContainerOpen__ed7ab{background:rgba(var(--color-bg-light),1);height:var(--height)}.cfxui__BurgerMenu__burgerLine__886ad,.cfxui__BurgerMenu__burgerLineOpen__af602{width:100%;height:calc(var(--quant) * .3);background-color:rgba(var(--color-primary),1);border-radius:var(--border-radius-xsmall)}.cfxui__BurgerMenu__burgerLine__886ad,.cfxui__BurgerMenu__burgerLineOpen__af602{transition:all .25s ease,outline-offset 0s,outline 0s}.cfxui__BurgerMenu__burgerLineOpen__af602:nth-child(1){transform:rotate(45deg) translate(5px,5px)}.cfxui__BurgerMenu__burgerLineOpen__af602:nth-child(1){transition:all .25s ease,outline-offset 0s,outline 0s}.cfxui__BurgerMenu__burgerLineOpen__af602:nth-child(2){opacity:0}.cfxui__BurgerMenu__burgerLineOpen__af602:nth-child(2){transition:all .25s ease,outline-offset 0s,outline 0s}.cfxui__BurgerMenu__burgerLineOpen__af602:nth-child(3){transform:rotate(-45deg) translate(7px,-7px)}.cfxui__BurgerMenu__burgerLineOpen__af602:nth-child(3){transition:all .25s ease,outline-offset 0s,outline 0s}.cfxui__BurgerMenu__subItemContainer__0d64a{background-color:rgba(var(--color-secondary),.25);max-height:0;overflow:hidden}.cfxui__BurgerMenu__subItemContainer__0d64a{transition:all .25s ease,outline-offset 0s,outline 0s}.cfxui__BurgerMenu__subItemContainerOpen__5491d{max-height:var(--height)}
@@ -0,0 +1,15 @@
1
+ import { default as React } from 'react';
2
+
3
+ interface MenuItem {
4
+ label: string;
5
+ highlighted?: boolean;
6
+ id: string;
7
+ className?: string;
8
+ submenu?: MenuItem[];
9
+ }
10
+ interface BurgerMenuProps {
11
+ items: MenuItem[];
12
+ onItemClick: (item: string) => void;
13
+ }
14
+ export declare function BurgerMenu({ items, onItemClick, }: BurgerMenuProps): React.ReactElement;
15
+ export {};
@@ -0,0 +1,138 @@
1
+ import { jsxs as a, jsx as n } from "react/jsx-runtime";
2
+ import { useState as f, useCallback as l } from "react";
3
+ import { Icon as O } from "../Icon/Icon.js";
4
+ import { Interactive as c } from "../Interactive/Interactive.js";
5
+ import { Flex as u } from "../Layout/Flex/Flex.js";
6
+ import { Text as x } from "../Text/Text.js";
7
+ import "../ui.js";
8
+ import { clsx as t } from "../../utils/clsx.js";
9
+ const y = "cfxui__BurgerMenu__burgerButton__cc9ab", L = "cfxui__BurgerMenu__burgerContainerOpen__ed7ab", B = "cfxui__BurgerMenu__burgerLine__886ad", k = "cfxui__BurgerMenu__burgerLineOpen__af602", w = "cfxui__BurgerMenu__subItemContainer__0d64a", I = "cfxui__BurgerMenu__subItemContainerOpen__5491d", r = {
10
+ burgerButton: y,
11
+ burgerContainerOpen: L,
12
+ burgerLine: B,
13
+ burgerLineOpen: k,
14
+ subItemContainer: w,
15
+ subItemContainerOpen: I
16
+ };
17
+ function K({
18
+ items: h,
19
+ onItemClick: b
20
+ }) {
21
+ const [i, g] = f(!1), [d, C] = f({}), p = l(() => {
22
+ g((e) => !e);
23
+ }, []), s = l((e) => {
24
+ b(e), g(!1);
25
+ }, [b]), _ = l((e) => {
26
+ C((o) => ({
27
+ ...o,
28
+ [e]: !o[e]
29
+ }));
30
+ }, []);
31
+ return /* @__PURE__ */ a(
32
+ u,
33
+ {
34
+ className: t({ [r.burgerContainerOpen]: i }),
35
+ direction: "column",
36
+ children: [
37
+ /* @__PURE__ */ n(u, { justifyContent: "flex-end", children: /* @__PURE__ */ n(
38
+ c,
39
+ {
40
+ showPointer: !0,
41
+ "aria-label": "Toggle menu",
42
+ role: "button",
43
+ onClick: p,
44
+ onKeyDown: (e) => {
45
+ (e.key === "Enter" || e.key === " ") && p();
46
+ },
47
+ children: /* @__PURE__ */ a(
48
+ u,
49
+ {
50
+ justifyContent: "space-around",
51
+ direction: "column",
52
+ className: r.burgerButton,
53
+ children: [
54
+ /* @__PURE__ */ n(
55
+ "span",
56
+ {
57
+ className: t(i ? r.burgerLineOpen : r.burgerLine)
58
+ }
59
+ ),
60
+ /* @__PURE__ */ n(
61
+ "span",
62
+ {
63
+ className: t(i ? r.burgerLineOpen : r.burgerLine)
64
+ }
65
+ ),
66
+ /* @__PURE__ */ n(
67
+ "span",
68
+ {
69
+ className: t(i ? r.burgerLineOpen : r.burgerLine)
70
+ }
71
+ )
72
+ ]
73
+ }
74
+ )
75
+ }
76
+ ) }),
77
+ i && /* @__PURE__ */ n(u, { direction: "column", className: r.menu, children: h.map((e) => /* @__PURE__ */ a("div", { children: [
78
+ /* @__PURE__ */ n(
79
+ c,
80
+ {
81
+ showPointer: !0,
82
+ "aria-label": "Toggle item",
83
+ role: "button",
84
+ onClick: () => {
85
+ e.submenu ? _(e.id) : s(e.id);
86
+ },
87
+ onKeyDown: (o) => {
88
+ (o.key === "Enter" || o.key === " ") && (e.submenu ? _(e.id) : s(e.id));
89
+ },
90
+ children: /* @__PURE__ */ a(u, { p: 2, justifyContent: "space-between", children: [
91
+ /* @__PURE__ */ n(
92
+ x,
93
+ {
94
+ size: "xsmall",
95
+ weight: e.highlighted ? "bold" : "normal",
96
+ children: e.label
97
+ }
98
+ ),
99
+ e.submenu && /* @__PURE__ */ n(
100
+ O,
101
+ {
102
+ name: d[e.id] ? "UpChevron" : "DownChevron"
103
+ }
104
+ )
105
+ ] })
106
+ }
107
+ ),
108
+ e.submenu && /* @__PURE__ */ n(
109
+ u,
110
+ {
111
+ className: t(r.subItemContainer, {
112
+ [r.subItemContainerOpen]: d[e.id]
113
+ }),
114
+ direction: "column",
115
+ children: e.submenu.map((o) => /* @__PURE__ */ n(
116
+ c,
117
+ {
118
+ showPointer: !0,
119
+ "aria-label": "Toggle sub item",
120
+ role: "button",
121
+ onClick: () => s(o.id),
122
+ onKeyDown: (m) => {
123
+ (m.key === "Enter" || m.key === " ") && s(o.id);
124
+ },
125
+ children: /* @__PURE__ */ n(u, { p: 2, children: o.label })
126
+ },
127
+ o.id
128
+ ))
129
+ }
130
+ )
131
+ ] }, e.id)) })
132
+ ]
133
+ }
134
+ );
135
+ }
136
+ export {
137
+ K as BurgerMenu
138
+ };
@@ -0,0 +1,5 @@
1
+ import { default as React } from 'react';
2
+
3
+ declare function BurgerMenuShowcase(): import("react/jsx-runtime").JSX.Element;
4
+ declare const _default: React.MemoExoticComponent<typeof BurgerMenuShowcase>;
5
+ export default _default;
@@ -0,0 +1,53 @@
1
+ import { jsx as e, jsxs as l } from "react/jsx-runtime";
2
+ import i from "react";
3
+ import { Flex as r } from "../Layout/Flex/Flex.js";
4
+ import { Text as o } from "../Text/Text.js";
5
+ import "../ui.js";
6
+ import { BurgerMenu as n } from "./BurgerMenu.js";
7
+ const a = [
8
+ {
9
+ id: "1",
10
+ label: "Account",
11
+ highlighted: !0
12
+ },
13
+ {
14
+ id: "2",
15
+ label: "Dashboard"
16
+ },
17
+ {
18
+ id: "3",
19
+ label: "Servers",
20
+ submenu: [
21
+ {
22
+ id: "3-1",
23
+ label: "Server Keys"
24
+ },
25
+ {
26
+ id: "3-2",
27
+ label: "Server Hosting"
28
+ }
29
+ ]
30
+ },
31
+ {
32
+ id: "4",
33
+ label: "Settings"
34
+ }
35
+ ], m = (t) => {
36
+ console.log(`Item clicked: ${t}`);
37
+ };
38
+ function c() {
39
+ return /* @__PURE__ */ e(r, { gap: "large", vertical: !0, pb: 20, children: /* @__PURE__ */ l(r, { gap: "normal", vertical: !0, children: [
40
+ /* @__PURE__ */ e(o, { children: "Burger Menu" }),
41
+ /* @__PURE__ */ e("div", { children: /* @__PURE__ */ e(
42
+ n,
43
+ {
44
+ items: a,
45
+ onItemClick: m
46
+ }
47
+ ) })
48
+ ] }) });
49
+ }
50
+ const b = i.memo(c);
51
+ export {
52
+ b as default
53
+ };
@@ -0,0 +1 @@
1
+ export { BurgerMenu } from './BurgerMenu';
@@ -0,0 +1,4 @@
1
+ import { BurgerMenu as o } from "./BurgerMenu.js";
2
+ export {
3
+ o as BurgerMenu
4
+ };