@hypericon/mico 0.2.2 → 0.2.4

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.
@@ -4,6 +4,8 @@ export declare const MenuButton: m.Component<{
4
4
  icon?: m.Vnode<any, any> | IconAttrs;
5
5
  label?: string;
6
6
  hint?: string;
7
+ /** If an href is supplied, `m.route.Link` is used instad of `button` */
8
+ href?: string;
7
9
  disabled?: boolean;
8
10
  onclick?: (ev: MouseEvent) => any;
9
11
  onhover?: (ev: MouseEvent) => any;
@@ -9,39 +9,73 @@ const icon_1 = require("../icon");
9
9
  const menu_settings_1 = require("./menu-settings");
10
10
  exports.MenuButton = {
11
11
  view({ attrs }) {
12
- var _a, _b;
13
- return (0, mithril_1.default)("button", {
14
- class: `${(_a = attrs.class) !== null && _a !== void 0 ? _a : ""} ${menu_settings_1.MENU_SETTINGS.MENU_BUTTON_CLASS}`,
15
- style: `${(_b = attrs.style) !== null && _b !== void 0 ? _b : ""} width: 100%; height: 1.5rem; padding-right: 0.5rem; display: flex; align-items: center;`,
16
- disabled: attrs.disabled,
17
- onclick: (ev) => {
18
- var _a;
19
- (_a = attrs.onclick) === null || _a === void 0 ? void 0 : _a.call(attrs, ev);
20
- mithril_1.default.redraw();
21
- },
22
- }, [
23
- (0, mithril_1.default)("", {
24
- // class: attrs.disabled ? "text-disabled" : "text-icon",
25
- class: menu_settings_1.MENU_SETTINGS.MENU_BUTTON_ICON_CLASS,
26
- style: "width: 2rem; flex: none; display: flex; align-items: center; justify-content: space-around;",
12
+ var _a, _b, _c, _d;
13
+ return (attrs.href !== undefined) ? [
14
+ (0, mithril_1.default)(mithril_1.default.route.Link, {
15
+ class: `${(_a = attrs.class) !== null && _a !== void 0 ? _a : ""} ${menu_settings_1.MENU_SETTINGS.MENU_BUTTON_CLASS}`,
16
+ style: `${(_b = attrs.style) !== null && _b !== void 0 ? _b : ""} width: 100%; height: 1.5rem; padding-right: 0.5rem; display: flex; align-items: center;`,
17
+ href: attrs.href,
18
+ disabled: attrs.disabled,
19
+ onclick: (ev) => {
20
+ var _a;
21
+ (_a = attrs.onclick) === null || _a === void 0 ? void 0 : _a.call(attrs, ev);
22
+ mithril_1.default.redraw();
23
+ },
27
24
  }, [
28
- attrs.icon ? [
29
- ("fas" in attrs.icon || "far" in attrs.icon || "fab" in attrs.icon)
30
- ? (0, mithril_1.default)(icon_1.Icon, Object.assign({}, attrs.icon))
31
- : attrs.icon,
32
- ] : [],
25
+ (0, mithril_1.default)(ButtonIcon, { icon: attrs.icon }),
26
+ (0, mithril_1.default)(ButtonLabel, { label: attrs.label }),
27
+ (0, mithril_1.default)("", { style: "flex: 1 1 0%;" }),
28
+ (0, mithril_1.default)(ButtonHint, { hint: attrs.hint }),
33
29
  ]),
34
- (0, mithril_1.default)("span", {
35
- class: menu_settings_1.MENU_SETTINGS.MENU_BUTTON_LABEL_CLASS,
36
- style: "overflow: hidden; text-overflow: ellipsis; white-space: nowrap;",
37
- }, attrs.label),
38
- (0, mithril_1.default)("", { style: "flex: 1 1 0%;" }),
39
- attrs.hint
40
- ? (0, mithril_1.default)("span", {
41
- class: menu_settings_1.MENU_SETTINGS.MENU_BUTTON_HINT_CLASS,
42
- style: "overflow: hidden; text-overflow: ellipsis; white-space: nowrap;",
43
- }, attrs.hint)
44
- : [],
30
+ ] : [
31
+ (0, mithril_1.default)("button", {
32
+ class: `${(_c = attrs.class) !== null && _c !== void 0 ? _c : ""} ${menu_settings_1.MENU_SETTINGS.MENU_BUTTON_CLASS}`,
33
+ style: `${(_d = attrs.style) !== null && _d !== void 0 ? _d : ""} width: 100%; height: 1.5rem; padding-right: 0.5rem; display: flex; align-items: center;`,
34
+ disabled: attrs.disabled,
35
+ onclick: (ev) => {
36
+ var _a;
37
+ (_a = attrs.onclick) === null || _a === void 0 ? void 0 : _a.call(attrs, ev);
38
+ mithril_1.default.redraw();
39
+ },
40
+ }, [
41
+ (0, mithril_1.default)(ButtonIcon, { icon: attrs.icon }),
42
+ (0, mithril_1.default)(ButtonLabel, { label: attrs.label }),
43
+ (0, mithril_1.default)("", { style: "flex: 1 1 0%;" }),
44
+ (0, mithril_1.default)(ButtonHint, { hint: attrs.hint }),
45
+ ]),
46
+ ];
47
+ }
48
+ };
49
+ const ButtonIcon = {
50
+ view({ attrs }) {
51
+ return (0, mithril_1.default)("", {
52
+ // class: attrs.disabled ? "text-disabled" : "text-icon",
53
+ class: menu_settings_1.MENU_SETTINGS.MENU_BUTTON_ICON_CLASS,
54
+ style: "width: 2rem; flex: none; display: flex; align-items: center; justify-content: space-around;",
55
+ }, [
56
+ attrs.icon ? [
57
+ ("fas" in attrs.icon || "far" in attrs.icon || "fab" in attrs.icon)
58
+ ? (0, mithril_1.default)(icon_1.Icon, Object.assign({}, attrs.icon))
59
+ : attrs.icon,
60
+ ] : [],
45
61
  ]);
46
62
  }
47
63
  };
64
+ const ButtonLabel = {
65
+ view({ attrs }) {
66
+ return (0, mithril_1.default)("span", {
67
+ class: menu_settings_1.MENU_SETTINGS.MENU_BUTTON_LABEL_CLASS,
68
+ style: "overflow: hidden; text-overflow: ellipsis; white-space: nowrap;",
69
+ }, attrs.label);
70
+ }
71
+ };
72
+ const ButtonHint = {
73
+ view({ attrs }) {
74
+ return attrs.hint
75
+ ? (0, mithril_1.default)("span", {
76
+ class: menu_settings_1.MENU_SETTINGS.MENU_BUTTON_HINT_CLASS,
77
+ style: "overflow: hidden; text-overflow: ellipsis; white-space: nowrap;",
78
+ }, attrs.hint)
79
+ : [];
80
+ }
81
+ };
@@ -11,7 +11,7 @@ exports.MenuSeparator = {
11
11
  // return m(".my-2.ml-8.mr-2.border-b.border-slate-300");
12
12
  return (0, mithril_1.default)("", {
13
13
  class: menu_settings_1.MENU_SETTINGS.MENU_SEPARATOR_CLASS,
14
- style: "margin: 0.25rem 0; border-bottom: 1px;",
14
+ style: "margin: 0.25rem 0; border-bottom: 1px solid;",
15
15
  });
16
16
  }
17
17
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hypericon/mico",
3
- "version": "0.2.2",
3
+ "version": "0.2.4",
4
4
  "description": "UI components and utilities with Mithril",
5
5
  "author": "Ed Johnson, Hypericon Ltd",
6
6
  "license": "MIT",