@grucloud/bau-ui 0.40.0 → 0.42.0

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.
Files changed (87) hide show
  1. package/README.md +4 -2
  2. package/accordion/accordion.js +162 -0
  3. package/accordion/index.d.ts +26 -0
  4. package/accordion/index.js +1 -0
  5. package/alert/alert.js +65 -55
  6. package/alert/index.d.ts +8 -9
  7. package/alertStack/alertStack.js +5 -3
  8. package/alertStack/index.d.ts +5 -2
  9. package/animate/animate.js +47 -33
  10. package/animate/index.d.ts +2 -3
  11. package/autocomplete/autocomplete.js +222 -0
  12. package/autocomplete/index.d.ts +21 -0
  13. package/autocomplete/index.js +1 -0
  14. package/avatar/avatar.js +46 -6
  15. package/avatar/index.d.ts +5 -2
  16. package/badge/badge.js +43 -0
  17. package/badge/index.d.ts +12 -0
  18. package/badge/index.js +1 -0
  19. package/bau-ui.d.ts +14 -7
  20. package/breadcrumbs/breadcrumbs.js +30 -6
  21. package/breadcrumbs/index.d.ts +8 -2
  22. package/button/button.js +38 -105
  23. package/button/index.d.ts +4 -7
  24. package/buttonGroup/buttonGroup.js +68 -0
  25. package/buttonGroup/index.d.ts +10 -0
  26. package/buttonGroup/index.js +1 -0
  27. package/calendar/calendar.js +51 -0
  28. package/calendar/index.d.ts +13 -0
  29. package/calendar/index.js +1 -0
  30. package/checkbox/checkbox.js +66 -39
  31. package/checkbox/index.d.ts +5 -2
  32. package/chip/chip.js +60 -0
  33. package/chip/index.d.ts +10 -0
  34. package/chip/index.js +1 -0
  35. package/constants.d.ts +13 -0
  36. package/constants.js +3 -0
  37. package/context.d.ts +12 -0
  38. package/context.js +17 -0
  39. package/drawer/drawer.js +10 -5
  40. package/drawer/index.d.ts +5 -2
  41. package/drillDownMenu/drillDownMenu.js +157 -138
  42. package/drillDownMenu/index.d.ts +11 -3
  43. package/fileInput/fileInput.js +25 -11
  44. package/fileInput/index.d.ts +9 -3
  45. package/form/form.js +31 -0
  46. package/form/index.d.ts +10 -0
  47. package/form/index.js +1 -0
  48. package/globalStyle/globalStyle.js +133 -61
  49. package/globalStyle/index.d.ts +14 -0
  50. package/input/index.d.ts +6 -8
  51. package/input/input.js +78 -107
  52. package/list/index.d.ts +10 -0
  53. package/list/index.js +1 -0
  54. package/list/list.js +66 -0
  55. package/modal/index.d.ts +5 -2
  56. package/modal/modal.js +47 -10
  57. package/package.json +4 -4
  58. package/pages/login/index.d.ts +4 -5
  59. package/pages/login/login.js +1 -1
  60. package/popover/index.d.ts +18 -0
  61. package/popover/index.js +1 -0
  62. package/popover/popover.js +69 -0
  63. package/select/index.d.ts +16 -0
  64. package/select/index.js +1 -0
  65. package/select/select.js +176 -0
  66. package/slider/index.d.ts +10 -0
  67. package/slider/index.js +1 -0
  68. package/slider/slider.js +47 -0
  69. package/spinner/index.d.ts +7 -4
  70. package/spinner/spinner.js +13 -5
  71. package/switch/index.d.ts +5 -2
  72. package/switch/switch.js +101 -18
  73. package/tableContainer/index.d.ts +9 -0
  74. package/tableContainer/index.js +1 -0
  75. package/tableContainer/tableContainer.js +78 -0
  76. package/tablePagination/index.d.ts +17 -0
  77. package/tablePagination/index.js +1 -0
  78. package/tablePagination/tablePagination.js +131 -0
  79. package/tabs/index.d.ts +3 -1
  80. package/tabs/tabs.js +34 -15
  81. package/themeSwitch/index.d.ts +3 -1
  82. package/themeSwitch/themeSwitch.js +58 -15
  83. package/tooltip/index.d.ts +24 -0
  84. package/tooltip/index.js +1 -0
  85. package/tooltip/tooltip.js +184 -0
  86. package/treeView/index.d.ts +7 -2
  87. package/treeView/treeView.js +37 -9
