@postenbring/hedwig-react 0.0.1 → 0.0.3

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.
@@ -1,12 +1,37 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
1
2
  import * as React from 'react';
2
3
 
3
- interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
4
- children: React.ReactNode;
4
+ interface ButtonProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, "className" | "style"> {
5
+ /**
6
+ * The height, font size and padding of the button
7
+ */
5
8
  size?: "small" | "medium" | "large";
9
+ /**
10
+ * Make the button use 100% width available.
11
+ * Using the "mobile" it only stretch to full width on smaller screens
12
+ */
13
+ fullWidth?: boolean | "mobile";
14
+ /**
15
+ * The background of the button.
16
+ */
17
+ fill?: "contained" | "outlined";
18
+ children: React.ReactNode;
19
+ buttonRef?: React.ForwardedRef<HTMLButtonElement>;
20
+ }
21
+ /**
22
+ * ## TODO
23
+ *
24
+ * - [ ] Handle links that looks like buttons
25
+ * - [ ] Revisit how to handle outline
26
+ * - [ ] Figure out outline-white
27
+ */
28
+ declare function PrimaryButton(props: ButtonProps): react_jsx_runtime.JSX.Element;
29
+ declare namespace PrimaryButton {
30
+ var displayName: string;
6
31
  }
7
- declare function Button({ children, style, className, size, ...rest }: ButtonProps): JSX.Element;
8
- declare namespace Button {
32
+ declare function SecondaryButton(props: ButtonProps): react_jsx_runtime.JSX.Element;
33
+ declare namespace SecondaryButton {
9
34
  var displayName: string;
10
35
  }
11
36
 
12
- export { Button, ButtonProps };
37
+ export { PrimaryButton, SecondaryButton };
@@ -1,12 +1,37 @@
1
+ import * as react_jsx_runtime from 'react/jsx-runtime';
1
2
  import * as React from 'react';
2
3
 
3
- interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
4
- children: React.ReactNode;
4
+ interface ButtonProps extends Omit<React.ButtonHTMLAttributes<HTMLButtonElement>, "className" | "style"> {
5
+ /**
6
+ * The height, font size and padding of the button
7
+ */
5
8
  size?: "small" | "medium" | "large";
9
+ /**
10
+ * Make the button use 100% width available.
11
+ * Using the "mobile" it only stretch to full width on smaller screens
12
+ */
13
+ fullWidth?: boolean | "mobile";
14
+ /**
15
+ * The background of the button.
16
+ */
17
+ fill?: "contained" | "outlined";
18
+ children: React.ReactNode;
19
+ buttonRef?: React.ForwardedRef<HTMLButtonElement>;
20
+ }
21
+ /**
22
+ * ## TODO
23
+ *
24
+ * - [ ] Handle links that looks like buttons
25
+ * - [ ] Revisit how to handle outline
26
+ * - [ ] Figure out outline-white
27
+ */
28
+ declare function PrimaryButton(props: ButtonProps): react_jsx_runtime.JSX.Element;
29
+ declare namespace PrimaryButton {
30
+ var displayName: string;
6
31
  }
7
- declare function Button({ children, style, className, size, ...rest }: ButtonProps): JSX.Element;
8
- declare namespace Button {
32
+ declare function SecondaryButton(props: ButtonProps): react_jsx_runtime.JSX.Element;
33
+ declare namespace SecondaryButton {
9
34
  var displayName: string;
10
35
  }
11
36
 
12
- export { Button, ButtonProps };
37
+ export { PrimaryButton, SecondaryButton };
@@ -49,51 +49,73 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
49
49
  // src/button/index.tsx
50
50
  var button_exports = {};
51
51
  __export(button_exports, {
52
- Button: () => Button
52
+ PrimaryButton: () => PrimaryButton,
53
+ SecondaryButton: () => SecondaryButton
53
54
  });
54
55
  module.exports = __toCommonJS(button_exports);
56
+ var import_tokens = require("@postenbring/hedwig-tokens/tokens-output/css/tokens.css");
57
+ var import_base = require("@postenbring/hedwig-css/dist/base.css");
55
58
  var import_button = require("@postenbring/hedwig-css/dist/button/button.css");
56
59
 
57
60
  // src/button/button.tsx
58
61
  var import_clsx = require("clsx");
59
62
 
60
63
  // src/utils.ts
61
- function warnForStyleOverrides(className, styles) {
62
- if (className) {
64
+ function warnForStyleOverrides(props) {
65
+ if (props.className) {
63
66
  console.warn("Overriding styles are not premited");
64
67
  }
65
- if (styles) {
68
+ if (props.styles) {
66
69
  console.warn("Overriding styles are not premited");
67
70
  }
68
71
  }
69
72
 
70
73
  // src/button/button.tsx
71
74
  var import_jsx_runtime = require("react/jsx-runtime");
72
- function Button(_a) {
75
+ function BaseButton(_a) {
73
76
  var _b = _a, {
74
77
  children,
75
- style,
76
- className,
77
- size = "medium"
78
+ variant,
79
+ size = "medium",
80
+ fullWidth = false,
81
+ fill = "contained",
82
+ buttonRef
78
83
  } = _b, rest = __objRest(_b, [
79
84
  "children",
80
- "style",
81
- "className",
82
- "size"
85
+ "variant",
86
+ "size",
87
+ "fullWidth",
88
+ "fill",
89
+ "buttonRef"
83
90
  ]);
84
- warnForStyleOverrides(style, className);
91
+ warnForStyleOverrides(rest);
85
92
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
86
93
  "button",
87
94
  __spreadProps(__spreadValues({
88
- className: (0, import_clsx.clsx)("hds-button", "hds-button--primary", `hds-button--${size}`),
95
+ className: (0, import_clsx.clsx)("hds-button", `hds-button--${size}`, {
96
+ [`hds-button--${variant}`]: fill === "contained",
97
+ [`hds-button--outline-${variant}`]: fill === "outlined",
98
+ "hds-button--full": fullWidth === true,
99
+ "hds-button--mobile-full": fullWidth === "mobile"
100
+ }),
101
+ ref: buttonRef,
89
102
  type: "button"
90
103
  }, rest), {
91
104
  children
92
105
  })
93
106
  );
94
107
  }
95
- Button.displayName = "Button";
108
+ BaseButton.displayName = "BaseButton";
109
+ function PrimaryButton(props) {
110
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(BaseButton, __spreadProps(__spreadValues({}, props), { variant: "primary" }));
111
+ }
112
+ PrimaryButton.displayName = "PrimaryButton";
113
+ function SecondaryButton(props) {
114
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(BaseButton, __spreadProps(__spreadValues({}, props), { variant: "secondary" }));
115
+ }
116
+ SecondaryButton.displayName = "SecondaryButton";
96
117
  // Annotate the CommonJS export names for ESM import in node:
97
118
  0 && (module.exports = {
98
- Button
119
+ PrimaryButton,
120
+ SecondaryButton
99
121
  });
@@ -1,6 +1,8 @@
1
1
  import {
2
- Button
3
- } from "../chunk-EG5TPDNX.mjs";
2
+ PrimaryButton,
3
+ SecondaryButton
4
+ } from "../chunk-ZPSTPWVB.mjs";
4
5
  export {
5
- Button
6
+ PrimaryButton,
7
+ SecondaryButton
6
8
  };
@@ -31,48 +31,73 @@ var __objRest = (source, exclude) => {
31
31
  };
32
32
 
33
33
  // src/button/index.tsx
34
+ import "@postenbring/hedwig-tokens/tokens-output/css/tokens.css";
35
+ import "@postenbring/hedwig-css/dist/base.css";
34
36
  import "@postenbring/hedwig-css/dist/button/button.css";
35
37
 
36
38
  // src/button/button.tsx
37
39
  import { clsx } from "clsx";
38
40
 
39
41
  // src/utils.ts
40
- function warnForStyleOverrides(className, styles) {
41
- if (className) {
42
+ function warnForStyleOverrides(props) {
43
+ if (props.className) {
42
44
  console.warn("Overriding styles are not premited");
43
45
  }
44
- if (styles) {
46
+ if (props.styles) {
45
47
  console.warn("Overriding styles are not premited");
46
48
  }
47
49
  }
48
50
 
49
51
  // src/button/button.tsx
50
52
  import { jsx } from "react/jsx-runtime";
51
- function Button(_a) {
53
+ function BaseButton(_a) {
52
54
  var _b = _a, {
53
55
  children,
54
- style,
55
- className,
56
- size = "medium"
56
+ variant,
57
+ size = "medium",
58
+ fullWidth = false,
59
+ fill = "contained",
60
+ buttonRef
57
61
  } = _b, rest = __objRest(_b, [
58
62
  "children",
59
- "style",
60
- "className",
61
- "size"
63
+ "variant",
64
+ "size",
65
+ "fullWidth",
66
+ "fill",
67
+ "buttonRef"
62
68
  ]);
63
- warnForStyleOverrides(style, className);
69
+ warnForStyleOverrides(rest);
64
70
  return /* @__PURE__ */ jsx(
65
71
  "button",
66
72
  __spreadProps(__spreadValues({
67
- className: clsx("hds-button", "hds-button--primary", `hds-button--${size}`),
73
+ className: clsx("hds-button", `hds-button--${size}`, {
74
+ [`hds-button--${variant}`]: fill === "contained",
75
+ [`hds-button--outline-${variant}`]: fill === "outlined",
76
+ "hds-button--full": fullWidth === true,
77
+ "hds-button--mobile-full": fullWidth === "mobile"
78
+ }),
79
+ ref: buttonRef,
68
80
  type: "button"
69
81
  }, rest), {
70
82
  children
71
83
  })
72
84
  );
73
85
  }
74
- Button.displayName = "Button";
86
+ BaseButton.displayName = "BaseButton";
87
+ function PrimaryButton(props) {
88
+ return /* @__PURE__ */ jsx(BaseButton, __spreadProps(__spreadValues({}, props), { variant: "primary" }));
89
+ }
90
+ PrimaryButton.displayName = "PrimaryButton";
91
+ function SecondaryButton(props) {
92
+ return /* @__PURE__ */ jsx(BaseButton, __spreadProps(__spreadValues({}, props), { variant: "secondary" }));
93
+ }
94
+ SecondaryButton.displayName = "SecondaryButton";
75
95
 
76
96
  export {
77
- Button
97
+ __spreadValues,
98
+ __spreadProps,
99
+ __objRest,
100
+ warnForStyleOverrides,
101
+ PrimaryButton,
102
+ SecondaryButton
78
103
  };
package/dist/index.d.mts CHANGED
@@ -1,2 +1,27 @@
1
- export { Button, ButtonProps } from './button/index.mjs';
2
- import 'react';
1
+ export { PrimaryButton, SecondaryButton } from './button/index.mjs';
2
+ import * as react_jsx_runtime from 'react/jsx-runtime';
3
+ import * as React from 'react';
4
+
5
+ interface LinkProps extends Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, "className" | "style"> {
6
+ /**
7
+ * The visual style of the link
8
+ */
9
+ variant?: "underline" | "solid" | "inverted" | "no-underline";
10
+ /**
11
+ * Font size of the link
12
+ */
13
+ size?: "small" | "medium" | "large";
14
+ children: React.ReactNode;
15
+ anchorRef?: React.ForwardedRef<HTMLAnchorElement>;
16
+ }
17
+ /**
18
+ * ## TODO
19
+ *
20
+ * - [ ] Handle button styling
21
+ */
22
+ declare function Link({ children, variant, size, anchorRef, ...rest }: LinkProps): react_jsx_runtime.JSX.Element;
23
+ declare namespace Link {
24
+ var displayName: string;
25
+ }
26
+
27
+ export { Link };
package/dist/index.d.ts CHANGED
@@ -1,2 +1,27 @@
1
- export { Button, ButtonProps } from './button/index.js';
2
- import 'react';
1
+ export { PrimaryButton, SecondaryButton } from './button/index.js';
2
+ import * as react_jsx_runtime from 'react/jsx-runtime';
3
+ import * as React from 'react';
4
+
5
+ interface LinkProps extends Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, "className" | "style"> {
6
+ /**
7
+ * The visual style of the link
8
+ */
9
+ variant?: "underline" | "solid" | "inverted" | "no-underline";
10
+ /**
11
+ * Font size of the link
12
+ */
13
+ size?: "small" | "medium" | "large";
14
+ children: React.ReactNode;
15
+ anchorRef?: React.ForwardedRef<HTMLAnchorElement>;
16
+ }
17
+ /**
18
+ * ## TODO
19
+ *
20
+ * - [ ] Handle button styling
21
+ */
22
+ declare function Link({ children, variant, size, anchorRef, ...rest }: LinkProps): react_jsx_runtime.JSX.Element;
23
+ declare namespace Link {
24
+ var displayName: string;
25
+ }
26
+
27
+ export { Link };
package/dist/index.js CHANGED
@@ -49,53 +49,113 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
49
49
  // src/index.tsx
50
50
  var src_exports = {};
51
51
  __export(src_exports, {
52
- Button: () => Button
52
+ Link: () => Link,
53
+ PrimaryButton: () => PrimaryButton,
54
+ SecondaryButton: () => SecondaryButton
53
55
  });
54
56
  module.exports = __toCommonJS(src_exports);
55
57
 
56
58
  // src/button/index.tsx
59
+ var import_tokens = require("@postenbring/hedwig-tokens/tokens-output/css/tokens.css");
60
+ var import_base = require("@postenbring/hedwig-css/dist/base.css");
57
61
  var import_button = require("@postenbring/hedwig-css/dist/button/button.css");
58
62
 
59
63
  // src/button/button.tsx
60
64
  var import_clsx = require("clsx");
61
65
 
62
66
  // src/utils.ts
63
- function warnForStyleOverrides(className, styles) {
64
- if (className) {
67
+ function warnForStyleOverrides(props) {
68
+ if (props.className) {
65
69
  console.warn("Overriding styles are not premited");
66
70
  }
67
- if (styles) {
71
+ if (props.styles) {
68
72
  console.warn("Overriding styles are not premited");
69
73
  }
70
74
  }
71
75
 
72
76
  // src/button/button.tsx
73
77
  var import_jsx_runtime = require("react/jsx-runtime");
74
- function Button(_a) {
78
+ function BaseButton(_a) {
75
79
  var _b = _a, {
76
80
  children,
77
- style,
78
- className,
79
- size = "medium"
81
+ variant,
82
+ size = "medium",
83
+ fullWidth = false,
84
+ fill = "contained",
85
+ buttonRef
80
86
  } = _b, rest = __objRest(_b, [
81
87
  "children",
82
- "style",
83
- "className",
84
- "size"
88
+ "variant",
89
+ "size",
90
+ "fullWidth",
91
+ "fill",
92
+ "buttonRef"
85
93
  ]);
86
- warnForStyleOverrides(style, className);
94
+ warnForStyleOverrides(rest);
87
95
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
88
96
  "button",
89
97
  __spreadProps(__spreadValues({
90
- className: (0, import_clsx.clsx)("hds-button", "hds-button--primary", `hds-button--${size}`),
98
+ className: (0, import_clsx.clsx)("hds-button", `hds-button--${size}`, {
99
+ [`hds-button--${variant}`]: fill === "contained",
100
+ [`hds-button--outline-${variant}`]: fill === "outlined",
101
+ "hds-button--full": fullWidth === true,
102
+ "hds-button--mobile-full": fullWidth === "mobile"
103
+ }),
104
+ ref: buttonRef,
91
105
  type: "button"
92
106
  }, rest), {
93
107
  children
94
108
  })
95
109
  );
96
110
  }
97
- Button.displayName = "Button";
111
+ BaseButton.displayName = "BaseButton";
112
+ function PrimaryButton(props) {
113
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(BaseButton, __spreadProps(__spreadValues({}, props), { variant: "primary" }));
114
+ }
115
+ PrimaryButton.displayName = "PrimaryButton";
116
+ function SecondaryButton(props) {
117
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(BaseButton, __spreadProps(__spreadValues({}, props), { variant: "secondary" }));
118
+ }
119
+ SecondaryButton.displayName = "SecondaryButton";
120
+
121
+ // src/link/index.tsx
122
+ var import_tokens2 = require("@postenbring/hedwig-tokens/tokens-output/css/tokens.css");
123
+ var import_base2 = require("@postenbring/hedwig-css/dist/base.css");
124
+ var import_link = require("@postenbring/hedwig-css/dist/link/link.css");
125
+
126
+ // src/link/link.tsx
127
+ var import_clsx2 = require("clsx");
128
+ var import_jsx_runtime2 = require("react/jsx-runtime");
129
+ function Link(_a) {
130
+ var _b = _a, {
131
+ children,
132
+ variant = "underline",
133
+ size = "medium",
134
+ anchorRef
135
+ } = _b, rest = __objRest(_b, [
136
+ "children",
137
+ "variant",
138
+ "size",
139
+ "anchorRef"
140
+ ]);
141
+ warnForStyleOverrides(rest);
142
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
143
+ "a",
144
+ __spreadProps(__spreadValues({
145
+ className: (0, import_clsx2.clsx)("hds-link", {
146
+ [`hds-link--${variant}`]: variant !== "underline",
147
+ [`hds-link--${size}`]: size !== "medium"
148
+ }),
149
+ ref: anchorRef
150
+ }, rest), {
151
+ children
152
+ })
153
+ );
154
+ }
155
+ Link.displayName = "Link";
98
156
  // Annotate the CommonJS export names for ESM import in node:
99
157
  0 && (module.exports = {
100
- Button
158
+ Link,
159
+ PrimaryButton,
160
+ SecondaryButton
101
161
  });
package/dist/index.mjs CHANGED
@@ -1,6 +1,49 @@
1
1
  import {
2
- Button
3
- } from "./chunk-EG5TPDNX.mjs";
2
+ PrimaryButton,
3
+ SecondaryButton,
4
+ __objRest,
5
+ __spreadProps,
6
+ __spreadValues,
7
+ warnForStyleOverrides
8
+ } from "./chunk-ZPSTPWVB.mjs";
9
+
10
+ // src/link/index.tsx
11
+ import "@postenbring/hedwig-tokens/tokens-output/css/tokens.css";
12
+ import "@postenbring/hedwig-css/dist/base.css";
13
+ import "@postenbring/hedwig-css/dist/link/link.css";
14
+
15
+ // src/link/link.tsx
16
+ import { clsx } from "clsx";
17
+ import { jsx } from "react/jsx-runtime";
18
+ function Link(_a) {
19
+ var _b = _a, {
20
+ children,
21
+ variant = "underline",
22
+ size = "medium",
23
+ anchorRef
24
+ } = _b, rest = __objRest(_b, [
25
+ "children",
26
+ "variant",
27
+ "size",
28
+ "anchorRef"
29
+ ]);
30
+ warnForStyleOverrides(rest);
31
+ return /* @__PURE__ */ jsx(
32
+ "a",
33
+ __spreadProps(__spreadValues({
34
+ className: clsx("hds-link", {
35
+ [`hds-link--${variant}`]: variant !== "underline",
36
+ [`hds-link--${size}`]: size !== "medium"
37
+ }),
38
+ ref: anchorRef
39
+ }, rest), {
40
+ children
41
+ })
42
+ );
43
+ }
44
+ Link.displayName = "Link";
4
45
  export {
5
- Button
46
+ Link,
47
+ PrimaryButton,
48
+ SecondaryButton
6
49
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@postenbring/hedwig-react",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.ts",
@@ -27,6 +27,7 @@
27
27
  },
28
28
  "dependencies": {
29
29
  "@postenbring/hedwig-css": "*",
30
+ "@postenbring/hedwig-tokens": "*",
30
31
  "clsx": "2.0.0"
31
32
  },
32
33
  "publishConfig": {