ag-common 0.0.126 → 0.0.127
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.
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare const Sidebar: ({ children, className, key, cookieDocument, }: {
|
|
2
|
+
children: any;
|
|
3
|
+
className?: string | undefined;
|
|
4
|
+
/**
|
|
5
|
+
* used for localstorage. default 'sidebar'
|
|
6
|
+
*/
|
|
7
|
+
key?: string | undefined;
|
|
8
|
+
/**
|
|
9
|
+
* pass in SSR cookiedocument
|
|
10
|
+
*/
|
|
11
|
+
cookieDocument?: string | undefined;
|
|
12
|
+
}) => JSX.Element;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Sidebar = void 0;
|
|
7
|
+
const react_1 = __importDefault(require("react"));
|
|
8
|
+
const styled_components_1 = __importDefault(require("styled-components"));
|
|
9
|
+
const cookie_1 = require("../../helpers/cookie");
|
|
10
|
+
const common_1 = require("../../styles/common");
|
|
11
|
+
const Chevron_1 = require("../Chevron");
|
|
12
|
+
const Base = styled_components_1.default.div `
|
|
13
|
+
position: relative;
|
|
14
|
+
transition: all 200ms;
|
|
15
|
+
width: 15rem;
|
|
16
|
+
border-right: solid 1px #ccc;
|
|
17
|
+
margin-right: 1rem;
|
|
18
|
+
padding-left: 0.5rem;
|
|
19
|
+
|
|
20
|
+
&[data-open='false'] {
|
|
21
|
+
width: 0.5rem;
|
|
22
|
+
background-color: rgba(0, 0, 0, 0.1);
|
|
23
|
+
cursor: pointer;
|
|
24
|
+
&:hover,
|
|
25
|
+
&:hover [data-hover='true'] {
|
|
26
|
+
background-color: #ccc;
|
|
27
|
+
}
|
|
28
|
+
&:hover {
|
|
29
|
+
border-right: solid 1px #999;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
${common_1.NoTextSelect};
|
|
33
|
+
|
|
34
|
+
&:hover {
|
|
35
|
+
[data-content] {
|
|
36
|
+
left: 1rem;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
`;
|
|
40
|
+
const ContentBlock = styled_components_1.default.div `
|
|
41
|
+
left: -18rem;
|
|
42
|
+
transition left 200ms;
|
|
43
|
+
&[data-open='false'] {
|
|
44
|
+
position: absolute;
|
|
45
|
+
top: 0;
|
|
46
|
+
z-index: 1;
|
|
47
|
+
width: 15rem;
|
|
48
|
+
}
|
|
49
|
+
`;
|
|
50
|
+
const Content = styled_components_1.default.div `
|
|
51
|
+
display: flex;
|
|
52
|
+
flex-flow: column;
|
|
53
|
+
width: 100%;
|
|
54
|
+
height: 100%;
|
|
55
|
+
margin-top: 2rem;
|
|
56
|
+
|
|
57
|
+
&[data-open='false'] {
|
|
58
|
+
padding: 1rem;
|
|
59
|
+
background-color: white;
|
|
60
|
+
${(0, common_1.Shadow)()};
|
|
61
|
+
border-radius: 1rem;
|
|
62
|
+
}
|
|
63
|
+
`;
|
|
64
|
+
const Hamburger = styled_components_1.default.div `
|
|
65
|
+
position: absolute;
|
|
66
|
+
transition: all 200ms;
|
|
67
|
+
&[data-open='false'] {
|
|
68
|
+
top: 0.5rem;
|
|
69
|
+
left: 0.25rem;
|
|
70
|
+
}
|
|
71
|
+
&[data-open='true'] {
|
|
72
|
+
top: 0.5rem;
|
|
73
|
+
right: -0.75rem;
|
|
74
|
+
}
|
|
75
|
+
display: flex;
|
|
76
|
+
justify-content: center;
|
|
77
|
+
align-items: center;
|
|
78
|
+
width: 1.5rem;
|
|
79
|
+
height: 1.5rem;
|
|
80
|
+
background-color: rgba(255, 255, 255, 0.9);
|
|
81
|
+
&:hover {
|
|
82
|
+
background-color: rgba(0, 0, 0, 0.1);
|
|
83
|
+
}
|
|
84
|
+
border-radius: 50%;
|
|
85
|
+
border: solid 1px rgba(0, 0, 0, 0.5);
|
|
86
|
+
|
|
87
|
+
cursor: pointer;
|
|
88
|
+
`;
|
|
89
|
+
const ChevronStyled = (0, styled_components_1.default)(Chevron_1.Chevron) `
|
|
90
|
+
svg {
|
|
91
|
+
fill: #555;
|
|
92
|
+
}
|
|
93
|
+
`;
|
|
94
|
+
const Sidebar = ({ children, className, key = 'sidebar', cookieDocument, }) => {
|
|
95
|
+
const [openRaw, setOpenRaw] = (0, cookie_1.useCookie)({
|
|
96
|
+
key,
|
|
97
|
+
defaultValue: 'false',
|
|
98
|
+
cookieDocument: cookieDocument,
|
|
99
|
+
});
|
|
100
|
+
const open = openRaw === 'true';
|
|
101
|
+
const setOpen = (o) => setOpenRaw(o.toString());
|
|
102
|
+
return (react_1.default.createElement(Base, { className: className, "data-open": open, onClick: () => !open && setOpen(true), "data-hover": true },
|
|
103
|
+
react_1.default.createElement(Hamburger, { "data-open": open, onClick: () => setOpen(!open), "data-hover": true },
|
|
104
|
+
react_1.default.createElement(ChevronStyled, { point: open ? 'right' : 'left', width: "100%" })),
|
|
105
|
+
react_1.default.createElement(ContentBlock, { "data-content": true, "data-open": open },
|
|
106
|
+
react_1.default.createElement(Content, { "data-open": open, onClick: (e) => {
|
|
107
|
+
e.stopPropagation();
|
|
108
|
+
} }, children))));
|
|
109
|
+
};
|
|
110
|
+
exports.Sidebar = Sidebar;
|
|
@@ -27,6 +27,7 @@ __exportStar(require("./LogoutButton"), exports);
|
|
|
27
27
|
__exportStar(require("./Modal"), exports);
|
|
28
28
|
__exportStar(require("./Prompt"), exports);
|
|
29
29
|
__exportStar(require("./RowOrColumn"), exports);
|
|
30
|
+
__exportStar(require("./Sidebar"), exports);
|
|
30
31
|
__exportStar(require("./Table"), exports);
|
|
31
32
|
__exportStar(require("./TextEdit"), exports);
|
|
32
33
|
__exportStar(require("./TextInput"), exports);
|