@raketa-builder/ui 0.1.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/.turbo/turbo-build.log +8 -0
- package/.turbo/turbo-lint.log +13 -0
- package/CHANGELOG.md +7 -0
- package/dist/index.js +1061 -0
- package/package.json +27 -0
- package/src/Button.js +102 -0
- package/src/Container.js +16 -0
- package/src/DataGrid.js +73 -0
- package/src/Field.js +37 -0
- package/src/FormGroup.js +8 -0
- package/src/Grid.js +38 -0
- package/src/H.js +10 -0
- package/src/Handle.js +12 -0
- package/src/Hint.js +12 -0
- package/src/Input.js +23 -0
- package/src/Label.js +12 -0
- package/src/LanguageSwitcher.js +146 -0
- package/src/Modal.js +112 -0
- package/src/Navigation.js +44 -0
- package/src/P.js +9 -0
- package/src/PageTitle.js +24 -0
- package/src/Pagination.js +117 -0
- package/src/Panel.js +31 -0
- package/src/Select.js +29 -0
- package/src/Stack.js +8 -0
- package/src/Tabs.js +57 -0
- package/src/Textarea.js +24 -0
- package/src/Toolbar.js +11 -0
- package/src/buttonReset.js +12 -0
- package/src/index.js +28 -0
- package/src/reset.js +13 -0
- package/src/theme.js +50 -0
- package/tsconfig.json +5 -0
package/package.json
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@raketa-builder/ui",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"main": "./dist/index.js",
|
|
5
|
+
"types": "./dist/index.d.ts",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"lint": "TIMING=1 eslint \"**/*.js\"",
|
|
9
|
+
"build": "tsup src/index.js --format cjs --loader \".js=jsx\"",
|
|
10
|
+
"dev": "tsup src/index.js --format cjs --loader \".js=jsx\" --watch"
|
|
11
|
+
},
|
|
12
|
+
"peerDependencies": {
|
|
13
|
+
"styled-components": "^5.1.0",
|
|
14
|
+
"react": "18.2.0",
|
|
15
|
+
"react-dom": "18.2.0"
|
|
16
|
+
},
|
|
17
|
+
"devDependencies": {
|
|
18
|
+
"@types/react": "17.0.37",
|
|
19
|
+
"@types/react-dom": "17.0.11",
|
|
20
|
+
"eslint": "7.32.0",
|
|
21
|
+
"eslint-config-custom": "*",
|
|
22
|
+
"react": "18.2.0",
|
|
23
|
+
"tsconfig": "*",
|
|
24
|
+
"tsup": "^6.5.0",
|
|
25
|
+
"typescript": "4.5.2"
|
|
26
|
+
}
|
|
27
|
+
}
|
package/src/Button.js
ADDED
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import styled from "styled-components";
|
|
2
|
+
import buttonReset from "./buttonReset";
|
|
3
|
+
import theme from "./theme";
|
|
4
|
+
|
|
5
|
+
const variants = {
|
|
6
|
+
primary: {
|
|
7
|
+
border: "primary",
|
|
8
|
+
background: "primary",
|
|
9
|
+
color: "white",
|
|
10
|
+
hoverBorder: "primaryDark",
|
|
11
|
+
hoverBackground: "primaryDark",
|
|
12
|
+
hoverColor: "white",
|
|
13
|
+
activeBorder: "primaryDarker",
|
|
14
|
+
activeBackground: "primaryDarker",
|
|
15
|
+
activeColor: "white",
|
|
16
|
+
},
|
|
17
|
+
secondary: {
|
|
18
|
+
border: "darkerGray",
|
|
19
|
+
background: "white",
|
|
20
|
+
color: "darkerGray",
|
|
21
|
+
hoverBorder: "darkGray",
|
|
22
|
+
hoverBackground: "darkGray",
|
|
23
|
+
hoverColor: "white",
|
|
24
|
+
activeBorder: "darkerGray",
|
|
25
|
+
activeBackground: "darkerGray",
|
|
26
|
+
activeColor: "white",
|
|
27
|
+
},
|
|
28
|
+
success: {
|
|
29
|
+
border: "success",
|
|
30
|
+
background: "success",
|
|
31
|
+
color: "white",
|
|
32
|
+
hoverBorder: "successDark",
|
|
33
|
+
hoverBackground: "successDark",
|
|
34
|
+
hoverColor: "white",
|
|
35
|
+
activeBorder: "successDarker",
|
|
36
|
+
activeBackground: "successDarker",
|
|
37
|
+
activeColor: "white",
|
|
38
|
+
},
|
|
39
|
+
danger: {
|
|
40
|
+
border: "danger",
|
|
41
|
+
background: "danger",
|
|
42
|
+
color: "white",
|
|
43
|
+
hoverBorder: "dangerDark",
|
|
44
|
+
hoverBackground: "dangerDark",
|
|
45
|
+
hoverColor: "white",
|
|
46
|
+
activeBorder: "dangerDarker",
|
|
47
|
+
activeBackground: "dangerDarker",
|
|
48
|
+
activeColor: "white",
|
|
49
|
+
},
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
const sizes = {
|
|
53
|
+
sm: theme.font.small,
|
|
54
|
+
md: theme.font.base,
|
|
55
|
+
lg: theme.font.medium,
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const getColor = (props, variant, key) =>
|
|
59
|
+
props.theme.colors[variants[variant][key]];
|
|
60
|
+
|
|
61
|
+
const Button = styled.button`
|
|
62
|
+
${buttonReset};
|
|
63
|
+
padding: 0.5em 1em;
|
|
64
|
+
margin-right: 0.25em;
|
|
65
|
+
border: 2px solid ${(props) => getColor(props, props.variant, "border")};
|
|
66
|
+
border-radius: 48px;
|
|
67
|
+
background-color: ${(props) => getColor(props, props.variant, "background")};
|
|
68
|
+
color: ${(props) => getColor(props, props.variant, "color")};
|
|
69
|
+
font-size: ${(props) => sizes[props.size || "md"]};
|
|
70
|
+
font-weight: 700;
|
|
71
|
+
line-height: 1;
|
|
72
|
+
transition: 0.2s ease-in-out all;
|
|
73
|
+
|
|
74
|
+
&:focus {
|
|
75
|
+
border-color: ${(props) => getColor(props, props.variant, "activeBorder")};
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
&:hover {
|
|
79
|
+
border-color: ${(props) => getColor(props, props.variant, "hoverBorder")};
|
|
80
|
+
background-color: ${(props) =>
|
|
81
|
+
getColor(props, props.variant, "hoverBackground")};
|
|
82
|
+
color: ${(props) => getColor(props, props.variant, "hoverColor")};
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
&:active {
|
|
86
|
+
border-color: ${(props) => getColor(props, props.variant, "activeBorder")};
|
|
87
|
+
background-color: ${(props) =>
|
|
88
|
+
getColor(props, props.variant, "activeBackground")};
|
|
89
|
+
color: ${(props) => getColor(props, props.variant, "activeColor")};
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
&:last-of-type {
|
|
93
|
+
margin-right: 0;
|
|
94
|
+
}
|
|
95
|
+
`;
|
|
96
|
+
|
|
97
|
+
Button.defaultProps = {
|
|
98
|
+
type: "button",
|
|
99
|
+
variant: "primary",
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
export default Button;
|
package/src/Container.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import styled from "styled-components";
|
|
2
|
+
import reset from "./reset";
|
|
3
|
+
|
|
4
|
+
export default styled.div`
|
|
5
|
+
${reset};
|
|
6
|
+
width: 100%;
|
|
7
|
+
padding: 0 calc(1em / 2);
|
|
8
|
+
|
|
9
|
+
padding-top: ${(props) => props.top && "1em"};
|
|
10
|
+
padding-bottom: ${(props) => props.bottom && "1em"};
|
|
11
|
+
|
|
12
|
+
@media (min-width: 1184px) {
|
|
13
|
+
width: 98%;
|
|
14
|
+
margin: 0 auto;
|
|
15
|
+
}
|
|
16
|
+
`;
|
package/src/DataGrid.js
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import styled from "styled-components";
|
|
3
|
+
import reset from "./reset";
|
|
4
|
+
|
|
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
|
+
`;
|
|
56
|
+
|
|
57
|
+
const DataGrid = ({ list, header, row }) => (
|
|
58
|
+
<Wrapper>
|
|
59
|
+
<table>
|
|
60
|
+
<thead>
|
|
61
|
+
<tr>{header()}</tr>
|
|
62
|
+
</thead>
|
|
63
|
+
|
|
64
|
+
<tbody>
|
|
65
|
+
{list.map((item, idx) => (
|
|
66
|
+
<tr key={item.id || idx}>{row(item)}</tr>
|
|
67
|
+
))}
|
|
68
|
+
</tbody>
|
|
69
|
+
</table>
|
|
70
|
+
</Wrapper>
|
|
71
|
+
);
|
|
72
|
+
|
|
73
|
+
export default DataGrid;
|
package/src/Field.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import FormGroup from "./FormGroup";
|
|
3
|
+
import Label from "./Label";
|
|
4
|
+
import Input from "./Input";
|
|
5
|
+
import Textarea from "./Textarea";
|
|
6
|
+
import Select from "./Select";
|
|
7
|
+
import Hint from "./Hint";
|
|
8
|
+
|
|
9
|
+
const Field = ({
|
|
10
|
+
as = "input",
|
|
11
|
+
r,
|
|
12
|
+
name,
|
|
13
|
+
label,
|
|
14
|
+
hint = "",
|
|
15
|
+
error = "",
|
|
16
|
+
wrapperProps,
|
|
17
|
+
...props
|
|
18
|
+
}) => {
|
|
19
|
+
const types = {
|
|
20
|
+
input: Input,
|
|
21
|
+
select: Select,
|
|
22
|
+
textarea: Textarea,
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
const Component = types[as];
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<FormGroup {...wrapperProps}>
|
|
29
|
+
{label && <Label htmlFor={name}>{label}</Label>}
|
|
30
|
+
<Component ref={r} id={name} name={name} {...props} />
|
|
31
|
+
{hint && <Hint>{hint}</Hint>}
|
|
32
|
+
{error && <Hint type="error">{error}</Hint>}
|
|
33
|
+
</FormGroup>
|
|
34
|
+
);
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
export default Field;
|
package/src/FormGroup.js
ADDED
package/src/Grid.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import styled from "styled-components";
|
|
2
|
+
import reset from "./reset";
|
|
3
|
+
|
|
4
|
+
const Row = styled.div`
|
|
5
|
+
${reset};
|
|
6
|
+
|
|
7
|
+
@media (min-width: 1184px) {
|
|
8
|
+
display: grid;
|
|
9
|
+
grid-template-columns: repeat(12, 1fr);
|
|
10
|
+
grid-column-gap: ${(props) => props.gutter || "1em"};
|
|
11
|
+
grid-row-gap: ${(props) => props.gutter || "1em"};
|
|
12
|
+
margin: 0;
|
|
13
|
+
}
|
|
14
|
+
`;
|
|
15
|
+
|
|
16
|
+
const Col = styled.div`
|
|
17
|
+
${reset};
|
|
18
|
+
|
|
19
|
+
grid-column: span ${(props) => props.s || 12};
|
|
20
|
+
`;
|
|
21
|
+
|
|
22
|
+
const getShift = (s) => {
|
|
23
|
+
const SHIFTS = {
|
|
24
|
+
1: "2 / span 10",
|
|
25
|
+
2: "3 / span 8",
|
|
26
|
+
3: "4 / span 6",
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
return SHIFTS[s];
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
const Shift = styled.div`
|
|
33
|
+
${reset};
|
|
34
|
+
|
|
35
|
+
grid-column: ${(props) => getShift(props.s)};
|
|
36
|
+
`;
|
|
37
|
+
|
|
38
|
+
export { Shift, Row, Col };
|
package/src/H.js
ADDED
package/src/Handle.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import styled from "styled-components";
|
|
2
|
+
|
|
3
|
+
export default styled.div`
|
|
4
|
+
width: 2em;
|
|
5
|
+
height: 2em;
|
|
6
|
+
background-size: 50%;
|
|
7
|
+
background-repeat: no-repeat;
|
|
8
|
+
background-position: center;
|
|
9
|
+
background-image: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiBzdHJva2U9IiMwMDAiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIiBjbGFzcz0iZmVhdGhlciBmZWF0aGVyLW1vcmUtdmVydGljYWwiPjxjaXJjbGUgY3g9IjEyIiBjeT0iMTIiIHI9IjEiPjwvY2lyY2xlPjxjaXJjbGUgY3g9IjEyIiBjeT0iNSIgcj0iMSI+PC9jaXJjbGU+PGNpcmNsZSBjeD0iMTIiIGN5PSIxOSIgcj0iMSI+PC9jaXJjbGU+PC9zdmc+);
|
|
10
|
+
cursor: grabbing;
|
|
11
|
+
filter: invert(${(props) => (props.active ? 1 : 0)});
|
|
12
|
+
`;
|
package/src/Hint.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import styled from "styled-components";
|
|
2
|
+
import reset from "./reset";
|
|
3
|
+
|
|
4
|
+
const Hint = styled.div`
|
|
5
|
+
${reset};
|
|
6
|
+
|
|
7
|
+
font-size: ${(props) => props.theme.font.small};
|
|
8
|
+
opacity: 0.7;
|
|
9
|
+
color: ${(props) => props.type === "error" && props.theme.colors.danger};
|
|
10
|
+
`;
|
|
11
|
+
|
|
12
|
+
export default Hint;
|
package/src/Input.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import styled from "styled-components";
|
|
2
|
+
import reset from "./reset";
|
|
3
|
+
|
|
4
|
+
export default styled.input`
|
|
5
|
+
${reset};
|
|
6
|
+
border: 0;
|
|
7
|
+
outline: 0;
|
|
8
|
+
border-radius: 4px;
|
|
9
|
+
border: 0;
|
|
10
|
+
width: 100%;
|
|
11
|
+
padding: 0.5em 0.75em;
|
|
12
|
+
border: 1px solid ${(props) => props.theme.colors.gray};
|
|
13
|
+
background-color: ${(props) => props.theme.colors.trueWhite};
|
|
14
|
+
transition: all 0.2s ease-in-out;
|
|
15
|
+
|
|
16
|
+
&:hover {
|
|
17
|
+
border-color: ${(props) => props.theme.colors.darkGray};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
&:focus {
|
|
21
|
+
border-color: ${(props) => props.theme.colors.primary};
|
|
22
|
+
}
|
|
23
|
+
`;
|
package/src/Label.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import styled from "styled-components";
|
|
2
|
+
import reset from "./reset";
|
|
3
|
+
|
|
4
|
+
export default styled.label`
|
|
5
|
+
${reset};
|
|
6
|
+
display: block;
|
|
7
|
+
margin-bottom: 0.25em;
|
|
8
|
+
color: ${(props) => props.theme.colors.darkerGray};
|
|
9
|
+
font-size: ${(props) => props.theme.font.small};
|
|
10
|
+
font-weight: 600;
|
|
11
|
+
cursor: pointer;
|
|
12
|
+
`;
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import styled from "styled-components";
|
|
3
|
+
import reset from "./reset";
|
|
4
|
+
|
|
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
|
+
}
|
|
76
|
+
|
|
77
|
+
a {
|
|
78
|
+
position: absolute;
|
|
79
|
+
top: 0;
|
|
80
|
+
bottom: 0;
|
|
81
|
+
left: 0;
|
|
82
|
+
right: 0;
|
|
83
|
+
z-index: 3;
|
|
84
|
+
|
|
85
|
+
color: ${(props) => props.theme.colors.trueWhite};
|
|
86
|
+
font-weight: 700;
|
|
87
|
+
text-decoration: none;
|
|
88
|
+
|
|
89
|
+
:hover {
|
|
90
|
+
background-color: ${(props) => props.theme.colors.primaryRGB06};
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
`;
|
|
94
|
+
|
|
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
|
+
`;
|
|
109
|
+
|
|
110
|
+
const LanguageSwitcherItemComponent = ({ path, label }) => (
|
|
111
|
+
<LanguageSwitcherItem>
|
|
112
|
+
<a href={path}>{label}</a>
|
|
113
|
+
</LanguageSwitcherItem>
|
|
114
|
+
);
|
|
115
|
+
|
|
116
|
+
const LanguageSwitcherNewItemComponent = ({ path, label }) => (
|
|
117
|
+
<LanguageSwitcherNewItem>
|
|
118
|
+
<span>{label}</span>
|
|
119
|
+
<a href={path}>+</a>
|
|
120
|
+
</LanguageSwitcherNewItem>
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
const LanguageSwitcher = ({ current, navigation }) => {
|
|
124
|
+
return (
|
|
125
|
+
<LanguageSwitcherWrapper>
|
|
126
|
+
<LanguageSwitcherCurrent>{current}</LanguageSwitcherCurrent>
|
|
127
|
+
<LanguageSwitcherMenu data-switcher>
|
|
128
|
+
{navigation.map((navItem, idx) => {
|
|
129
|
+
const LinkComponent = navItem.newItem
|
|
130
|
+
? LanguageSwitcherNewItemComponent
|
|
131
|
+
: LanguageSwitcherItemComponent;
|
|
132
|
+
|
|
133
|
+
return (
|
|
134
|
+
<LinkComponent
|
|
135
|
+
key={idx}
|
|
136
|
+
path={navItem.path}
|
|
137
|
+
label={navItem.label}
|
|
138
|
+
/>
|
|
139
|
+
);
|
|
140
|
+
})}
|
|
141
|
+
</LanguageSwitcherMenu>
|
|
142
|
+
</LanguageSwitcherWrapper>
|
|
143
|
+
);
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
export default LanguageSwitcher;
|
package/src/Modal.js
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import styled from "styled-components";
|
|
3
|
+
import reset from "./reset";
|
|
4
|
+
import buttonReset from "./buttonReset";
|
|
5
|
+
|
|
6
|
+
const Overlay = styled.div`
|
|
7
|
+
${reset};
|
|
8
|
+
position: fixed;
|
|
9
|
+
top: 0;
|
|
10
|
+
right: 0;
|
|
11
|
+
bottom: 0;
|
|
12
|
+
left: 0;
|
|
13
|
+
z-index: 11;
|
|
14
|
+
background-color: rgba(0, 0, 0, 0.6);
|
|
15
|
+
cursor: pointer;
|
|
16
|
+
`;
|
|
17
|
+
|
|
18
|
+
const Wrapper = styled.div`
|
|
19
|
+
${reset};
|
|
20
|
+
position: fixed;
|
|
21
|
+
top: 0;
|
|
22
|
+
right: 0;
|
|
23
|
+
bottom: 0;
|
|
24
|
+
left: 0;
|
|
25
|
+
z-index: 12;
|
|
26
|
+
display: flex;
|
|
27
|
+
justify-content: center;
|
|
28
|
+
align-items: center;
|
|
29
|
+
pointer-events: none;
|
|
30
|
+
`;
|
|
31
|
+
|
|
32
|
+
const Inner = styled.div`
|
|
33
|
+
${reset};
|
|
34
|
+
width: 80%;
|
|
35
|
+
border-radius: 5px;
|
|
36
|
+
background-color: ${(props) => props.theme.colors.lighterGray};
|
|
37
|
+
box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
|
|
38
|
+
pointer-events: all;
|
|
39
|
+
`;
|
|
40
|
+
|
|
41
|
+
const TitleBar = styled.div`
|
|
42
|
+
${reset};
|
|
43
|
+
display: flex;
|
|
44
|
+
justify-content: space-between;
|
|
45
|
+
align-items: center;
|
|
46
|
+
padding: 1em;
|
|
47
|
+
border-bottom: 2px solid ${(props) => props.theme.colors.lightGray};
|
|
48
|
+
`;
|
|
49
|
+
|
|
50
|
+
const Title = styled.div`
|
|
51
|
+
${reset};
|
|
52
|
+
font-size: 1.25em;
|
|
53
|
+
font-weight: 500;
|
|
54
|
+
`;
|
|
55
|
+
|
|
56
|
+
const CloseButton = styled.button`
|
|
57
|
+
${buttonReset};
|
|
58
|
+
position: relative;
|
|
59
|
+
right: -4px;
|
|
60
|
+
z-index: 13;
|
|
61
|
+
width: 2em;
|
|
62
|
+
height: 2em;
|
|
63
|
+
margin: 0;
|
|
64
|
+
padding: 0;
|
|
65
|
+
background-repeat: no-repeat;
|
|
66
|
+
background-size: 80%;
|
|
67
|
+
background-position: center;
|
|
68
|
+
background-image: url(data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiBzdHJva2U9IiMwMDAiIHN0cm9rZS13aWR0aD0iMiIgc3Ryb2tlLWxpbmVjYXA9InJvdW5kIiBzdHJva2UtbGluZWpvaW49InJvdW5kIiBjbGFzcz0iZmVhdGhlciBmZWF0aGVyLXgiPjxsaW5lIHgxPSIxOCIgeTE9IjYiIHgyPSI2IiB5Mj0iMTgiPjwvbGluZT48bGluZSB4MT0iNiIgeTE9IjYiIHgyPSIxOCIgeTI9IjE4Ij48L2xpbmU+PC9zdmc+);
|
|
69
|
+
font-size: 1em;
|
|
70
|
+
overflow: hidden;
|
|
71
|
+
text-indent: -9999px;
|
|
72
|
+
`;
|
|
73
|
+
|
|
74
|
+
const Content = styled.div`
|
|
75
|
+
${reset};
|
|
76
|
+
padding: 0.5em 1em 1em 1em;
|
|
77
|
+
`;
|
|
78
|
+
|
|
79
|
+
const Modal = ({ title, children, onClose }) => {
|
|
80
|
+
const handleKeyUp = ({ key }) => {
|
|
81
|
+
if (key === "Escape") onClose();
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
React.useEffect(() => {
|
|
85
|
+
document.addEventListener("keyup", handleKeyUp);
|
|
86
|
+
|
|
87
|
+
return () => {
|
|
88
|
+
document.removeEventListener("keyup", handleKeyUp);
|
|
89
|
+
};
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
return (
|
|
93
|
+
<React.Fragment>
|
|
94
|
+
<Overlay onClick={onClose} />
|
|
95
|
+
|
|
96
|
+
<Wrapper>
|
|
97
|
+
<Inner>
|
|
98
|
+
<TitleBar>
|
|
99
|
+
<Title>{title}</Title>
|
|
100
|
+
<CloseButton type="button" onClick={onClose}>
|
|
101
|
+
×
|
|
102
|
+
</CloseButton>
|
|
103
|
+
</TitleBar>
|
|
104
|
+
|
|
105
|
+
<Content>{children}</Content>
|
|
106
|
+
</Inner>
|
|
107
|
+
</Wrapper>
|
|
108
|
+
</React.Fragment>
|
|
109
|
+
);
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
export default Modal;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import styled from "styled-components";
|
|
2
|
+
import reset from "./reset";
|
|
3
|
+
|
|
4
|
+
const Navigation = styled.div`
|
|
5
|
+
${reset};
|
|
6
|
+
|
|
7
|
+
position: fixed;
|
|
8
|
+
top: 0;
|
|
9
|
+
bottom: 0;
|
|
10
|
+
left: 0;
|
|
11
|
+
display: flex;
|
|
12
|
+
gap: 8px;
|
|
13
|
+
flex-direction: column;
|
|
14
|
+
align-items: center;
|
|
15
|
+
width: 64px;
|
|
16
|
+
padding: 8px 0;
|
|
17
|
+
background-color: ${(props) => props.theme.colors.black};
|
|
18
|
+
`;
|
|
19
|
+
|
|
20
|
+
const NavItem = styled.div`
|
|
21
|
+
${reset};
|
|
22
|
+
|
|
23
|
+
width: 48px;
|
|
24
|
+
height: 48px;
|
|
25
|
+
border-radius: 4px;
|
|
26
|
+
background-color: ${(props) =>
|
|
27
|
+
props.active ? props.theme.colors.darkerGray : "transparent"};
|
|
28
|
+
transition: all 0.2s ease-in-out;
|
|
29
|
+
|
|
30
|
+
&:hover {
|
|
31
|
+
background-color: ${(props) => props.theme.colors.darkerGray};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
a,
|
|
35
|
+
button {
|
|
36
|
+
display: flex;
|
|
37
|
+
justify-content: center;
|
|
38
|
+
align-items: center;
|
|
39
|
+
width: 100%;
|
|
40
|
+
height: 100%;
|
|
41
|
+
}
|
|
42
|
+
`;
|
|
43
|
+
|
|
44
|
+
export { Navigation, NavItem };
|