@raketa-builder/ui 0.2.2-alpha → 0.4.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@raketa-builder/ui",
3
- "version": "0.2.2-alpha",
3
+ "version": "0.4.0",
4
4
  "main": "./dist/index.js",
5
5
  "types": "./dist/index.d.ts",
6
6
  "license": "MIT",
@@ -10,7 +10,6 @@
10
10
  "dev": "tsup src/index.js --format cjs --loader \".js=jsx\" --watch"
11
11
  },
12
12
  "peerDependencies": {
13
- "styled-components": "5.1.0",
14
13
  "react": "18.2.0",
15
14
  "react-dom": "18.2.0"
16
15
  },
@@ -5,7 +5,9 @@ const Button = ({ type, size, variant, className, ...props }) => (
5
5
  <button
6
6
  type={type}
7
7
  className={cn(
8
- "r-reset r-reset-button r-button",
8
+ "r-reset",
9
+ "r-reset-button",
10
+ "r-button",
9
11
  `r-button-${size}`,
10
12
  `r-button-${variant}`,
11
13
  className
@@ -0,0 +1,8 @@
1
+ import React from "react";
2
+ import cn from "./cn";
3
+
4
+ const Container = ({ className, ...props }) => (
5
+ <div className={cn("r-reset", "r-container", className)} {...props} />
6
+ );
7
+
8
+ export default Container;
package/src/DataGrid.jsx CHANGED
@@ -1,62 +1,13 @@
1
1
  import React from "react";
2
- import styled from "styled-components";
3
- import reset from "./reset";
2
+ import cn from "./cn";
4
3
 
5
- const Wrapper = styled.div`
6
- ${reset}
7
-
8
- table {
9
- border-collapse: collapse;
10
- width: 100%;
11
- margin-bottom: 1em;
12
-
13
- th,
14
- td {
15
- padding: 0.5em;
16
- text-align: left;
17
- }
18
-
19
- tr {
20
- border-bottom: 1px solid ${(props) => props.theme.colors.lightGray};
21
- transition: all 0.3s ease-in-out;
22
- }
23
-
24
- a {
25
- color: ${(props) => props.theme.colors.primary};
26
- }
27
-
28
- tbody {
29
- tr {
30
- &:hover {
31
- border-color: ${(props) => props.theme.colors.gray};
32
-
33
- td {
34
- background-color: ${(props) => props.theme.colors.lighterGray};
35
- }
36
- }
37
- }
38
- }
39
-
40
- .actions {
41
- width: 50px;
42
- white-space: nowrap;
43
-
44
- div:first-of-type {
45
- display: flex;
46
- align-items: center;
47
- }
48
-
49
- a,
50
- button {
51
- margin-left: 0.5em;
52
- }
53
- }
54
- }
55
- `;
4
+ const Wrapper = ({ className, ...props }) => (
5
+ <div className={cn("r-reset", className)} {...props} />
6
+ );
56
7
 
57
8
  const DataGrid = ({ list, header, row }) => (
58
9
  <Wrapper>
59
- <table>
10
+ <table className="r-table">
60
11
  <thead>
61
12
  <tr>{header()}</tr>
62
13
  </thead>
@@ -1,21 +1,20 @@
1
- import React from 'react';
2
- import styled from 'styled-components';
3
- import reset from './reset';
1
+ import React from "react";
2
+ import cn from "./cn";
4
3
 
5
4
  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',
5
+ "darkkhaki",
6
+ "palevioletred",
7
+ "mediumseagreen",
8
+ "olivedrab",
9
+ "steelblue",
10
+ "salmon",
11
+ "indianred",
12
+ "mediumpurple",
13
+ "coral",
14
+ "rosybrown",
15
+ "lightseagreen",
16
+ "plum",
17
+ "tan",
19
18
  ];
20
19
 
21
20
  const initialsToColor = (initials, colors) => {
@@ -24,21 +23,20 @@ const initialsToColor = (initials, colors) => {
24
23
  let colorIndex = asciiVal % colors.length;
25
24
 
26
25
  return colors[colorIndex];
27
- }
26
+ };
28
27
 
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.4);
40
- text-shadow: 1px 1px rgba(0, 0, 0, 0.1)
41
- `;
28
+ const DefaultAvatarStyles = ({ initials, size, className, ...props }) => (
29
+ <div
30
+ style={{
31
+ width: size || "2.5rem",
32
+ height: size || "2.5rem",
33
+ fontSize: `calc(${size} * 0.4)`,
34
+ backgroundColor: initialsToColor(initials, AVATAR_COLORS),
35
+ }}
36
+ className={cn("r-reset", "r-default-avatar", className)}
37
+ {...props}
38
+ />
39
+ );
42
40
 
43
41
  const DefaultAvatar = ({ initials, ...props }) => (
44
42
  <DefaultAvatarStyles initials={initials} {...props}>
@@ -47,8 +45,8 @@ const DefaultAvatar = ({ initials, ...props }) => (
47
45
  );
48
46
 
49
47
  DefaultAvatar.defaultProps = {
50
- size: '24px',
51
- initials: 'AA',
52
- }
48
+ size: "24px",
49
+ initials: "AA",
50
+ };
53
51
 
54
52
  export default DefaultAvatar;
@@ -0,0 +1,8 @@
1
+ import React from "react";
2
+ import cn from "./cn";
3
+
4
+ const Hint = ({ type, className, ...props }) => (
5
+ <div className={cn("r-reset", "r-form-group", className)} {...props} />
6
+ );
7
+
8
+ export default Hint;
package/src/Grid.jsx ADDED
@@ -0,0 +1,47 @@
1
+ import React from "react";
2
+ import cn from "./cn";
3
+
4
+ const getShift = (s) => {
5
+ const SHIFTS = {
6
+ 1: "2 / span 10",
7
+ 2: "3 / span 8",
8
+ 3: "4 / span 6",
9
+ };
10
+
11
+ return SHIFTS[s];
12
+ };
13
+
14
+ const Shift = ({ s, className, ...props }) => {
15
+ return (
16
+ <div
17
+ style={{
18
+ gridColumn: getShift(s) || "2 / span 10",
19
+ }}
20
+ className={cn("r-reset", className)}
21
+ {...props}
22
+ ></div>
23
+ );
24
+ };
25
+
26
+ const Col = ({ s, className, ...props }) => (
27
+ <div
28
+ style={{
29
+ gridColumn: `span ${s || "12"}`,
30
+ }}
31
+ className={cn("r-reset", className)}
32
+ {...props}
33
+ ></div>
34
+ );
35
+
36
+ const Row = ({ gutter, className, ...props }) => (
37
+ <div
38
+ style={{
39
+ columnGap: gutter || "1em",
40
+ rowGap: gutter || "1em",
41
+ }}
42
+ className={cn("r-reset", "r-row", className)}
43
+ {...props}
44
+ ></div>
45
+ );
46
+
47
+ export { Row, Col, Shift };
package/src/H.jsx CHANGED
@@ -3,7 +3,7 @@ import cn from "./cn";
3
3
 
4
4
  const H = ({ size = "base", className = "", ...props }) => (
5
5
  <div
6
- className={cn("r-reset r-heading", `r-fs-${size}`, className)}
6
+ className={cn("r-reset", "r-heading", `r-fs-${size}`, className)}
7
7
  {...props}
8
8
  />
9
9
  );
package/src/Handle.jsx ADDED
@@ -0,0 +1,8 @@
1
+ import React from "react";
2
+ import cn from "./cn";
3
+
4
+ const Handle = ({ className, ...props }) => (
5
+ <div className={cn("r-reset", "r-drag-handle", className)} {...props} />
6
+ );
7
+
8
+ export default Handle;
package/src/Hint.jsx ADDED
@@ -0,0 +1,16 @@
1
+ import React from "react";
2
+ import cn from "./cn";
3
+
4
+ const Hint = ({ type, className, ...props }) => (
5
+ <div
6
+ className={cn(
7
+ "r-reset",
8
+ "r-fs-small r-hint",
9
+ className,
10
+ type === "error" && "r-hint-error"
11
+ )}
12
+ {...props}
13
+ />
14
+ );
15
+
16
+ export default Hint;
@@ -0,0 +1,20 @@
1
+ import React from "react";
2
+ import cn from "./cn";
3
+
4
+ const ImageAvatar = ({ size, className, ...props }) => (
5
+ <img
6
+ alt=""
7
+ style={{
8
+ width: size || "2.5rem",
9
+ height: size || "2.5rem",
10
+ }}
11
+ className={cn("r-reset", "r-image-avatar", className)}
12
+ {...props}
13
+ />
14
+ );
15
+
16
+ ImageAvatar.defaultProps = {
17
+ size: "24px",
18
+ };
19
+
20
+ export default ImageAvatar;
@@ -2,7 +2,7 @@ import React from "react";
2
2
  import cn from "./cn";
3
3
 
4
4
  const Input = ({ className, ...props }) => (
5
- <input className={cn("r-reset r-input", className)} {...props} />
5
+ <input className={cn("r-reset", "r-input", className)} {...props} />
6
6
  );
7
7
 
8
8
  export default Input;
package/src/Label.jsx ADDED
@@ -0,0 +1,11 @@
1
+ import React from "react";
2
+ import cn from "./cn";
3
+
4
+ const Label = ({ className, ...props }) => (
5
+ <label
6
+ className={cn("r-reset", "r-fs-small r-label", className)}
7
+ {...props}
8
+ />
9
+ );
10
+
11
+ export default Label;
@@ -1,111 +1,28 @@
1
1
  import React from "react";
2
- import styled from "styled-components";
3
- import reset from "./reset";
2
+ import cn from "./cn";
4
3
 
5
- const LanguageSwitcherWrapper = styled.div`
6
- ${reset};
7
- position: relative;
8
- display: flex;
9
- flex-wrap: nowrap;
10
- width: 100%;
11
- height: 100%;
12
- color: #fff;
13
-
14
- &:hover {
15
- [data-switcher] {
16
- left: 48px;
17
- opacity: 1;
18
- }
19
- }
20
- `;
21
-
22
- const LanguageSwitcherMenu = styled.div`
23
- ${reset};
24
- position: absolute;
25
- z-index: 9;
26
- left: -1000px;
27
- display: flex;
28
- flex-wrap: nowrap;
29
- height: 100%;
30
- background-color: ${(props) => props.theme.colors.trueBlack};
31
- opacity: 0;
32
- transition: all ease-in-out 0.3s;
33
- `;
34
-
35
- const LanguageSwitcherItem = styled.div`
36
- ${reset};
37
- display: flex;
38
- justify-content: center;
39
- align-items: center;
40
- width: 48px;
41
- height: 48px;
42
- background-color: ${(props) => props.theme.colors.trueBlack};
43
- text-transform: uppercase;
44
-
45
- a {
46
- color: ${(props) => props.theme.colors.trueWhite};
47
- font-weight: 500;
48
- text-decoration: none;
49
-
50
- :hover {
51
- background-color: ${(props) => props.theme.colors.primaryRGB06};
52
- }
53
- }
54
- `;
55
-
56
- const LanguageSwitcherNewItem = styled.div`
57
- ${reset};
58
- position: relative;
59
- width: 48px;
60
- height: 48px;
61
- background-color: ${(props) => props.theme.colors.trueBlack};
62
- text-transform: uppercase;
63
-
64
- span {
65
- display: flex;
66
- justify-content: center;
67
- align-items: center;
68
- width: 100%;
69
- height: 100%;
70
- opacity: 0.6;
71
-
72
- color: ${(props) => props.theme.colors.trueWhite};
73
- font-weight: 500;
74
- text-decoration: none;
75
- }
4
+ const LanguageSwitcherWrapper = ({ className, ...props }) => (
5
+ <div className={cn("r-reset", "r-language-switcher", className)} {...props} />
6
+ );
76
7
 
77
- a {
78
- position: absolute;
79
- top: 0;
80
- bottom: 0;
81
- left: 0;
82
- right: 0;
83
- z-index: 3;
8
+ const LanguageSwitcherMenu = ({ className, ...props }) => (
9
+ <div className={cn("r-reset", "r-language-menu", className)} {...props} />
10
+ );
84
11
 
85
- color: ${(props) => props.theme.colors.trueWhite};
86
- font-weight: 700;
87
- text-decoration: none;
12
+ const LanguageSwitcherItem = ({ className, ...props }) => (
13
+ <div className={cn("r-reset", "r-language-item", className)} {...props} />
14
+ );
88
15
 
89
- :hover {
90
- background-color: ${(props) => props.theme.colors.primaryRGB06};
91
- }
92
- }
93
- `;
16
+ const LanguageSwitcherNewItem = ({ className, ...props }) => (
17
+ <div className={cn("r-reset", "r-language-new-item", className)} {...props} />
18
+ );
94
19
 
95
- const LanguageSwitcherCurrent = styled.div`
96
- ${reset};
97
- position: relative;
98
- z-index: 10;
99
- display: flex;
100
- justify-content: center;
101
- align-items: center;
102
- width: 100%;
103
- height: 100%;
104
- border-radius: 4px;
105
- background-color: ${(props) => props.theme.colors.primary};
106
- text-transform: uppercase;
107
- cursor: pointer;
108
- `;
20
+ const LanguageSwitcherCurrent = ({ className, ...props }) => (
21
+ <div
22
+ className={cn("r-reset", "r-language-current-item", className)}
23
+ {...props}
24
+ />
25
+ );
109
26
 
110
27
  const LanguageSwitcherItemComponent = ({ path, label }) => (
111
28
  <LanguageSwitcherItem>
package/src/Modal.jsx ADDED
@@ -0,0 +1,68 @@
1
+ import React from "react";
2
+ import cn from "./cn";
3
+
4
+ const Overlay = ({ className, ...props }) => (
5
+ <div className={cn("r-reset", "r-modal-overlay", className)} {...props} />
6
+ );
7
+
8
+ const Wrapper = ({ className, ...props }) => (
9
+ <div className={cn("r-reset", "r-modal", className)} {...props} />
10
+ );
11
+
12
+ const Inner = ({ className, ...props }) => (
13
+ <div className={cn("r-reset", "r-modal-inner", className)} {...props} />
14
+ );
15
+
16
+ const TitleBar = ({ className, ...props }) => (
17
+ <div className={cn("r-reset", "r-modal-title-bar", className)} {...props} />
18
+ );
19
+
20
+ const Title = ({ className, ...props }) => (
21
+ <div className={cn("r-reset", "r-modal-title", className)} {...props} />
22
+ );
23
+
24
+ const CloseButton = ({ className, ...props }) => (
25
+ <button
26
+ className={cn("r-reset-button r-modal-close-btn", className)}
27
+ {...props}
28
+ />
29
+ );
30
+
31
+ const Content = ({ className, ...props }) => (
32
+ <div className={cn("r-reset", "r-modal-content", className)} {...props} />
33
+ );
34
+
35
+ const Modal = ({ title, children, onClose }) => {
36
+ const handleKeyUp = ({ key }) => {
37
+ if (key === "Escape") onClose();
38
+ };
39
+
40
+ React.useEffect(() => {
41
+ document.addEventListener("keyup", handleKeyUp);
42
+
43
+ return () => {
44
+ document.removeEventListener("keyup", handleKeyUp);
45
+ };
46
+ });
47
+
48
+ return (
49
+ <React.Fragment>
50
+ <Overlay onClick={onClose} />
51
+
52
+ <Wrapper>
53
+ <Inner>
54
+ <TitleBar>
55
+ <Title>{title}</Title>
56
+ <CloseButton type="button" onClick={onClose}>
57
+ &times;
58
+ </CloseButton>
59
+ </TitleBar>
60
+
61
+ <Content>{children}</Content>
62
+ </Inner>
63
+ </Wrapper>
64
+ </React.Fragment>
65
+ );
66
+ };
67
+
68
+ export default Modal;
@@ -0,0 +1,20 @@
1
+ import React from "react";
2
+ import cn from "./cn";
3
+
4
+ const Navigation = ({ className, ...props }) => (
5
+ <div className={cn("r-reset", "r-navigation", className)} {...props} />
6
+ );
7
+
8
+ const NavItem = ({ active, className, ...props }) => (
9
+ <div
10
+ className={cn(
11
+ "r-reset",
12
+ "r-navigation-item",
13
+ active ? "r-navigation-item-active" : "",
14
+ className
15
+ )}
16
+ {...props}
17
+ />
18
+ );
19
+
20
+ export { Navigation, NavItem };
@@ -2,7 +2,7 @@ import React from "react";
2
2
  import cn from "./cn";
3
3
 
4
4
  const P = ({ className, ...props }) => (
5
- <div className={cn("r-reset r-paragraph", className)} {...props} />
5
+ <div className={cn("r-reset", "r-paragraph", className)} {...props} />
6
6
  );
7
7
 
8
8
  export default P;
package/src/PageTitle.jsx CHANGED
@@ -1,13 +1,10 @@
1
1
  import React from "react";
2
- import styled from "styled-components";
3
- import reset from "./reset";
4
2
  import H from "./H";
3
+ import cn from "./cn";
5
4
 
6
- const Wrapper = styled.div`
7
- ${reset};
8
-
9
- margin: 1em 0;
10
- `;
5
+ const Wrapper = ({ className, ...props }) => (
6
+ <div className={cn("r-reset", "r-page-title", className)} {...props} />
7
+ );
11
8
 
12
9
  const PageTitle = ({ children }) => (
13
10
  <Wrapper>
@@ -1,38 +1,9 @@
1
1
  import React from "react";
2
- import styled from "styled-components";
3
- import reset from "./reset";
2
+ import cn from "./cn";
4
3
 
5
- const Wrapper = styled.div`
6
- ${reset}
7
-
8
- display: flex;
9
- justify-content: center;
10
- flex-wrap: wrap;
11
- gap: 0.25em;
12
- padding: 1em 0 1em 0;
13
-
14
- a,
15
- span {
16
- display: block;
17
- min-width: 1.25em;
18
- padding: 0.5em 0.75em;
19
- font-weight: 500;
20
- text-align: center;
21
- }
22
-
23
- a {
24
- color: ${(props) => props.theme.colors.primary};
25
- border: 1px solid ${(props) => props.theme.colors.lightGray};
26
- border-radius: 4px;
27
- transition: all 0.2s ease-in-out;
28
-
29
- &:hover {
30
- border-color: ${(props) => props.theme.colors.primary};
31
- background-color: ${(props) => props.theme.colors.primary};
32
- color: ${(props) => props.theme.colors.white};
33
- }
34
- }
35
- `;
4
+ const Wrapper = ({ className, ...props }) => (
5
+ <div className={cn("r-reset", "r-pagination", className)} {...props} />
6
+ );
36
7
 
37
8
  const Prev = ({ LinkComponent, router, currentPage }) => {
38
9
  if (currentPage === 1) {
package/src/Panel.jsx CHANGED
@@ -1,31 +1,16 @@
1
- import styled from "styled-components";
2
- import reset from "./reset";
1
+ import React from "react";
2
+ import cn from "./cn";
3
3
 
4
- const Panel = styled.div`
5
- ${reset};
6
- margin-bottom: 0.5em;
7
- border: 1px solid #ddd;
8
- border-radius: 3px;
9
- background-color: #fff;
4
+ const Panel = ({ className, ...props }) => (
5
+ <div className={cn("r-reset", "r-panel", className)} {...props} />
6
+ );
10
7
 
11
- &.sortable-selected {
12
- background-color: #0a0a;
13
- }
14
- `;
8
+ const PanelTitle = ({ className, ...props }) => (
9
+ <div className={cn("r-reset", "r-panel-title", className)} {...props} />
10
+ );
15
11
 
16
- const PanelTitle = styled.div`
17
- ${reset};
18
- display: flex;
19
- justify-content: space-between;
20
- align-items: center;
21
- padding: 0.25em 0.25em 0.25em;
22
- border-bottom: 1px solid #ddd;
23
- background-color: ${(props) => props.theme.colors.lighterGray};
24
- font-weight: 700;
25
- `;
26
-
27
- const PanelContent = styled.div`
28
- padding: 1em;
29
- `;
12
+ const PanelContent = ({ className, ...props }) => (
13
+ <div className={cn("r-panel-content", className)} {...props} />
14
+ );
30
15
 
31
16
  export { Panel, PanelTitle, PanelContent };
package/src/Select.jsx ADDED
@@ -0,0 +1,8 @@
1
+ import React from "react";
2
+ import cn from "./cn";
3
+
4
+ const Select = ({ className, ...props }) => (
5
+ <select className={cn("r-reset", "r-input r-select", className)} {...props} />
6
+ );
7
+
8
+ export default Select;