Skip to content

Commit d12fdfb

Browse files
committed
Add dropdown componant to sidebar
Co-authored-by: Eric Han eric.j.h92@gmail.com
1 parent bba4489 commit d12fdfb

File tree

4 files changed

+80
-4
lines changed

4 files changed

+80
-4
lines changed

backend/main.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,6 @@ if (dev) {
7171
installExtension(REACT_DEVELOPER_TOOLS);
7272
});
7373
}
74-
7574
// Invoke createWindow to create browser windows after Electron has been initialized.
7675
app.on('ready', createWindow);
7776

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
import React from 'react';
2+
import styled from 'styled-components';
3+
import {
4+
IconButton,
5+
ListItemSecondaryAction,
6+
Checkbox,
7+
Tooltip,
8+
} from '@material-ui/core';
9+
import CloseIcon from '@material-ui/icons/Close';
10+
import {
11+
SidebarListItem,
12+
StyledListItemText,
13+
textColor,
14+
} from '../../style-variables';
15+
import { QueryData } from '../../types';
16+
17+
const QueryText = styled(StyledListItemText)`
18+
& .MuiListItemText-secondary {
19+
color: ${textColor};
20+
}
21+
`;
22+
23+
const CompareCheck = styled(Checkbox)`
24+
color: ${textColor};
25+
`;
26+
27+
interface QueryDbnameProps {
28+
query: QueryData;
29+
isSelected: boolean;
30+
select: () => void;
31+
setComparison: (evt: React.ChangeEvent<HTMLInputElement>) => void;
32+
isCompared: boolean;
33+
deleteThisQuery: () => void;
34+
}
35+
36+
const QueryDbname = ({
37+
query,
38+
select,
39+
isSelected,
40+
setComparison,
41+
isCompared,
42+
deleteThisQuery,
43+
}: QueryDbnameProps) => (
44+
<SidebarListItem button $customSelected={isSelected} onClick={select}>
45+
<QueryText primary={query.db} />
46+
<ListItemSecondaryAction>
47+
<Tooltip title="View in Comparison">
48+
<CompareCheck onChange={setComparison} checked={isCompared} />
49+
</Tooltip>
50+
<Tooltip title="Forget Query">
51+
<IconButton edge="end" onClick={deleteThisQuery}>
52+
<CloseIcon />
53+
</IconButton>
54+
</Tooltip>
55+
</ListItemSecondaryAction>
56+
</SidebarListItem>
57+
);
58+
59+
export default QueryDbname;

frontend/components/sidebar/QueryEntry.tsx

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import {
1313
textColor,
1414
} from '../../style-variables';
1515
import { QueryData } from '../../types';
16+
import QueryDbname from './QueryDbname';
17+
import { Accordion } from 'react-bootstrap-accordion';
1618

1719
const QueryText = styled(StyledListItemText)`
1820
& .MuiListItemText-secondary {
@@ -42,10 +44,25 @@ const QueryEntry = ({
4244
deleteThisQuery,
4345
}: QueryEntryProps) => (
4446
<SidebarListItem button $customSelected={isSelected} onClick={select}>
45-
<QueryText primary={query.label} secondary={query.db} />
47+
<QueryText primary={query.label} />
48+
4649
<ListItemSecondaryAction>
47-
<Tooltip title="View in Comparison">
48-
<CompareCheck onChange={setComparison} checked={isCompared} />
50+
<Tooltip title="drop down">
51+
{/* <CompareCheck onChange={setComparison} checked={isCompared} /> */}
52+
<div className="accordion" id="accordionPanelsStayOpenExample"></div>
53+
<div className="accordion-item">
54+
<h2 className="accordion-header" id="panelsStayOpen-headingOne">
55+
<button className="accordion-button" type="button" data-bs-toggle="collapse" data-bs-target="#panelsStayOpen-collapseOne" aria-expanded="true" aria-controls="panelsStayOpen-collapseOne">
56+
Accordion Item #1
57+
</button>
58+
</h2>
59+
<div id="panelsStayOpen-collapseOne" className="accordion-collapse collapse show" aria-labelledby="panelsStayOpen-headingOne">
60+
<div className="accordion-body">
61+
<strong>This is the first item's accordion body.</strong> It is shown by default, until the collapse plugin adds the appropriate classes that we use to style each element. These classes control the overall appearance, as well as the showing and hiding via CSS transitions. You can modify any of this with custom CSS or overriding our default variables. It's also worth noting that just about any HTML can go within the <code>.accordion-body</code>, though the transition does limit overflow.
62+
</div>
63+
</div>
64+
</div>
65+
</div>
4966
</Tooltip>
5067
<Tooltip title="Forget Query">
5168
<IconButton edge="end" onClick={deleteThisQuery}>

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
"pg": "^8.3.2",
5252
"react": "^17.0.1",
5353
"react-bootstrap": "^1.3.0",
54+
"react-bootstrap-accordion": "^1.0.0",
5455
"react-chartjs-2": "^2.11.1",
5556
"react-codemirror": "^1.0.0",
5657
"react-dom": "^17.0.1",

0 commit comments

Comments
 (0)