ag-common 0.0.620 → 0.0.621
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.
|
@@ -2,5 +2,10 @@ import React from 'react';
|
|
|
2
2
|
export interface ISidebar {
|
|
3
3
|
children: React.ReactNode;
|
|
4
4
|
className?: string;
|
|
5
|
+
/** default:defaultClosed
|
|
6
|
+
* defaultClosed: always closed by default.
|
|
7
|
+
* fixedOpen: always open on bigscreen. cant close if bigscreen
|
|
8
|
+
*/
|
|
9
|
+
mode?: 'defaultClosed' | 'fixedOpen';
|
|
5
10
|
}
|
|
6
|
-
export declare const Sidebar: ({ children, className }: ISidebar) => React.JSX.Element;
|
|
11
|
+
export declare const Sidebar: ({ children, className, mode, }: ISidebar) => React.JSX.Element;
|
|
@@ -28,13 +28,26 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
28
28
|
};
|
|
29
29
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
30
30
|
exports.Sidebar = void 0;
|
|
31
|
+
const react_1 = require("@emotion/react");
|
|
31
32
|
const styled_1 = __importDefault(require("@emotion/styled"));
|
|
32
|
-
const
|
|
33
|
+
const react_2 = __importStar(require("react"));
|
|
33
34
|
const helpers_1 = require("../../helpers");
|
|
34
35
|
const Hamburger_1 = require("../../icons/Hamburger");
|
|
35
36
|
const common_1 = require("../../styles/common");
|
|
36
37
|
const media_1 = require("../../styles/media");
|
|
37
38
|
const Chevron_1 = require("../Chevron");
|
|
39
|
+
const closedSidebarHover = (0, react_1.css) `
|
|
40
|
+
width: 0.5rem;
|
|
41
|
+
background-color: rgba(0, 0, 0, 0.1);
|
|
42
|
+
cursor: pointer;
|
|
43
|
+
&:hover,
|
|
44
|
+
&:hover [data-hover='true'] {
|
|
45
|
+
background-color: #ccc;
|
|
46
|
+
}
|
|
47
|
+
&:hover {
|
|
48
|
+
border-right: solid 1px #999;
|
|
49
|
+
}
|
|
50
|
+
`;
|
|
38
51
|
const Base = styled_1.default.div `
|
|
39
52
|
position: relative;
|
|
40
53
|
transition: all 200ms;
|
|
@@ -42,46 +55,56 @@ const Base = styled_1.default.div `
|
|
|
42
55
|
padding-left: 0.5rem;
|
|
43
56
|
height: 100vh;
|
|
44
57
|
|
|
58
|
+
${common_1.NoTextSelect};
|
|
59
|
+
&:hover {
|
|
60
|
+
[data-type='content-block'] {
|
|
61
|
+
left: 1rem;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
45
65
|
&[data-open='true'] {
|
|
46
|
-
width:
|
|
47
|
-
|
|
66
|
+
width: fit-content;
|
|
67
|
+
|
|
48
68
|
@media ${media_1.smallScreen} {
|
|
49
69
|
max-width: unset;
|
|
50
70
|
position: fixed;
|
|
51
71
|
top: 0;
|
|
52
72
|
left: 0;
|
|
73
|
+
z-index: 1;
|
|
53
74
|
}
|
|
54
75
|
}
|
|
55
76
|
&[data-open='false'] {
|
|
56
|
-
|
|
57
|
-
background-color: rgba(0, 0, 0, 0.1);
|
|
58
|
-
cursor: pointer;
|
|
59
|
-
&:hover,
|
|
60
|
-
&:hover [data-hover='true'] {
|
|
61
|
-
background-color: #ccc;
|
|
62
|
-
}
|
|
63
|
-
&:hover {
|
|
64
|
-
border-right: solid 1px #999;
|
|
65
|
-
}
|
|
77
|
+
${closedSidebarHover};
|
|
66
78
|
}
|
|
67
|
-
${common_1.NoTextSelect};
|
|
68
79
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
80
|
+
:not([data-open]) {
|
|
81
|
+
@media ${media_1.smallScreen} {
|
|
82
|
+
${closedSidebarHover};
|
|
83
|
+
}
|
|
84
|
+
@media ${media_1.bigScreen} {
|
|
85
|
+
width: fit-content;
|
|
72
86
|
}
|
|
73
87
|
}
|
|
74
88
|
`;
|
|
75
|
-
const
|
|
76
|
-
left: -
|
|
89
|
+
const closedContentBlockOffScreen = (0, react_1.css) `
|
|
90
|
+
left: -100vw;
|
|
77
91
|
transition: left 200ms;
|
|
78
92
|
height: 100%;
|
|
93
|
+
`;
|
|
94
|
+
const ContentBlock = styled_1.default.div `
|
|
95
|
+
${closedContentBlockOffScreen};
|
|
79
96
|
&[data-open='false'] {
|
|
80
97
|
position: absolute;
|
|
81
98
|
top: 0;
|
|
82
99
|
z-index: 1;
|
|
83
|
-
width:
|
|
84
|
-
|
|
100
|
+
width: fit-content;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
:not([data-open]) {
|
|
104
|
+
@media ${media_1.smallScreen} {
|
|
105
|
+
position: absolute;
|
|
106
|
+
${closedContentBlockOffScreen};
|
|
107
|
+
}
|
|
85
108
|
}
|
|
86
109
|
`;
|
|
87
110
|
const Content = styled_1.default.div `
|
|
@@ -100,10 +123,24 @@ const HamburgerB = styled_1.default.div `
|
|
|
100
123
|
position: absolute;
|
|
101
124
|
transition: all 200ms;
|
|
102
125
|
z-index: 2;
|
|
126
|
+
|
|
127
|
+
&[data-hide-on-big='true'] {
|
|
128
|
+
@media ${media_1.bigScreen} {
|
|
129
|
+
display: none;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
103
133
|
&[data-open='false'] {
|
|
104
134
|
top: 0.5rem;
|
|
105
135
|
left: 0.25rem;
|
|
106
136
|
}
|
|
137
|
+
|
|
138
|
+
:not([data-open]) {
|
|
139
|
+
@media ${media_1.bigScreen} {
|
|
140
|
+
top: 0.5rem;
|
|
141
|
+
right: -0.75rem;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
107
144
|
&[data-open='true'] {
|
|
108
145
|
top: 0.5rem;
|
|
109
146
|
right: -0.75rem;
|
|
@@ -127,19 +164,22 @@ const ChevronStyled = (0, styled_1.default)(Chevron_1.Chevron) `
|
|
|
127
164
|
fill: #555;
|
|
128
165
|
}
|
|
129
166
|
`;
|
|
130
|
-
const Sidebar = ({ children, className }) => {
|
|
131
|
-
const ref = (0,
|
|
132
|
-
const [open, setOpen] = (0,
|
|
167
|
+
const Sidebar = ({ children, className, mode = 'defaultClosed', }) => {
|
|
168
|
+
const ref = (0, react_2.useRef)(null);
|
|
169
|
+
const [open, setOpen] = (0, react_2.useState)(mode === 'defaultClosed' ? false : null);
|
|
133
170
|
(0, helpers_1.useOnClickOutside)({ ref }, () => {
|
|
134
171
|
if (!open || window.innerWidth > media_1.smallScreenPx) {
|
|
135
172
|
return;
|
|
136
173
|
}
|
|
137
174
|
setOpen(false);
|
|
138
175
|
});
|
|
139
|
-
return (
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
176
|
+
return (react_2.default.createElement(Base, { "data-type": "sidebar", className: className, "data-open": open, onClick: () => !open && setOpen(true), "data-hover": true, ref: ref },
|
|
177
|
+
react_2.default.createElement(HamburgerB, { "data-hide-on-big": mode === 'fixedOpen', "data-open": open, onClick: (e) => {
|
|
178
|
+
e.stopPropagation();
|
|
179
|
+
setOpen(!open);
|
|
180
|
+
}, "data-hover": true }, open ? react_2.default.createElement(ChevronStyled, { point: "left", width: "100%" }) : react_2.default.createElement(Hamburger_1.Hamburger, null)),
|
|
181
|
+
react_2.default.createElement(ContentBlock, { "data-type": "content-block", "data-open": open },
|
|
182
|
+
react_2.default.createElement(Content, { "data-type": "content", "data-open": open, onClick: (e) => {
|
|
143
183
|
e.stopPropagation();
|
|
144
184
|
} }, children))));
|
|
145
185
|
};
|
package/package.json
CHANGED