@@ -1,10 +1,11 @@
1
1
  const ColorPaletteDefault = [
2
- ["primary", { h: "230", s: "48%", l: "47%" }],
3
- ["secondary", { h: "338", s: "100%", l: "48%" }],
4
- ["success", { h: "120", s: "100%", l: "32%" }],
5
- ["info", { h: "194", s: "80%", l: "62%" }],
6
- ["warning", { h: "43", s: "100%", l: "50%" }],
7
- ["danger", { h: "358", s: "95%", l: "60%" }],
2
+ ["neutral", { h: "0", s: "0%", l: "50%" }],
3
+ ["primary", { h: "230", s: "70%", l: "30%" }],
4
+ ["secondary", { h: "338", s: "70%", l: "50%" }],
5
+ ["success", { h: "120", s: "70%", l: "25%" }],
6
+ ["info", { h: "194", s: "70%", l: "30%" }],
7
+ ["warning", { h: "43", s: "70%", l: "25%" }],
8
+ ["danger", { h: "358", s: "70%", l: "30%" }],
8
9
  ];
9
10
 
10
11
  const SHADES_LIGHT = [
@@ -18,22 +19,51 @@ const SHADES_DARK = [
18
19
  ["darkest", "0.5"],
19
20
  ];
20
21
 
22
+ const darkVar = (color) => `var(--color-${color})`;
23
+ const lightestVar = (color) => `var(--color-${color}-lightest)`;
24
+
25
+ const variantToCss = () =>
26
+ ColorPaletteDefault.map(
27
+ ([color]) =>
28
+ `
29
+ .outline.${color} {
30
+ border: 2px solid ${darkVar(color)};
31
+ color: var(--font-color-base)
32
+ }
33
+ .soft.${color} {
34
+ background-color: ${lightestVar(color)};
35
+ }
36
+ .solid.${color} {
37
+ background-color: ${darkVar(color)};
38
+ }
39
+ `
40
+ ).join("\n");
41
+
42
+ const darkColors = () =>
43
+ ColorPaletteDefault.map(([color]) => [
44
+ `--color-${color}-s: var(--color-${color}-dark-s);`,
45
+ ]).join("\n");
46
+
47
+ const indexToColor = (index) => {
48
+ return 100 - index * 10;
49
+ };
50
+
21
51
  const buildGrays = () =>
22
- new Array(20)
52
+ new Array(10)
23
53
  .fill("")
24
54
  .map(
25
55
  (v, index) =>
26
- `--color-gray-${index * 50}: hsl(0, 0%, ${100 - 5 * index}%);`
56
+ `--color-gray-${index * 100}: hsl(0, 0%, ${indexToColor(index)}%);`
27
57
  )
28
58
  .join("\n");
29
59
 
30
60
  export const buildEmphasis = ({ dark }) =>
31
- new Array(20)
61
+ new Array(10)
32
62
  .fill("")
33
63
  .map(
34
64
  (v, index) =>
35
- `--color-emphasis-${index * 50}: var(--color-gray-${
36
- dark ? 1000 - index * 50 : index * 50
65
+ `--color-emphasis-${index * 100}: var(--color-gray-${
66
+ dark ? 1000 - index * 100 : index * 100
37
67
  });`
38
68
  )
39
69
  .join("\n");
@@ -41,8 +71,10 @@ export const buildEmphasis = ({ dark }) =>
41
71
  const buildColor = ([color, { h, s, l }]) =>
42
72
  [
43
73
  `--color-${color}-h: ${h};`,
44
- `--color-${color}-s: ${s};`,
45
74
  `--color-${color}-l: ${l};`,
75
+ `--color-${color}-base-s: ${s};`,
76
+ `--color-${color}-s: var(--color-${color}-base-s);`,
77
+ `--color-${color}-dark-s: calc(${s} - 25%);`,
46
78
  `--color-${color}-hsl: var(--color-${color}-h), var(--color-${color}-s), var(--color-${color}-l);`,
47
79
  `--color-${color}: hsl(var(--color-${color}-hsl));`,
48
80
  ...SHADES_LIGHT.map(
@@ -62,53 +94,93 @@ export default function globalStyle(
62
94
  { colorPalette = ColorPaletteDefault } = {}
63
95
  ) {
64
96
  createGlobalStyles`
65
- :root {
66
- --color-scheme: light;
67
- --contrast-background-value: 90%;
68
- --contrast-foreground-value: 70%;
69
- --contrast-background-dark-value: 70%;
70
- --contrast-foreground-dark-value: 90%;
71
- --color-white: #fff;
72
- --color-black: #000;
73
- ${colorPalette.map(([color, hsl]) => buildColor([color, hsl])).join("\n")}
74
- ${buildGrays()}
75
- ${buildEmphasis({})}
76
- --color-content: hsl(0, 0%, 10%);
77
- --color-content-inverse: hsl(0, 0%, 90%);
78
- --color-content-secondary: hsl(0, 0%, 30%);
79
- --background-color: var(--color-white);
80
- --background-surface-color: var(--color-content-inverse);
81
- --global-border-width: 1px;
82
- --global-radius: 0.4rem;
83
- --font-color-base: var(--color-content);
84
- --font-color-disabled: var(--color-emphasis-700);
85
- --font-color-inverse: var(--color-content-inverse);
86
- --font-color-secondary: var(--color-content-secondary);
87
- --font-family: system-ui, -apple-system, Helvetica, Arial, sans-serif;
88
- --font-family-monospace: Consolas, monospace;
89
- --font-weight-light: 300;
90
- --font-weight-normal: 400;
91
- --font-weight-semibold: 500;
92
- --font-weight-bold: 700;
93
- --global-spacing: 1rem;
94
- --spacing-vertical: var(--global-spacing);
95
- --spacing-horizontal: var(--global-spacing);
96
- --transition-fast: 200ms;
97
- --transition-slow: 400ms;
98
- --shadow-s: 0 1px 2px 0 rgba(0, 0, 0, 0.4);
99
- --shadow-m: 0 2px 4px 0 rgba(0, 0, 0, 0.4);
100
- --font-size-base: 100%;
101
- --line-height-base: 1.65;
102
- --link-color: var(--color-primary)
103
- }
104
- :root {
105
- font-family: var(--font-family);
106
- color-scheme: var(--color-scheme);
107
- color: var(--color-content);
108
- font: var(--font-size-base) / var(--line-height-base) var(--font-family)
109
- }
110
- body {
111
- margin: 0;
112
- }
113
- `;
97
+ :root {
98
+ --color-scheme: light;
99
+ --contrast-background-value: 90%;
100
+ --contrast-foreground-value: 70%;
101
+ --contrast-background-dark-value: 70%;
102
+ --contrast-foreground-dark-value: 90%;
103
+ --color-white: #fff;
104
+ --color-black: #000;
105
+ ${colorPalette.map(([color, hsl]) => buildColor([color, hsl])).join("\n")}
106
+ ${buildGrays()}
107
+ ${buildEmphasis({})}
108
+ ${variantToCss()}
109
+ --color-content: hsl(0, 0%, 10%);
110
+ --color-content-inverse: hsl(0, 0%, 95%);
111
+ --color-content-secondary: hsl(0, 0%, 30%);
112
+ --background-color: var(--color-white);
113
+ --global-border-width: 1px;
114
+ --global-radius: 0.4rem;
115
+ --font-color-base: var(--color-content);
116
+ --font-color-disabled: var(--color-emphasis-600);
117
+ --font-color-inverse: var(--color-content-inverse);
118
+ --font-color-secondary: var(--color-content-secondary);
119
+ --font-family: system-ui, -apple-system, Helvetica, Arial, sans-serif;
120
+ --font-family-monospace: Consolas, monospace;
121
+ --font-weight-light: 300;
122
+ --font-weight-normal: 400;
123
+ --font-weight-semibold: 500;
124
+ --font-weight-bold: 700;
125
+ --global-spacing: 1rem;
126
+ --spacing-vertical: var(--global-spacing);
127
+ --spacing-horizontal: var(--global-spacing);
128
+ --transition-fast: 200ms;
129
+ --transition-slow: 400ms;
130
+ --shadow-s: 0 1px 2px 0 rgba(0, 0, 0, 0.4);
131
+ --shadow-m: 0 3px 1px -2px rgba(0, 0, 0, 0.2),
132
+ 0 2px 2px 0 rgba(0, 0, 0, 0.14), 0 1px 5px 0 rgba(0, 0, 0, 0.12);
133
+ --shadow-lg: 0 2px 4px -1px rgba(0, 0, 0, 0.2),
134
+ 0 4px 5px 0 rgba(0, 0, 0, 0.14), 0 1px 10px 0 rgba(0, 0, 0, 0.12);
135
+ --font-size-base: 100%;
136
+ --line-height-base: 1.65;
137
+ --link-color: var(--color-primary);
138
+ --brightness-hover-always: 120%;
139
+ --brightness-active-always: 130%;
140
+ --brightness-hover: 80%;
141
+ --brightness-hover-reverse: 140%;
142
+ --brightness-active: 90%;
143
+ .plain {
144
+ background-color: var(--background-color);
145
+ }
146
+ .outline {
147
+ background-color: var(--background-color);
148
+ }
149
+ .solid {
150
+ color: var(--font-color-inverse);
151
+ }
152
+ .sm {
153
+ font-size: 0.8rem;
154
+ }
155
+ .md {
156
+ font-size: 1.1rem;
157
+ }
158
+ .lg {
159
+ font-size: 1.2rem;
160
+ }
161
+ }
162
+ :root {
163
+ font-family: var(--font-family);
164
+ color-scheme: var(--color-scheme);
165
+ color: var(--color-content);
166
+ font: var(--font-size-base) / var(--line-height-base) var(--font-family);
167
+ background-color: var(--background-color);
168
+ }
169
+ html[data-theme="dark"] {
170
+ ${darkColors()}
171
+ --color-scheme: dark;
172
+ --background-color: #121212;
173
+ --hover-overlay: rgba(255, 255, 255, 0.05);
174
+ --color-content: #e3e3e3;
175
+ --color-content-secondary: rgba(255, 255, 255, 0.7);
176
+ --brightness-hover-always: 130%;
177
+ --brightness-active-always: 120%;
178
+ --brightness-active: 180%;
179
+ --brightness-hover: 150%;
180
+ --brightness-hover-reverse: 70% ${buildEmphasis({ dark: true })};
181
+ }
182
+ body {
183
+ margin: 0;
184
+ }
185
+ `;
114
186
  }
@@ -0,0 +1,14 @@
1
+ declare module "@grucloud/bau-ui/globalStyle" {
2
+ type HSL = {
3
+ h: string;
4
+ s: string;
5
+ l: string;
6
+ };
7
+ export type ColorDefs = [name: any, hsl: HSL];
8
+
9
+ type StyleOption = {
10
+ colorPalette: ColorDefs[];
11
+ };
12
+
13
+ export default function (context: any, option?: StyleOption): void;
14
+ }
package/input/index.d.ts CHANGED
@@ -1,12 +1,10 @@
1
1
  declare module "@grucloud/bau-ui/input" {
2
- export type InputProps = {
3
- name: string;
4
- id: string;
5
- label: string;
6
- error?: string;
7
- };
2
+ type DefaultDesignProps = import("../constants").DefaultDesignProps;
3
+ type ComponentOption = import("../bau-ui").ComponentOption;
8
4
 
9
- type Component = import("../bau-ui").Component<InputProps>;
5
+ export type InputProps = {} & DefaultDesignProps;
10
6
 
11
- export default function (context: any): Component;
7
+ type Component = import("../bau-ui").Component<InputProps, HTMLInputElement>;
8
+
9
+ export default function (context: any, option?: ComponentOption): Component;
12
10
  }
package/input/input.js CHANGED
@@ -1,122 +1,93 @@
1
- import classNames from "@grucloud/bau-css/classNames";
1
+ import classNames from "@grucloud/bau-css/classNames.js";
2
+ import { Colors } from "../constants.js";
2
3
 
3
- const createStyles = ({ css, createGlobalStyles }) => {
4
- createGlobalStyles`
5
- :root {
6
- --input-border-bottom-size: 2px;
4
+ const colorsToCss = () =>
5
+ Colors.map(
6
+ (color) =>
7
+ `
8
+ &.input.${color} {
9
+ border: 2px solid transparent;
7
10
  }
8
- `;
9
-
10
- return {
11
- base: css`
12
- position: relative;
13
- display: inline-block;
14
- min-height: 3rem;
15
-
16
- & input {
17
- font-size: 1.2rem;
18
- background: var(--color-emphasis-100);
19
- box-shadow: var(--shadow-s);
20
- border-radius: var(--global-radius);
21
- border: var(--input-border-bottom-size) solid transparent;
22
- border-bottom: var(--input-border-bottom-size) solid
23
- var(--color-emphasis-900);
24
- box-sizing: border-box;
25
- padding: 26px 10px 4px 10px;
26
- outline: none;
27
- transition: background-color var(--transition-fast) ease-in-out;
28
- &:hover {
29
- background: var(--color-emphasis-200);
30
- }
31
- &:focus,
32
- &:valid {
33
- border-bottom: var(--input-border-bottom-size) solid
34
- var(--color-primary);
35
- }
36
- &:focus + label,
37
- &:valid + label,
38
- &:disabled + label {
39
- top: 1rem;
40
- font-size: 0.8rem;
41
- font-weight: bold;
42
- color: var(--color-primary);
43
- }
44
- }
45
- & label {
46
- display: block;
47
- top: 1.5rem;
48
- line-height: 0;
49
- position: absolute;
50
- pointer-events: none;
51
- padding: 0px 10px;
52
- transition: var(--transition-fast) ease-in-out;
53
- color: var(--font-color-secondary);
54
- &:focus {
55
- font-style: normal;
56
- }
57
- }
58
- & div[data-input-error] {
59
- margin: 0.2rem 0;
60
- position: absolute;
61
- background: var(--background-color);
62
- }
63
- `,
64
- disabled: css`
65
- & * {
66
- color: var(--font-color-disabled) !important;
67
- }
68
- & input {
69
- border-bottom: var(--input-border-bottom-size) dashed
70
- var(--font-color-disabled);
71
- }
72
- `,
73
- error: css`
74
- color: var(--color-danger-darkest) !important;
75
- & * {
76
- color: var(--color-danger-darkest) !important;
77
- }
78
- & input {
79
- border-bottom: var(--input-border-bottom-size) dashed
80
- var(--color-danger-darkest) !important;
81
- }
82
- `,
11
+ &.input.plain.${color} {
12
+ &:focus {
13
+ border-color: var(--color-${color});
83
14
  };
84
- };
15
+ }
16
+ &.input.outline.${color} {
17
+ border: 1px solid var(--color-${color});
18
+ &:focus {
19
+ border: 2px solid var(--color-${color});
20
+ };
21
+ }
22
+ &.input.soft.${color} {
23
+ &:focus {
24
+ border-color: var(--color-${color});
25
+ };
26
+ }
27
+ &.input.solid.${color} {
28
+ &:focus {
29
+ border-color: var(--color-${color});
30
+ };
31
+ &::placeholder {
32
+ color: var(--font-color-inverse);
33
+ filter: brightness(var(--brightness-hover));
34
+ }
35
+ &:hover {
36
+ background-color: var(--color-${color}-light);
37
+ }
38
+ }
39
+ `
40
+ ).join("\n");
85
41
 
86
- export default function (context, options = {}) {
87
- const { bau, css, createGlobalStyles } = context;
88
- const { div, input, label } = bau.tags;
42
+ export default function (context, options) {
43
+ const { bau, css } = context;
44
+ const { input } = bau.tags;
89
45
 
90
- const styles = createStyles({ css, createGlobalStyles });
46
+ const className = css`
47
+ display: inline-block;
48
+ box-shadow: var(--shadow-s);
49
+ border-radius: var(--global-radius);
50
+ box-sizing: border-box;
51
+ outline: none;
52
+ color: inherit;
53
+ transition: background-color var(--transition-fast) ease-in-out;
54
+ &.input:hover {
55
+ background-color: var(--color-emphasis-100);
56
+ }
57
+ &.sm {
58
+ padding: 0.4rem;
59
+ }
60
+ &.md {
61
+ padding: 0.5rem;
62
+ }
63
+ &.lg {
64
+ padding: 0.8rem;
65
+ }
66
+ ${colorsToCss()}
67
+ `;
91
68
 
92
69
  return function Input(props) {
93
70
  const {
71
+ size = "md",
72
+ variant = "outline",
73
+ color = "neutral",
94
74
  name,
95
75
  id,
96
76
  disabled,
97
- label: labelValue = "",
98
- error = "",
99
77
  ...otherProps
100
78
  } = props;
101
- return div(
102
- {
103
- class: classNames(
104
- styles.base,
105
- disabled && styles.disabled,
106
- error && styles.error,
107
- props.class
108
- ),
109
- },
110
- input({
111
- id,
112
- name,
113
- type: "text",
114
- required: true,
115
- disabled,
116
- ...otherProps,
117
- }),
118
- label({ htmlFor: id }, labelValue),
119
- div({ "data-input-error": name }, error)
120
- );
79
+
80
+ return input({
81
+ ...otherProps,
82
+ class: classNames(
83
+ "input",
84
+ size,
85
+ color,
86
+ variant,
87
+ className,
88
+ options?.class,
89
+ otherProps.class
90
+ ),
91
+ });
121
92
  };
122
93
  }
@@ -0,0 +1,10 @@
1
+ declare module "@grucloud/bau-ui/list" {
2
+ type DefaultDesignProps = import("../constants").DefaultDesignProps;
3
+ type ComponentOption = import("../bau-ui").ComponentOption;
4
+
5
+ export type ListProps = {} & DefaultDesignProps;
6
+
7
+ type Component = import("../bau-ui").Component<ListProps, HTMLUListElement>;
8
+
9
+ export default function (context: any, option?: ComponentOption): Component;
10
+ }
package/list/index.js ADDED
@@ -0,0 +1 @@
1
+ export { default } from "./list";
package/list/list.js ADDED
@@ -0,0 +1,66 @@
1
+ import classNames from "@grucloud/bau-css/classNames.js";
2
+ import { toPropsAndChildren } from "@grucloud/bau/bau.js";
3
+ import { Colors } from "../constants.js";
4
+
5
+ export default function (context, options) {
6
+ const { bau, css } = context;
7
+ const { ul } = bau.tags;
8
+
9
+ const colorsToCss = () =>
10
+ Colors.map(
11
+ (color) =>
12
+ `
13
+ `
14
+ ).join("\n");
15
+
16
+ const className = css`
17
+ list-style: none;
18
+ padding: 0;
19
+ margin: 0 0;
20
+ &.solid {
21
+ & li:hover {
22
+ filter: brightness(var(--brightness-hover-always));
23
+ }
24
+ & li.active {
25
+ filter: brightness(var(--brightness-active-always));
26
+ }
27
+ }
28
+ & li {
29
+ padding: 0.4rem;
30
+ cursor: pointer;
31
+ background-color: inherit;
32
+ transition: all var(--transition-slow) ease-out;
33
+ display: flex;
34
+ align-items: center;
35
+ &:hover {
36
+ filter: brightness(var(--brightness-hover));
37
+ }
38
+ &.active {
39
+ filter: brightness(var(--brightness-active));
40
+ }
41
+ }
42
+ ${colorsToCss()}
43
+ `;
44
+
45
+ return function List(...args) {
46
+ let [
47
+ { color = "neutral", variant = "plain", size, ...props },
48
+ ...children
49
+ ] = toPropsAndChildren(args);
50
+ return ul(
51
+ {
52
+ ...props,
53
+ class: classNames(
54
+ "list",
55
+ className,
56
+ color,
57
+ variant,
58
+ size,
59
+ options?.class,
60
+ props?.class
61
+ ),
62
+ },
63
+ ...children
64
+ );
65
+ };
66
+ }
package/modal/index.d.ts CHANGED
@@ -1,7 +1,10 @@
1
1
  declare module "@grucloud/bau-ui/modal" {
2
- export type ModalProps = {};
2
+ type DefaultDesignProps = import("../constants").DefaultDesignProps;
3
+ type ComponentOption = import("../bau-ui").ComponentOption;
4
+
5
+ export type ModalProps = {} & DefaultDesignProps;
3
6
 
4
7
  type Component = import("../bau-ui").Component<ModalProps, HTMLDialogElement>;
5
8
 
6
- export default function (context: any): Component;
9
+ export default function (context: any, option?: ComponentOption): Component;
7
10
  }
package/modal/modal.js CHANGED
@@ -1,10 +1,31 @@
1
- import classNames from "@grucloud/bau-css/classNames";
1
+ import classNames from "@grucloud/bau-css/classNames.js";
2
+ import { toPropsAndChildren } from "@grucloud/bau/bau.js";
3
+ import { Colors } from "../constants.js";
2
4
 
3
- export default function (context) {
5
+ export default function (context, options) {
4
6
  const { bau, css } = context;
5
7
  const { dialog } = bau.tags;
6
8
 
7
- const style = css`
9
+ const colorsToCss = () =>
10
+ Colors.map(
11
+ (color) =>
12
+ `
13
+ &.modal.plain.${color} {
14
+ color: inherit;
15
+ }
16
+ &.modal.outline.${color} {
17
+ color: inherit;
18
+ }
19
+ &.modal.soft.${color} {
20
+ color: inherit;
21
+ }
22
+ &.modal.solid.${color} {
23
+
24
+ }
25
+ `
26
+ ).join("\n");
27
+
28
+ const className = css`
8
29
  box-shadow: var(--shadow-s);
9
30
  background-color: var(--background-color);
10
31
  top: 0;
@@ -21,26 +42,42 @@ export default function (context) {
21
42
  font-size: 1.8rem;
22
43
  font-weight: 800;
23
44
  text-align: center;
24
- background-color: var(--color-primary);
25
- color: var(--font-color-inverse);
26
45
  }
27
46
  & footer {
28
47
  display: flex;
29
48
  justify-content: flex-end;
30
49
  margin: 0px;
31
50
  box-shadow: var(--shadow-s);
32
- > * {
33
- margin: 12px;
34
- }
51
+ padding: 1rem;
52
+ gap: 1rem;
35
53
  }
36
54
  & > main {
37
55
  margin: 12px;
38
56
  flex-grow: 1;
39
57
  overflow: scroll;
40
58
  }
59
+ ${colorsToCss()}
41
60
  `;
42
61
 
43
- return function Modal(props, ...children) {
44
- return dialog({ class: classNames(style, props.class) }, ...children);
62
+ return function Modal(...args) {
63
+ let [
64
+ { color = "neutral", variant = "outline", size = "md", ...props },
65
+ ...children
66
+ ] = toPropsAndChildren(args);
67
+
68
+ return dialog(
69
+ {
70
+ class: classNames(
71
+ "modal",
72
+ className,
73
+ color,
74
+ variant,
75
+ size,
76
+ options?.class,
77
+ props?.class
78
+ ),
79
+ },
80
+ ...children
81
+ );
45
82
  };
46
83
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@grucloud/bau-ui",
3
3
  "description": "Components library built with Bau",
4
- "version": "0.40.0",
4
+ "version": "0.42.0",
5
5
  "type": "module",
6
6
  "license": "BSD",
7
7
  "keywords": [
@@ -18,8 +18,8 @@
18
18
  "directory": "bau-ui"
19
19
  },
20
20
  "dependencies": {
21
- "@grucloud/bau": "^0.40.0",
22
- "@grucloud/bau-css": "^0.40.0"
21
+ "@grucloud/bau": "^0.42.0",
22
+ "@grucloud/bau-css": "^0.42.0"
23
23
  },
24
- "gitHead": "d6f3c0553ec98d0906160f3426b5dd2b9659cb69"
24
+ "gitHead": "35376e3c8ba424c0adceca4b3928dbf9e7931676"
25
25
  }
@@ -1,10 +1,9 @@
1
1
  declare module "@grucloud/bau-ui/pages/login" {
2
- export type LoginProps = {
3
- // severity: string;
4
- // onRemove?: Function;
5
- };
2
+ type ComponentOption = import("../../bau-ui").ComponentOption;
6
3
 
7
- type Component = import("../bau-ui").Component<LoginProps>;
4
+ export type LoginProps = {};
5
+
6
+ type Component = import("../../bau-ui").Component<LoginProps>;
8
7
 
9
8
  export default function (context: any): Component;
10
9
  }