@astral/ui 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.
- package/cjs/index.d.ts +1 -0
- package/cjs/index.js +13 -0
- package/cjs/src/Badge/Badge.d.ts +3 -0
- package/cjs/src/Badge/Badge.js +31 -0
- package/cjs/src/Badge/index.d.ts +2 -0
- package/cjs/src/Badge/index.js +14 -0
- package/cjs/src/Badge/styled.d.ts +50 -0
- package/cjs/src/Badge/styled.js +63 -0
- package/cjs/src/Badge/types.d.ts +5 -0
- package/cjs/src/Badge/types.js +2 -0
- package/cjs/src/Button/Button.d.ts +2 -0
- package/cjs/src/Button/Button.js +33 -0
- package/cjs/src/Button/index.d.ts +2 -0
- package/cjs/src/Button/index.js +14 -0
- package/cjs/src/Button/styled.d.ts +13 -0
- package/cjs/src/Button/styled.js +33 -0
- package/cjs/src/Button/types.d.ts +7 -0
- package/cjs/src/Button/types.js +2 -0
- package/cjs/src/ButtonBase/ButtonBase.d.ts +2 -0
- package/cjs/src/ButtonBase/ButtonBase.js +33 -0
- package/cjs/src/ButtonBase/constants.d.ts +22 -0
- package/cjs/src/ButtonBase/constants.js +29 -0
- package/cjs/src/ButtonBase/index.d.ts +3 -0
- package/cjs/src/ButtonBase/index.js +15 -0
- package/cjs/src/ButtonBase/styled.d.ts +32 -0
- package/cjs/src/ButtonBase/styled.js +224 -0
- package/cjs/src/ButtonBase/types.d.ts +11 -0
- package/cjs/src/ButtonBase/types.js +2 -0
- package/cjs/src/CircularProgress/CircularProgress.d.ts +3 -0
- package/cjs/src/CircularProgress/CircularProgress.js +33 -0
- package/cjs/src/CircularProgress/constants.d.ts +9 -0
- package/cjs/src/CircularProgress/constants.js +14 -0
- package/cjs/src/CircularProgress/index.d.ts +2 -0
- package/cjs/src/CircularProgress/index.js +14 -0
- package/cjs/src/CircularProgress/styled.d.ts +8 -0
- package/cjs/src/CircularProgress/styled.js +26 -0
- package/cjs/src/CircularProgress/types.d.ts +8 -0
- package/cjs/src/CircularProgress/types.js +2 -0
- package/cjs/src/IconButton/IconButton.d.ts +2 -0
- package/cjs/src/IconButton/IconButton.js +32 -0
- package/cjs/src/IconButton/index.d.ts +1 -0
- package/cjs/src/IconButton/index.js +13 -0
- package/cjs/src/IconButton/styled.d.ts +19 -0
- package/cjs/src/IconButton/styled.js +25 -0
- package/cjs/src/ThemeProvider/ThemeProvider.d.ts +7 -0
- package/cjs/src/ThemeProvider/ThemeProvider.js +22 -0
- package/cjs/src/ThemeProvider/index.d.ts +1 -0
- package/cjs/src/ThemeProvider/index.js +13 -0
- package/cjs/src/Typography/Typography.d.ts +7 -0
- package/cjs/src/Typography/Typography.js +36 -0
- package/cjs/src/Typography/index.d.ts +1 -0
- package/cjs/src/Typography/index.js +13 -0
- package/cjs/src/index.d.ts +8 -0
- package/cjs/src/index.js +20 -0
- package/cjs/src/styles/index.d.ts +1 -0
- package/cjs/src/styles/index.js +13 -0
- package/cjs/src/styles/styled/index.d.ts +1 -0
- package/cjs/src/styles/styled/index.js +13 -0
- package/cjs/src/styles/styled/styled.d.ts +2 -0
- package/cjs/src/styles/styled/styled.js +8 -0
- package/cjs/src/styles/styled/types.d.ts +48 -0
- package/cjs/src/styles/styled/types.js +2 -0
- package/cjs/src/theme/__tests__/BaseTheme.test.d.ts +1 -0
- package/cjs/src/theme/__tests__/BaseTheme.test.js +56 -0
- package/cjs/src/theme/baseTheme.d.ts +27 -0
- package/cjs/src/theme/baseTheme.js +23 -0
- package/cjs/src/theme/components.d.ts +20 -0
- package/cjs/src/theme/components.js +28 -0
- package/cjs/src/theme/constants.d.ts +9 -0
- package/cjs/src/theme/constants.js +13 -0
- package/cjs/src/theme/elevation.d.ts +8 -0
- package/cjs/src/theme/elevation.js +10 -0
- package/cjs/src/theme/index.d.ts +5 -0
- package/cjs/src/theme/index.js +17 -0
- package/cjs/src/theme/palette/brandPalette.d.ts +15 -0
- package/cjs/src/theme/palette/brandPalette.js +85 -0
- package/cjs/src/theme/palette/index.d.ts +2 -0
- package/cjs/src/theme/palette/index.js +14 -0
- package/cjs/src/theme/palette/palette.d.ts +29 -0
- package/cjs/src/theme/palette/palette.js +108 -0
- package/cjs/src/theme/shape.d.ts +6 -0
- package/cjs/src/theme/shape.js +8 -0
- package/cjs/src/theme/typography.d.ts +19 -0
- package/cjs/src/theme/typography.js +112 -0
- package/esm/index.d.ts +1 -0
- package/esm/index.js +1 -0
- package/esm/src/Badge/Badge.d.ts +3 -0
- package/esm/src/Badge/Badge.js +29 -0
- package/esm/src/Badge/index.d.ts +2 -0
- package/esm/src/Badge/index.js +2 -0
- package/esm/src/Badge/styled.d.ts +50 -0
- package/esm/src/Badge/styled.js +60 -0
- package/esm/src/Badge/types.d.ts +5 -0
- package/esm/src/Badge/types.js +1 -0
- package/esm/src/Button/Button.d.ts +2 -0
- package/esm/src/Button/Button.js +29 -0
- package/esm/src/Button/index.d.ts +2 -0
- package/esm/src/Button/index.js +2 -0
- package/esm/src/Button/styled.d.ts +13 -0
- package/esm/src/Button/styled.js +30 -0
- package/esm/src/Button/types.d.ts +7 -0
- package/esm/src/Button/types.js +1 -0
- package/esm/src/ButtonBase/ButtonBase.d.ts +2 -0
- package/esm/src/ButtonBase/ButtonBase.js +29 -0
- package/esm/src/ButtonBase/constants.d.ts +22 -0
- package/esm/src/ButtonBase/constants.js +26 -0
- package/esm/src/ButtonBase/index.d.ts +3 -0
- package/esm/src/ButtonBase/index.js +3 -0
- package/esm/src/ButtonBase/styled.d.ts +32 -0
- package/esm/src/ButtonBase/styled.js +196 -0
- package/esm/src/ButtonBase/types.d.ts +11 -0
- package/esm/src/ButtonBase/types.js +1 -0
- package/esm/src/CircularProgress/CircularProgress.d.ts +3 -0
- package/esm/src/CircularProgress/CircularProgress.js +29 -0
- package/esm/src/CircularProgress/constants.d.ts +9 -0
- package/esm/src/CircularProgress/constants.js +11 -0
- package/esm/src/CircularProgress/index.d.ts +2 -0
- package/esm/src/CircularProgress/index.js +2 -0
- package/esm/src/CircularProgress/styled.d.ts +8 -0
- package/esm/src/CircularProgress/styled.js +23 -0
- package/esm/src/CircularProgress/types.d.ts +8 -0
- package/esm/src/CircularProgress/types.js +1 -0
- package/esm/src/IconButton/IconButton.d.ts +2 -0
- package/esm/src/IconButton/IconButton.js +28 -0
- package/esm/src/IconButton/index.d.ts +1 -0
- package/esm/src/IconButton/index.js +1 -0
- package/esm/src/IconButton/styled.d.ts +19 -0
- package/esm/src/IconButton/styled.js +21 -0
- package/esm/src/ThemeProvider/ThemeProvider.d.ts +7 -0
- package/esm/src/ThemeProvider/ThemeProvider.js +18 -0
- package/esm/src/ThemeProvider/index.d.ts +1 -0
- package/esm/src/ThemeProvider/index.js +1 -0
- package/esm/src/Typography/Typography.d.ts +7 -0
- package/esm/src/Typography/Typography.js +29 -0
- package/esm/src/Typography/index.d.ts +1 -0
- package/esm/src/Typography/index.js +1 -0
- package/esm/src/index.d.ts +8 -0
- package/esm/src/index.js +8 -0
- package/esm/src/styles/index.d.ts +1 -0
- package/esm/src/styles/index.js +1 -0
- package/esm/src/styles/styled/index.d.ts +1 -0
- package/esm/src/styles/styled/index.js +1 -0
- package/esm/src/styles/styled/styled.d.ts +2 -0
- package/esm/src/styles/styled/styled.js +2 -0
- package/esm/src/styles/styled/types.d.ts +48 -0
- package/esm/src/styles/styled/types.js +1 -0
- package/esm/src/theme/__tests__/BaseTheme.test.d.ts +1 -0
- package/esm/src/theme/__tests__/BaseTheme.test.js +54 -0
- package/esm/src/theme/baseTheme.d.ts +27 -0
- package/esm/src/theme/baseTheme.js +19 -0
- package/esm/src/theme/components.d.ts +20 -0
- package/esm/src/theme/components.js +24 -0
- package/esm/src/theme/constants.d.ts +9 -0
- package/esm/src/theme/constants.js +10 -0
- package/esm/src/theme/elevation.d.ts +8 -0
- package/esm/src/theme/elevation.js +7 -0
- package/esm/src/theme/index.d.ts +5 -0
- package/esm/src/theme/index.js +5 -0
- package/esm/src/theme/palette/brandPalette.d.ts +15 -0
- package/esm/src/theme/palette/brandPalette.js +82 -0
- package/esm/src/theme/palette/index.d.ts +2 -0
- package/esm/src/theme/palette/index.js +2 -0
- package/esm/src/theme/palette/palette.d.ts +29 -0
- package/esm/src/theme/palette/palette.js +104 -0
- package/esm/src/theme/shape.d.ts +6 -0
- package/esm/src/theme/shape.js +5 -0
- package/esm/src/theme/typography.d.ts +19 -0
- package/esm/src/theme/typography.js +108 -0
- package/package.json +6 -12
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
2
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
3
|
+
return cooked;
|
|
4
|
+
};
|
|
5
|
+
var __assign = (this && this.__assign) || function () {
|
|
6
|
+
__assign = Object.assign || function(t) {
|
|
7
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
8
|
+
s = arguments[i];
|
|
9
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
10
|
+
t[p] = s[p];
|
|
11
|
+
}
|
|
12
|
+
return t;
|
|
13
|
+
};
|
|
14
|
+
return __assign.apply(this, arguments);
|
|
15
|
+
};
|
|
16
|
+
import ButtonUnstyled, { buttonUnstyledClasses, } from '@mui/base/ButtonUnstyled';
|
|
17
|
+
import { styled } from '../styles';
|
|
18
|
+
import { ButtonColors, ButtonSizes, ButtonStates, ButtonVariants, } from './constants';
|
|
19
|
+
var BACKGROUND_COLOR_VARIANTS = {
|
|
20
|
+
default: {
|
|
21
|
+
contained: '800',
|
|
22
|
+
light: '100',
|
|
23
|
+
text: '100',
|
|
24
|
+
},
|
|
25
|
+
hover: {
|
|
26
|
+
contained: '700',
|
|
27
|
+
light: '200',
|
|
28
|
+
text: '200',
|
|
29
|
+
},
|
|
30
|
+
focus: {
|
|
31
|
+
contained: '900',
|
|
32
|
+
light: '100',
|
|
33
|
+
text: '100',
|
|
34
|
+
},
|
|
35
|
+
};
|
|
36
|
+
export var getColor = function (_a) {
|
|
37
|
+
var theme = _a.theme, customVariant = _a.customVariant, customColor = _a.customColor, buttonState = _a.buttonState;
|
|
38
|
+
var palette = theme.palette;
|
|
39
|
+
if (buttonState === ButtonStates.ACTIVE) {
|
|
40
|
+
if (customVariant === ButtonVariants.LINK)
|
|
41
|
+
return palette.grey['900'];
|
|
42
|
+
return palette.primary.contrastText;
|
|
43
|
+
}
|
|
44
|
+
if (customVariant === ButtonVariants.TEXT) {
|
|
45
|
+
if (buttonState === ButtonStates.FOCUS)
|
|
46
|
+
return theme.palette.primary.main;
|
|
47
|
+
return palette.grey['900'];
|
|
48
|
+
}
|
|
49
|
+
if (customVariant === ButtonVariants.CONTAINED)
|
|
50
|
+
return palette.primary.contrastText;
|
|
51
|
+
if (customVariant === ButtonVariants.LIGHT) {
|
|
52
|
+
if (customColor === ButtonColors.PRIMARY) {
|
|
53
|
+
if (buttonState === ButtonStates.DEFAULT)
|
|
54
|
+
return palette.grey['900'];
|
|
55
|
+
if (buttonState === ButtonStates.HOVER)
|
|
56
|
+
return palette.grey['900'];
|
|
57
|
+
if (buttonState === ButtonStates.FOCUS)
|
|
58
|
+
return palette.primary['800'];
|
|
59
|
+
}
|
|
60
|
+
if (customColor === ButtonColors.ERROR)
|
|
61
|
+
return palette.red['900'];
|
|
62
|
+
if (customColor === ButtonColors.SUCCESS)
|
|
63
|
+
return palette.green['900'];
|
|
64
|
+
if (customColor === ButtonColors.WARNING)
|
|
65
|
+
return palette.yellow['900'];
|
|
66
|
+
return palette.grey['900'];
|
|
67
|
+
}
|
|
68
|
+
if (customVariant === ButtonVariants.LINK) {
|
|
69
|
+
if (buttonState === ButtonStates.DEFAULT)
|
|
70
|
+
return palette.primary['800'];
|
|
71
|
+
if (buttonState === ButtonStates.HOVER)
|
|
72
|
+
return palette.primary['700'];
|
|
73
|
+
if (buttonState === ButtonStates.FOCUS)
|
|
74
|
+
return palette.primary.dark;
|
|
75
|
+
return palette.primary.main;
|
|
76
|
+
}
|
|
77
|
+
return palette.grey['900'];
|
|
78
|
+
};
|
|
79
|
+
export var getBgText = function (_a) {
|
|
80
|
+
var palette = _a.palette, buttonState = _a.buttonState, colorVariant = _a.colorVariant;
|
|
81
|
+
if (buttonState === ButtonStates.HOVER)
|
|
82
|
+
return palette.grey[colorVariant];
|
|
83
|
+
if (buttonState === ButtonStates.FOCUS)
|
|
84
|
+
return palette.primary[colorVariant];
|
|
85
|
+
return 'transparent';
|
|
86
|
+
};
|
|
87
|
+
var getBgContained = function (_a) {
|
|
88
|
+
var palette = _a.palette, colorVariant = _a.colorVariant, customColor = _a.customColor;
|
|
89
|
+
if (customColor === ButtonColors.ERROR)
|
|
90
|
+
return palette.red[colorVariant];
|
|
91
|
+
if (customColor === ButtonColors.SUCCESS)
|
|
92
|
+
return palette.green[colorVariant];
|
|
93
|
+
if (customColor === ButtonColors.WARNING)
|
|
94
|
+
return palette.yellow[colorVariant];
|
|
95
|
+
if (customColor === ButtonColors.PRIMARY)
|
|
96
|
+
return palette.primary[colorVariant];
|
|
97
|
+
return 'transparent';
|
|
98
|
+
};
|
|
99
|
+
var getBgLight = function (_a) {
|
|
100
|
+
var palette = _a.palette, colorVariant = _a.colorVariant, buttonState = _a.buttonState, customColor = _a.customColor;
|
|
101
|
+
if (customColor === ButtonColors.PRIMARY) {
|
|
102
|
+
if (buttonState === ButtonStates.DEFAULT)
|
|
103
|
+
return palette.grey[colorVariant];
|
|
104
|
+
if (buttonState === ButtonStates.HOVER)
|
|
105
|
+
return palette.grey[colorVariant];
|
|
106
|
+
if (buttonState === ButtonStates.FOCUS)
|
|
107
|
+
return palette.primary[colorVariant];
|
|
108
|
+
}
|
|
109
|
+
if (customColor === ButtonColors.ERROR)
|
|
110
|
+
return palette.red[colorVariant];
|
|
111
|
+
if (customColor === ButtonColors.SUCCESS)
|
|
112
|
+
return palette.green[colorVariant];
|
|
113
|
+
if (customColor === ButtonColors.WARNING)
|
|
114
|
+
return palette.yellow[colorVariant];
|
|
115
|
+
return 'transparent';
|
|
116
|
+
};
|
|
117
|
+
export var getBgColor = function (_a) {
|
|
118
|
+
var customColor = _a.customColor, customVariant = _a.customVariant, buttonState = _a.buttonState, theme = _a.theme;
|
|
119
|
+
var palette = theme.palette;
|
|
120
|
+
if (customVariant === ButtonVariants.LINK)
|
|
121
|
+
return 'transparent';
|
|
122
|
+
if (buttonState === ButtonStates.ACTIVE)
|
|
123
|
+
return palette.grey['900'];
|
|
124
|
+
var containedColor = BACKGROUND_COLOR_VARIANTS[buttonState].contained;
|
|
125
|
+
var lightColor = BACKGROUND_COLOR_VARIANTS[buttonState].light;
|
|
126
|
+
var textColor = BACKGROUND_COLOR_VARIANTS[buttonState].text;
|
|
127
|
+
if (customVariant === ButtonVariants.TEXT)
|
|
128
|
+
return getBgText({ buttonState: buttonState, palette: palette, colorVariant: textColor });
|
|
129
|
+
if (customVariant === ButtonVariants.CONTAINED)
|
|
130
|
+
return getBgContained({
|
|
131
|
+
palette: palette,
|
|
132
|
+
customColor: customColor,
|
|
133
|
+
colorVariant: containedColor,
|
|
134
|
+
});
|
|
135
|
+
if (customVariant === ButtonVariants.LIGHT)
|
|
136
|
+
return getBgLight({
|
|
137
|
+
palette: palette,
|
|
138
|
+
buttonState: buttonState,
|
|
139
|
+
customColor: customColor,
|
|
140
|
+
colorVariant: lightColor,
|
|
141
|
+
});
|
|
142
|
+
return 'transparent';
|
|
143
|
+
};
|
|
144
|
+
export var getButtonHeight = function (_a) {
|
|
145
|
+
var size = _a.size;
|
|
146
|
+
if (size === ButtonSizes.LARGE)
|
|
147
|
+
return '40px';
|
|
148
|
+
return '32px';
|
|
149
|
+
};
|
|
150
|
+
export var getButtonPadding = function (_a) {
|
|
151
|
+
var size = _a.size, theme = _a.theme;
|
|
152
|
+
if (size === ButtonSizes.LARGE)
|
|
153
|
+
return theme.spacing(2, 4, 2, 4);
|
|
154
|
+
return theme.spacing(1, 3, 1, 3);
|
|
155
|
+
};
|
|
156
|
+
export var getDisabledBgColor = function (_a) {
|
|
157
|
+
var theme = _a.theme, customVariant = _a.customVariant;
|
|
158
|
+
if (customVariant === ButtonVariants.LINK ||
|
|
159
|
+
customVariant === ButtonVariants.TEXT)
|
|
160
|
+
return 'transparent';
|
|
161
|
+
return theme.palette.grey['100'];
|
|
162
|
+
};
|
|
163
|
+
export var StyledButtonBase = styled(ButtonUnstyled, {
|
|
164
|
+
shouldForwardProp: function (prop) {
|
|
165
|
+
return prop !== 'customColor' && prop !== 'customVariant';
|
|
166
|
+
},
|
|
167
|
+
})(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n border: none;\n font-family: Ubuntu, serif;\n padding: ", ";\n height: ", ";\n border-radius: ", ";\n cursor: pointer;\n font-size: ", ";\n font-weight: ", ";\n display: inline-flex;\n align-items: center;\n justify-content: center;\n position: relative;\n\n background-color: ", ";\n color: ", ";\n\n &:hover {\n background-color: ", ";\n color: ", ";\n }\n\n &:focus {\n background-color: ", ";\n color: ", ";\n }\n\n &:active {\n background-color: ", ";\n color: ", ";\n }\n\n &.", " {\n cursor: unset;\n background-color: ", ";\n color: ", ";\n }\n"], ["\n border: none;\n font-family: Ubuntu, serif;\n padding: ", ";\n height: ", ";\n border-radius: ", ";\n cursor: pointer;\n font-size: ", ";\n font-weight: ", ";\n display: inline-flex;\n align-items: center;\n justify-content: center;\n position: relative;\n\n background-color: ", ";\n color: ", ";\n\n &:hover {\n background-color: ", ";\n color: ", ";\n }\n\n &:focus {\n background-color: ", ";\n color: ", ";\n }\n\n &:active {\n background-color: ", ";\n color: ", ";\n }\n\n &.", " {\n cursor: unset;\n background-color: ", ";\n color: ", ";\n }\n"])), getButtonPadding, getButtonHeight, function (_a) {
|
|
168
|
+
var theme = _a.theme;
|
|
169
|
+
return theme.shape.small;
|
|
170
|
+
}, function (_a) {
|
|
171
|
+
var theme = _a.theme;
|
|
172
|
+
return theme.typography.button.fontSize;
|
|
173
|
+
}, function (_a) {
|
|
174
|
+
var theme = _a.theme;
|
|
175
|
+
return theme.typography.button.fontWeight;
|
|
176
|
+
}, function (props) {
|
|
177
|
+
return getBgColor(__assign(__assign({}, props), { buttonState: ButtonStates.DEFAULT }));
|
|
178
|
+
}, function (props) {
|
|
179
|
+
return getColor(__assign(__assign({}, props), { buttonState: ButtonStates.DEFAULT }));
|
|
180
|
+
}, function (props) {
|
|
181
|
+
return getBgColor(__assign(__assign({}, props), { buttonState: ButtonStates.HOVER }));
|
|
182
|
+
}, function (props) {
|
|
183
|
+
return getColor(__assign(__assign({}, props), { buttonState: ButtonStates.HOVER }));
|
|
184
|
+
}, function (props) {
|
|
185
|
+
return getBgColor(__assign(__assign({}, props), { buttonState: ButtonStates.FOCUS }));
|
|
186
|
+
}, function (props) {
|
|
187
|
+
return getColor(__assign(__assign({}, props), { buttonState: ButtonStates.FOCUS }));
|
|
188
|
+
}, function (props) {
|
|
189
|
+
return getBgColor(__assign(__assign({}, props), { buttonState: ButtonStates.ACTIVE }));
|
|
190
|
+
}, function (props) {
|
|
191
|
+
return getColor(__assign(__assign({}, props), { buttonState: ButtonStates.ACTIVE }));
|
|
192
|
+
}, buttonUnstyledClasses.disabled, getDisabledBgColor, function (_a) {
|
|
193
|
+
var theme = _a.theme;
|
|
194
|
+
return theme.palette.grey['500'];
|
|
195
|
+
});
|
|
196
|
+
var templateObject_1;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ButtonUnstyledProps } from '@mui/base/ButtonUnstyled';
|
|
2
|
+
import { ButtonColors, ButtonSizes, ButtonStates, ButtonVariants } from './constants';
|
|
3
|
+
export declare type ButtonColor = `${ButtonColors}`;
|
|
4
|
+
export declare type ButtonVariant = `${ButtonVariants}`;
|
|
5
|
+
export declare type ButtonSize = `${ButtonSizes}`;
|
|
6
|
+
export declare type ButtonState = `${ButtonStates}`;
|
|
7
|
+
export declare type BaseButtonProps = Omit<ButtonUnstyledProps, 'color' | 'variant' | 'size'> & {
|
|
8
|
+
color?: ButtonColor;
|
|
9
|
+
variant?: ButtonVariant;
|
|
10
|
+
size?: ButtonSize;
|
|
11
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
13
|
+
var t = {};
|
|
14
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
15
|
+
t[p] = s[p];
|
|
16
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
17
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
18
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
19
|
+
t[p[i]] = s[p[i]];
|
|
20
|
+
}
|
|
21
|
+
return t;
|
|
22
|
+
};
|
|
23
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
24
|
+
import { StyledCircularProgress } from './styled';
|
|
25
|
+
export var CircularProgress = function (_a) {
|
|
26
|
+
var color = _a.color, size = _a.size, props = __rest(_a, ["color", "size"]);
|
|
27
|
+
return (_jsx(StyledCircularProgress, __assign({}, props, { customSize: size, customColor: color }), void 0));
|
|
28
|
+
};
|
|
29
|
+
export default CircularProgress;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export var CircularProgressColors;
|
|
2
|
+
(function (CircularProgressColors) {
|
|
3
|
+
CircularProgressColors["PRIMARY"] = "primary";
|
|
4
|
+
CircularProgressColors["INVERTED"] = "inverted";
|
|
5
|
+
})(CircularProgressColors || (CircularProgressColors = {}));
|
|
6
|
+
export var CircularProgressSizes;
|
|
7
|
+
(function (CircularProgressSizes) {
|
|
8
|
+
CircularProgressSizes["SMALL"] = "small";
|
|
9
|
+
CircularProgressSizes["MEDIUM"] = "medium";
|
|
10
|
+
CircularProgressSizes["NUMBER"] = "number";
|
|
11
|
+
})(CircularProgressSizes || (CircularProgressSizes = {}));
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Theme } from '../theme';
|
|
2
|
+
import { CircularProgressProps } from './types';
|
|
3
|
+
export declare const StyledCircularProgress: import("@emotion/styled").StyledComponent<import("@mui/material").CircularProgressProps & {
|
|
4
|
+
theme?: Theme | undefined;
|
|
5
|
+
} & Omit<CircularProgressProps, "color" | "size"> & {
|
|
6
|
+
customColor?: "primary" | "inverted" | undefined;
|
|
7
|
+
customSize?: "number" | "medium" | "small" | undefined;
|
|
8
|
+
}, {}, {}>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
2
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
3
|
+
return cooked;
|
|
4
|
+
};
|
|
5
|
+
import { CircularProgress } from '@mui/material';
|
|
6
|
+
import { styled } from '../styles';
|
|
7
|
+
import { CircularProgressColors, CircularProgressSizes } from './constants';
|
|
8
|
+
var getColor = function (_a) {
|
|
9
|
+
var theme = _a.theme, customColor = _a.customColor;
|
|
10
|
+
if (customColor === CircularProgressColors.PRIMARY)
|
|
11
|
+
return theme.palette.primary.dark;
|
|
12
|
+
return theme.palette.primary.contrastText;
|
|
13
|
+
};
|
|
14
|
+
var getCircularProgressSize = function (_a) {
|
|
15
|
+
var customSize = _a.customSize;
|
|
16
|
+
if (customSize === CircularProgressSizes.SMALL)
|
|
17
|
+
return '16px';
|
|
18
|
+
return '24px';
|
|
19
|
+
};
|
|
20
|
+
export var StyledCircularProgress = styled(CircularProgress, {
|
|
21
|
+
shouldForwardProp: function (prop) { return prop !== 'customColor' && prop !== 'customSize'; },
|
|
22
|
+
})(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n width: ", ";\n height: ", ";\n color: ", ";\n"], ["\n width: ", ";\n height: ", ";\n color: ", ";\n"])), getCircularProgressSize, getCircularProgressSize, function (props) { return getColor(props); });
|
|
23
|
+
var templateObject_1;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { CircularProgressProps as MuiCircularProgressProps } from '@mui/material';
|
|
2
|
+
import { CircularProgressColors, CircularProgressSizes } from './constants';
|
|
3
|
+
export declare type CircularProgressColor = `${CircularProgressColors}`;
|
|
4
|
+
export declare type CircularProgressSize = `${CircularProgressSizes}`;
|
|
5
|
+
export declare type CircularProgressProps = Omit<MuiCircularProgressProps, 'color' | 'size'> & {
|
|
6
|
+
color?: CircularProgressColor;
|
|
7
|
+
size?: CircularProgressSize;
|
|
8
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
13
|
+
var t = {};
|
|
14
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
15
|
+
t[p] = s[p];
|
|
16
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
17
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
18
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
19
|
+
t[p[i]] = s[p[i]];
|
|
20
|
+
}
|
|
21
|
+
return t;
|
|
22
|
+
};
|
|
23
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
24
|
+
import { StyledIconButton } from './styled';
|
|
25
|
+
export var IconButton = function (_a) {
|
|
26
|
+
var children = _a.children, props = __rest(_a, ["children"]);
|
|
27
|
+
return _jsx(StyledIconButton, __assign({}, props, { children: children }), void 0);
|
|
28
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './IconButton';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './IconButton';
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { Theme } from '../theme';
|
|
3
|
+
import { ButtonProps } from '../Button';
|
|
4
|
+
declare type StyledIconButtonThemeProps = ButtonProps & {
|
|
5
|
+
theme: Theme;
|
|
6
|
+
};
|
|
7
|
+
export declare const getButtonHeight: ({ size, }: StyledIconButtonThemeProps) => string;
|
|
8
|
+
export declare const StyledIconButton: import("@emotion/styled").StyledComponent<Omit<import("@mui/base/ButtonUnstyled/ButtonUnstyledProps").default<"button", {}>, "color" | "variant" | "size"> & {
|
|
9
|
+
color?: "primary" | "error" | "warning" | "success" | undefined;
|
|
10
|
+
variant?: "link" | "light" | "text" | "contained" | undefined;
|
|
11
|
+
size?: "large" | "medium" | undefined;
|
|
12
|
+
} & {
|
|
13
|
+
theme?: Theme | undefined;
|
|
14
|
+
} & {
|
|
15
|
+
loading?: boolean | undefined;
|
|
16
|
+
startIcon?: import("react").ReactNode;
|
|
17
|
+
endIcon?: import("react").ReactNode;
|
|
18
|
+
}, {}, {}>;
|
|
19
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
var __makeTemplateObject = (this && this.__makeTemplateObject) || function (cooked, raw) {
|
|
2
|
+
if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
|
|
3
|
+
return cooked;
|
|
4
|
+
};
|
|
5
|
+
import { styled } from '../styles';
|
|
6
|
+
import { ButtonBase, ButtonSizes } from '../ButtonBase';
|
|
7
|
+
export var getButtonHeight = function (_a) {
|
|
8
|
+
var size = _a.size;
|
|
9
|
+
if (size === ButtonSizes.LARGE)
|
|
10
|
+
return '40px';
|
|
11
|
+
return '32px';
|
|
12
|
+
};
|
|
13
|
+
export var StyledIconButton = styled(ButtonBase, {
|
|
14
|
+
shouldForwardProp: function (prop) {
|
|
15
|
+
return prop !== 'startIcon' && prop !== 'endIcon' && prop !== 'loading';
|
|
16
|
+
},
|
|
17
|
+
})(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n height: ", ";\n width: ", ";\n padding: ", ";\n"], ["\n height: ", ";\n width: ", ";\n padding: ", ";\n"])), getButtonHeight, getButtonHeight, function (_a) {
|
|
18
|
+
var theme = _a.theme;
|
|
19
|
+
return theme.spacing(1);
|
|
20
|
+
});
|
|
21
|
+
var templateObject_1;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
|
+
import { CssBaseline, ThemeProvider as MuiThemeProvider } from '@mui/material';
|
|
14
|
+
import { ThemeProvider as EmotionThemeProvider } from '@emotion/react';
|
|
15
|
+
export var ThemeProvider = function (_a) {
|
|
16
|
+
var theme = _a.theme, children = _a.children;
|
|
17
|
+
return (_jsx(MuiThemeProvider, __assign({ theme: theme }, { children: _jsxs(EmotionThemeProvider, __assign({ theme: theme }, { children: [_jsx(CssBaseline, {}, void 0), children] }), void 0) }), void 0));
|
|
18
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ThemeProvider';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './ThemeProvider';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { TypographyProps as MuiTypographyProps } from '@mui/material/Typography';
|
|
2
|
+
import { Variant } from '@mui/material/styles/createTypography';
|
|
3
|
+
export declare type TypographyProps = Omit<MuiTypographyProps, 'variant'> & {
|
|
4
|
+
variant?: Variant | 'h7' | 'h8' | 'h9' | 'ui' | 'link' | 'pointer' | 'small' | 'code';
|
|
5
|
+
};
|
|
6
|
+
export declare const Typography: ({ variant, children, ...props }: TypographyProps) => JSX.Element;
|
|
7
|
+
export default Typography;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __rest = (this && this.__rest) || function (s, e) {
|
|
13
|
+
var t = {};
|
|
14
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
15
|
+
t[p] = s[p];
|
|
16
|
+
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
17
|
+
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
18
|
+
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
19
|
+
t[p[i]] = s[p[i]];
|
|
20
|
+
}
|
|
21
|
+
return t;
|
|
22
|
+
};
|
|
23
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
24
|
+
import MuiTypography from '@mui/material/Typography';
|
|
25
|
+
export var Typography = function (_a) {
|
|
26
|
+
var variant = _a.variant, children = _a.children, props = __rest(_a, ["variant", "children"]);
|
|
27
|
+
return (_jsx(MuiTypography, __assign({ variant: variant }, props, { children: children }), void 0));
|
|
28
|
+
};
|
|
29
|
+
export default Typography;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Typography';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Typography';
|
package/esm/src/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './styled';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './styled';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './styled';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './styled';
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { PropsOf } from '@emotion/react';
|
|
3
|
+
import { CreateStyledComponent, FilteringStyledOptions, StyledOptions } from '@emotion/styled/base';
|
|
4
|
+
import { Theme } from '../../theme';
|
|
5
|
+
/**
|
|
6
|
+
* @desc
|
|
7
|
+
* This function accepts a React component or tag ('div', 'a' etc).
|
|
8
|
+
*
|
|
9
|
+
* @example styled(MyComponent)({ width: 100 })
|
|
10
|
+
* @example styled(MyComponent)(myComponentProps => ({ width: myComponentProps.width })
|
|
11
|
+
* @example styled('div')({ width: 100 })
|
|
12
|
+
* @example styled('div')<Props>(props => ({ width: props.width })
|
|
13
|
+
*/
|
|
14
|
+
interface BaseCreateStyled {
|
|
15
|
+
<C extends React.ComponentClass<React.ComponentProps<C>>, ForwardedProps extends keyof React.ComponentProps<C> = keyof React.ComponentProps<C>>(component: C, options: FilteringStyledOptions<React.ComponentProps<C>, ForwardedProps>): CreateStyledComponent<Pick<PropsOf<C>, ForwardedProps> & {
|
|
16
|
+
theme?: Theme;
|
|
17
|
+
}, {}, {
|
|
18
|
+
ref?: React.Ref<InstanceType<C>>;
|
|
19
|
+
}>;
|
|
20
|
+
<C extends React.ComponentClass<React.ComponentProps<C>>>(component: C, options?: StyledOptions<React.ComponentProps<C>>): CreateStyledComponent<PropsOf<C> & {
|
|
21
|
+
theme?: Theme;
|
|
22
|
+
}, {}, {
|
|
23
|
+
ref?: React.Ref<InstanceType<C>>;
|
|
24
|
+
}>;
|
|
25
|
+
<C extends React.ComponentType<React.ComponentProps<C>>, ForwardedProps extends keyof React.ComponentProps<C> = keyof React.ComponentProps<C>>(component: C, options: FilteringStyledOptions<React.ComponentProps<C>, ForwardedProps>): CreateStyledComponent<Pick<PropsOf<C>, ForwardedProps> & {
|
|
26
|
+
theme?: Theme;
|
|
27
|
+
}>;
|
|
28
|
+
<C extends React.ComponentType<React.ComponentProps<C>>>(component: C, options?: StyledOptions<React.ComponentProps<C>>): CreateStyledComponent<PropsOf<C> & {
|
|
29
|
+
theme?: Theme;
|
|
30
|
+
}>;
|
|
31
|
+
<Tag extends keyof JSX.IntrinsicElements, ForwardedProps extends keyof JSX.IntrinsicElements[Tag] = keyof JSX.IntrinsicElements[Tag]>(tag: Tag, options: FilteringStyledOptions<JSX.IntrinsicElements[Tag], ForwardedProps>): CreateStyledComponent<{
|
|
32
|
+
theme?: Theme;
|
|
33
|
+
as?: React.ElementType;
|
|
34
|
+
}, Pick<JSX.IntrinsicElements[Tag], ForwardedProps>>;
|
|
35
|
+
<Tag extends keyof JSX.IntrinsicElements>(tag: Tag, options?: StyledOptions<JSX.IntrinsicElements[Tag]>): CreateStyledComponent<{
|
|
36
|
+
theme?: Theme;
|
|
37
|
+
as?: React.ElementType;
|
|
38
|
+
}, JSX.IntrinsicElements[Tag]>;
|
|
39
|
+
}
|
|
40
|
+
declare type StyledTags = {
|
|
41
|
+
[Tag in keyof JSX.IntrinsicElements]: CreateStyledComponent<{
|
|
42
|
+
theme?: Theme;
|
|
43
|
+
as?: React.ElementType;
|
|
44
|
+
}, JSX.IntrinsicElements[Tag]>;
|
|
45
|
+
};
|
|
46
|
+
export interface CreateStyled extends BaseCreateStyled, StyledTags {
|
|
47
|
+
}
|
|
48
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { createTheme } from '../baseTheme';
|
|
2
|
+
import { Brand } from '../constants';
|
|
3
|
+
describe('createTheme', function () {
|
|
4
|
+
var fontsUrls = {
|
|
5
|
+
bold: {
|
|
6
|
+
woff: '',
|
|
7
|
+
woff2: '',
|
|
8
|
+
},
|
|
9
|
+
regular: {
|
|
10
|
+
woff: '',
|
|
11
|
+
woff2: '',
|
|
12
|
+
},
|
|
13
|
+
medium: {
|
|
14
|
+
woff: '',
|
|
15
|
+
woff2: '',
|
|
16
|
+
},
|
|
17
|
+
light: {
|
|
18
|
+
woff: '',
|
|
19
|
+
woff2: '',
|
|
20
|
+
},
|
|
21
|
+
};
|
|
22
|
+
it('Theme merge done correctly', function () {
|
|
23
|
+
var extendedTheme = createTheme({
|
|
24
|
+
brand: Brand.DEFAULT,
|
|
25
|
+
fontsUrls: fontsUrls,
|
|
26
|
+
options: {
|
|
27
|
+
typography: { h1: { lineHeight: 12 } },
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
expect(extendedTheme.typography.h1.lineHeight).toBe(12);
|
|
31
|
+
});
|
|
32
|
+
it('Color should be taken depending on the brand', function () {
|
|
33
|
+
var theme = createTheme({ brand: Brand.SIGN, fontsUrls: fontsUrls });
|
|
34
|
+
var expected = {
|
|
35
|
+
primary: {
|
|
36
|
+
main: '#376798',
|
|
37
|
+
dark: '#325D89',
|
|
38
|
+
},
|
|
39
|
+
secondary: {
|
|
40
|
+
main: '#4099AC',
|
|
41
|
+
dark: '#325D89',
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
expect(theme.palette).toMatchObject(expected);
|
|
45
|
+
});
|
|
46
|
+
it('Spacing are calculated correctly', function () {
|
|
47
|
+
var theme = createTheme({ brand: Brand.SIGN, fontsUrls: fontsUrls });
|
|
48
|
+
expect(theme.spacing(2)).toBe('8px');
|
|
49
|
+
});
|
|
50
|
+
it('Theme has elevation params', function () {
|
|
51
|
+
var theme = createTheme({ brand: Brand.SIGN, fontsUrls: fontsUrls });
|
|
52
|
+
expect(theme.elevation[100]).toBe('box-shadow: 0px 0px 1px 0px #072D574F; box-shadow: 0px 1px 1px 0px #072D5740;');
|
|
53
|
+
});
|
|
54
|
+
});
|