wok-ui-ext 0.1.0 → 0.1.1

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.
@@ -8,6 +8,9 @@ export type { MenuItemData, MenuOptions } from './types';
8
8
  * 垂直菜单,支持多级嵌套、图标、折叠模式。
9
9
  * 适用于侧边栏导航。
10
10
  *
11
+ * 菜单宽度默认 240px,可通过构造参数 `width` 指定(数字,单位 px),
12
+ * 或直接覆写 CSS 变量 `--wok-ui-ext-menu-width` 调整。
13
+ *
11
14
  * @example
12
15
  * ```ts
13
16
  * const menu = new Menu({
@@ -7,6 +7,9 @@ import './style.css';
7
7
  * 垂直菜单,支持多级嵌套、图标、折叠模式。
8
8
  * 适用于侧边栏导航。
9
9
  *
10
+ * 菜单宽度默认 240px,可通过构造参数 `width` 指定(数字,单位 px),
11
+ * 或直接覆写 CSS 变量 `--wok-ui-ext-menu-width` 调整。
12
+ *
10
13
  * @example
11
14
  * ```ts
12
15
  * const menu = new Menu({
@@ -31,6 +34,10 @@ export class Menu extends DivModule {
31
34
  this.nodes = [];
32
35
  if (opts.collapsed)
33
36
  this.el.classList.add('wok-ui-ext-menu-collapsed');
37
+ // 指定宽度时写入 CSS 变量,供样式使用(默认 240px)
38
+ if (opts.width) {
39
+ this.el.style.setProperty('--wok-ui-ext-menu-width', `${opts.width}px`);
40
+ }
34
41
  const ctx = {
35
42
  selectedKey: opts.selectedKey,
36
43
  collapsed: opts.collapsed ?? false,
@@ -1,6 +1,6 @@
1
1
  .wok-ui-ext-menu {
2
2
  background: var(--bg-card);
3
- width: 240px;
3
+ width: var(--wok-ui-ext-menu-width, 240px);
4
4
  display: flex;
5
5
  flex-direction: column;
6
6
  transition: width 0.25s ease;
@@ -86,7 +86,7 @@
86
86
  padding-left: 48px;
87
87
  }
88
88
  .wok-ui-ext-menu.wok-ui-ext-menu-collapsed {
89
- width: 56px;
89
+ width: var(--wok-ui-ext-menu-collapsed-width, 56px);
90
90
  }
91
91
  .wok-ui-ext-menu.wok-ui-ext-menu-collapsed .wok-ui-ext-menu-item {
92
92
  justify-content: center;
@@ -24,6 +24,8 @@ export interface MenuOptions {
24
24
  selectedKey?: string;
25
25
  /** 是否折叠(仅显示图标) */
26
26
  collapsed?: boolean;
27
+ /** 菜单宽度(px,数字)。默认 240 */
28
+ width?: number;
27
29
  /** 点击菜单项回调 */
28
30
  onClick?: (key: string) => void;
29
31
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wok-ui-ext",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "description": "wok-ui 的扩展库,提供一套科技蓝风格 + 多主题的组件库,覆盖常用的组件",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",