@postenbring/hedwig-react 0.0.2 → 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,52 +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);
55
- var import_tokens = require("@postenbring/hedwig-tokens/dist/web/tokens.css");
56
+ var import_tokens = require("@postenbring/hedwig-tokens/tokens-output/css/tokens.css");
57
+ var import_base = require("@postenbring/hedwig-css/dist/base.css");
56
58
  var import_button = require("@postenbring/hedwig-css/dist/button/button.css");
57
59
 
58
60
  // src/button/button.tsx
59
61
  var import_clsx = require("clsx");
60
62
 
61
63
  // src/utils.ts
62
- function warnForStyleOverrides(className, styles) {
63
- if (className) {
64
+ function warnForStyleOverrides(props) {
65
+ if (props.className) {
64
66
  console.warn("Overriding styles are not premited");
65
67
  }
66
- if (styles) {
68
+ if (props.styles) {
67
69
  console.warn("Overriding styles are not premited");
68
70
  }
69
71
  }
70
72
 
71
73
  // src/button/button.tsx
72
74
  var import_jsx_runtime = require("react/jsx-runtime");
73
- function Button(_a) {
75
+ function BaseButton(_a) {
74
76
  var _b = _a, {
75
77
  children,
76
- style,
77
- className,
78
- size = "medium"
78
+ variant,
79
+ size = "medium",
80
+ fullWidth = false,
81
+ fill = "contained",
82
+ buttonRef
79
83
  } = _b, rest = __objRest(_b, [
80
84
  "children",
81
- "style",
82
- "className",
83
- "size"
85
+ "variant",
86
+ "size",
87
+ "fullWidth",
88
+ "fill",
89
+ "buttonRef"
84
90
  ]);
85
- warnForStyleOverrides(style, className);
91
+ warnForStyleOverrides(rest);
86
92
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
87
93
  "button",
88
94
  __spreadProps(__spreadValues({
89
- 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,
90
102
  type: "button"
91
103
  }, rest), {
92
104
  children
93
105
  })
94
106
  );
95
107
  }
96
- 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";
97
117
  // Annotate the CommonJS export names for ESM import in node:
98
118
  0 && (module.exports = {
99
- Button
119
+ PrimaryButton,
120
+ SecondaryButton
100
121
  });
@@ -1,6 +1,8 @@
1
1
  import {
2
- Button
3
- } from "../chunk-GT43SBJ6.mjs";
2
+ PrimaryButton,
3
+ SecondaryButton
4
+ } from "../chunk-ZPSTPWVB.mjs";
4
5
  export {
5
- Button
6
+ PrimaryButton,
7
+ SecondaryButton
6
8
  };
@@ -31,49 +31,73 @@ var __objRest = (source, exclude) => {
31
31
  };
32
32
 
33
33
  // src/button/index.tsx
34
- import "@postenbring/hedwig-tokens/dist/web/tokens.css";
34
+ import "@postenbring/hedwig-tokens/tokens-output/css/tokens.css";
35
+ import "@postenbring/hedwig-css/dist/base.css";
35
36
  import "@postenbring/hedwig-css/dist/button/button.css";
36
37
 
37
38
  // src/button/button.tsx
38
39
  import { clsx } from "clsx";
39
40
 
40
41
  // src/utils.ts
41
- function warnForStyleOverrides(className, styles) {
42
- if (className) {
42
+ function warnForStyleOverrides(props) {
43
+ if (props.className) {
43
44
  console.warn("Overriding styles are not premited");
44
45
  }
45
- if (styles) {
46
+ if (props.styles) {
46
47
  console.warn("Overriding styles are not premited");
47
48
  }
48
49
  }
49
50
 
50
51
  // src/button/button.tsx
51
52
  import { jsx } from "react/jsx-runtime";
52
- function Button(_a) {
53
+ function BaseButton(_a) {
53
54
  var _b = _a, {
54
55
  children,
55
- style,
56
- className,
57
- size = "medium"
56
+ variant,
57
+ size = "medium",
58
+ fullWidth = false,
59
+ fill = "contained",
60
+ buttonRef
58
61
  } = _b, rest = __objRest(_b, [
59
62
  "children",
60
- "style",
61
- "className",
62
- "size"
63
+ "variant",
64
+ "size",
65
+ "fullWidth",
66
+ "fill",
67
+ "buttonRef"
63
68
  ]);
64
- warnForStyleOverrides(style, className);
69
+ warnForStyleOverrides(rest);
65
70
  return /* @__PURE__ */ jsx(
66
71
  "button",
67
72
  __spreadProps(__spreadValues({
68
- 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,
69
80
  type: "button"
70
81
  }, rest), {
71
82
  children
72
83
  })
73
84
  );
74
85
  }
75
- 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";
76
95
 
77
96
  export {
78
- Button
97
+ __spreadValues,
98
+ __spreadProps,
99
+ __objRest,
100
+ warnForStyleOverrides,
101
+ PrimaryButton,
102
+ SecondaryButton
79
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,54 +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
57
- var import_tokens = require("@postenbring/hedwig-tokens/dist/web/tokens.css");
59
+ var import_tokens = require("@postenbring/hedwig-tokens/tokens-output/css/tokens.css");
60
+ var import_base = require("@postenbring/hedwig-css/dist/base.css");
58
61
  var import_button = require("@postenbring/hedwig-css/dist/button/button.css");
59
62
 
60
63
  // src/button/button.tsx
61
64
  var import_clsx = require("clsx");
62
65
 
63
66
  // src/utils.ts
64
- function warnForStyleOverrides(className, styles) {
65
- if (className) {
67
+ function warnForStyleOverrides(props) {
68
+ if (props.className) {
66
69
  console.warn("Overriding styles are not premited");
67
70
  }
68
- if (styles) {
71
+ if (props.styles) {
69
72
  console.warn("Overriding styles are not premited");
70
73
  }
71
74
  }
72
75
 
73
76
  // src/button/button.tsx
74
77
  var import_jsx_runtime = require("react/jsx-runtime");
75
- function Button(_a) {
78
+ function BaseButton(_a) {
76
79
  var _b = _a, {
77
80
  children,
78
- style,
79
- className,
80
- size = "medium"
81
+ variant,
82
+ size = "medium",
83
+ fullWidth = false,
84
+ fill = "contained",
85
+ buttonRef
81
86
  } = _b, rest = __objRest(_b, [
82
87
  "children",
83
- "style",
84
- "className",
85
- "size"
88
+ "variant",
89
+ "size",
90
+ "fullWidth",
91
+ "fill",
92
+ "buttonRef"
86
93
  ]);
87
- warnForStyleOverrides(style, className);
94
+ warnForStyleOverrides(rest);
88
95
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
89
96
  "button",
90
97
  __spreadProps(__spreadValues({
91
- 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,
92
105
  type: "button"
93
106
  }, rest), {
94
107
  children
95
108
  })
96
109
  );
97
110
  }
98
- 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";
99
156
  // Annotate the CommonJS export names for ESM import in node:
100
157
  0 && (module.exports = {
101
- Button
158
+ Link,
159
+ PrimaryButton,
160
+ SecondaryButton
102
161
  });
package/dist/index.mjs CHANGED
@@ -1,6 +1,49 @@
1
1
  import {
2
- Button
3
- } from "./chunk-GT43SBJ6.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.2",
3
+ "version": "0.0.3",
4
4
  "main": "./dist/index.js",
5
5
  "module": "./dist/index.mjs",
6
6
  "types": "./dist/index.d.ts",