@raketa-builder/ui 0.1.1 → 0.1.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.
@@ -4,5 +4,5 @@ CLI Using tsconfig: tsconfig.json
4
4
  CLI tsup v6.5.0
5
5
  CLI Target: es6
6
6
  CJS Build start
7
- CJS dist/index.js 30.36 KB
8
- CJS ⚡️ Build success in 23ms
7
+ CJS dist/index.js 32.23 KB
8
+ CJS ⚡️ Build success in 18ms
@@ -1,13 +1,13 @@
1
1
  $ TIMING=1 eslint "**/*.js"
2
2
  Rule | Time (ms) | Relative
3
3
  :------------------------------|----------:|--------:
4
- react/display-name | 7.720 | 33.1%
5
- react/no-direct-mutation-state | 5.256 | 22.5%
6
- react/require-render-return | 3.693 | 15.8%
7
- react/no-deprecated | 1.019 | 4.4%
8
- react-hooks/rules-of-hooks | 1.018 | 4.4%
9
- react-hooks/exhaustive-deps | 0.964 | 4.1%
10
- react/no-string-refs | 0.921 | 3.9%
11
- react/jsx-no-comment-textnodes | 0.302 | 1.3%
12
- react/no-unescaped-entities | 0.290 | 1.2%
13
- turbo/no-undeclared-env-vars | 0.211 | 0.9%
4
+ react/display-name | 5.504 | 31.9%
5
+ react/no-direct-mutation-state | 3.788 | 21.9%
6
+ react/require-render-return | 2.444 | 14.1%
7
+ react-hooks/exhaustive-deps | 0.876 | 5.1%
8
+ react/no-deprecated | 0.860 | 5.0%
9
+ react-hooks/rules-of-hooks | 0.758 | 4.4%
10
+ react/no-string-refs | 0.562 | 3.3%
11
+ react/no-unescaped-entities | 0.247 | 1.4%
12
+ react/jsx-no-comment-textnodes | 0.239 | 1.4%
13
+ react/no-danger-with-children | 0.194 | 1.1%
package/CHANGELOG.md CHANGED
@@ -1,11 +1,5 @@
1
1
  # @raketa-builder/ui
2
2
 
3
- ## 0.1.1
4
-
5
- ### Patch Changes
6
-
7
- - Updated Pagination to comply with Next 13
8
-
9
3
  ## 0.1.0
10
4
 
11
5
  ### Minor Changes
package/dist/index.js CHANGED
@@ -59,11 +59,13 @@ __export(src_exports, {
59
59
  Col: () => Col,
60
60
  Container: () => Container_default,
61
61
  DataGrid: () => DataGrid_default,
62
+ DefaultAvatar: () => DefaultAvatar_default,
62
63
  Field: () => Field_default,
63
64
  FormGroup: () => FormGroup_default,
64
65
  H: () => H_default,
65
66
  Handle: () => Handle_default,
66
67
  Hint: () => Hint_default,
68
+ ImageAvatar: () => ImageAvatar_default,
67
69
  Input: () => Input_default,
68
70
  Label: () => Label_default,
69
71
  LanguageSwitcher: () => LanguageSwitcher_default,
@@ -1027,17 +1029,81 @@ var LanguageSwitcher = ({ current, navigation }) => {
1027
1029
  ] });
1028
1030
  };
1029
1031
  var LanguageSwitcher_default = LanguageSwitcher;
1032
+
1033
+ // src/ImageAvatar.js
1034
+ var import_styled_components25 = __toESM(require("styled-components"));
1035
+ var ImageAvatar = import_styled_components25.default.img`
1036
+ ${reset_default};
1037
+ display: block;
1038
+ width: ${(props) => props.size};
1039
+ height: ${(props) => props.size};
1040
+ border-radius: 50%;
1041
+ `;
1042
+ ImageAvatar.defaultProps = {
1043
+ size: "24px"
1044
+ };
1045
+ var ImageAvatar_default = ImageAvatar;
1046
+
1047
+ // src/DefaultAvatar.jsx
1048
+ var import_react8 = __toESM(require("react"));
1049
+ var import_styled_components26 = __toESM(require("styled-components"));
1050
+ var import_jsx_runtime8 = require("react/jsx-runtime");
1051
+ var AVATAR_COLORS = [
1052
+ "darkkhaki",
1053
+ "palevioletred",
1054
+ "mediumseagreen",
1055
+ "olivedrab",
1056
+ "steelblue",
1057
+ "salmon",
1058
+ "indianred",
1059
+ "mediumpurple",
1060
+ "coral",
1061
+ "rosybrown",
1062
+ "lightseagreen",
1063
+ "plum",
1064
+ "tan"
1065
+ ];
1066
+ var initialsToColor = (initials, colors) => {
1067
+ let asciiVal = initials.charCodeAt(0);
1068
+ asciiVal += initials.charCodeAt(1);
1069
+ let colorIndex = asciiVal % colors.length;
1070
+ return colors[colorIndex];
1071
+ };
1072
+ var DefaultAvatarStyles = import_styled_components26.default.div`
1073
+ ${reset_default};
1074
+ display: flex;
1075
+ justify-content: center;
1076
+ align-items: center;
1077
+ width: ${(props) => props.size};
1078
+ height: ${(props) => props.size};
1079
+ border-radius: 50%;
1080
+ background-color: ${(props) => initialsToColor(props.initials, AVATAR_COLORS)};
1081
+ color: #fff;
1082
+ font-size: calc(${(props) => props.size} * 0.5);
1083
+ text-shadow: 1px 1px rgba(0, 0, 0, 0.1)
1084
+ `;
1085
+ var DefaultAvatar = (_a) => {
1086
+ var _b = _a, { initials } = _b, props = __objRest(_b, ["initials"]);
1087
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(DefaultAvatarStyles, __spreadProps(__spreadValues({ initials }, props), { children: initials }));
1088
+ };
1089
+ DefaultAvatar.defaultProps = {
1090
+ size: "24px",
1091
+ initials: "AA"
1092
+ };
1093
+ var DefaultAvatar_default = DefaultAvatar;
1030
1094
  // Annotate the CommonJS export names for ESM import in node:
1031
1095
  0 && (module.exports = {
1032
1096
  Button,
1033
1097
  Col,
1034
1098
  Container,
1035
1099
  DataGrid,
1100
+ DefaultAvatar,
1036
1101
  Field,
1037
1102
  FormGroup,
1038
1103
  H,
1039
1104
  Handle,
1040
1105
  Hint,
1106
+ ImageAvatar,
1041
1107
  Input,
1042
1108
  Label,
1043
1109
  LanguageSwitcher,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@raketa-builder/ui",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "license": "MIT",
@@ -0,0 +1,54 @@
1
+ import React from 'react';
2
+ import styled from 'styled-components';
3
+ import reset from './reset';
4
+
5
+ const AVATAR_COLORS = [
6
+ 'darkkhaki',
7
+ 'palevioletred',
8
+ 'mediumseagreen',
9
+ 'olivedrab',
10
+ 'steelblue',
11
+ 'salmon',
12
+ 'indianred',
13
+ 'mediumpurple',
14
+ 'coral',
15
+ 'rosybrown',
16
+ 'lightseagreen',
17
+ 'plum',
18
+ 'tan',
19
+ ];
20
+
21
+ const initialsToColor = (initials, colors) => {
22
+ let asciiVal = initials.charCodeAt(0);
23
+ asciiVal += initials.charCodeAt(1);
24
+ let colorIndex = asciiVal % colors.length;
25
+
26
+ return colors[colorIndex];
27
+ }
28
+
29
+ const DefaultAvatarStyles = styled.div`
30
+ ${reset};
31
+ display: flex;
32
+ justify-content: center;
33
+ align-items: center;
34
+ width: ${props => props.size};
35
+ height: ${props => props.size};
36
+ border-radius: 50%;
37
+ background-color: ${props => initialsToColor(props.initials, AVATAR_COLORS)};
38
+ color: #fff;
39
+ font-size: calc(${props => props.size} * 0.5);
40
+ text-shadow: 1px 1px rgba(0, 0, 0, 0.1)
41
+ `;
42
+
43
+ const DefaultAvatar = ({ initials, ...props }) => (
44
+ <DefaultAvatarStyles initials={initials} {...props}>
45
+ {initials}
46
+ </DefaultAvatarStyles>
47
+ );
48
+
49
+ DefaultAvatar.defaultProps = {
50
+ size: '24px',
51
+ initials: 'AA',
52
+ }
53
+
54
+ export default DefaultAvatar;
@@ -0,0 +1,16 @@
1
+ import styled from 'styled-components';
2
+ import reset from './reset';
3
+
4
+ const ImageAvatar = styled.img`
5
+ ${reset};
6
+ display: block;
7
+ width: ${props => props.size};
8
+ height: ${props => props.size};
9
+ border-radius: 50%;
10
+ `;
11
+
12
+ ImageAvatar.defaultProps = {
13
+ size: '24px',
14
+ }
15
+
16
+ export default ImageAvatar;
package/src/index.js CHANGED
@@ -26,3 +26,5 @@ export { Navigation, NavItem } from "./Navigation";
26
26
  export { default as PageTitle } from "./PageTitle";
27
27
  export { default as Pagination } from "./Pagination";
28
28
  export { default as LanguageSwitcher } from "./LanguageSwitcher";
29
+ export { default as ImageAvatar } from "./ImageAvatar";
30
+ export { default as DefaultAvatar } from "./DefaultAvatar";