Skip to content

Commit 84eedd6

Browse files
Sean PrashadSean Prashad
authored andcommitted
Add initial Tabs component
1 parent 276c64f commit 84eedd6

File tree

6 files changed

+70
-4
lines changed

6 files changed

+70
-4
lines changed

web/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"@testing-library/react": "^9.3.2",
99
"@testing-library/user-event": "^7.1.2",
1010
"bootstrap": "^4.4.1",
11+
"classnames": "^2.2.6",
1112
"enzyme": "^3.11.0",
1213
"enzyme-adapter-react-16": "^1.15.2",
1314
"gh-pages": "^2.2.0",

web/src/components/App.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@ import React from 'react';
33
import './styles.scss';
44

55
import Navigation from './Navigation';
6-
import Table from './Table';
6+
import Tabs from './Tabs';
77

88
function App() {
99
return (
1010
<div className="App">
1111
<Navigation />
12-
<Table />
12+
<Tabs />
1313
</div>
1414
);
1515
}

web/src/components/Table/TableView/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ function TableView({ columns, data }) {
2222
);
2323

2424
return (
25-
<Table align="center" striped hover {...getTableProps()}>
25+
<Table align="center" responsive striped hover {...getTableProps()}>
2626
<thead>
2727
{headerGroups.map(headerGroup => (
2828
<tr {...headerGroup.getHeaderGroupProps()}>

web/src/components/Tabs/index.js

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import React, { useState } from 'react';
2+
import {
3+
TabContent,
4+
TabPane,
5+
Nav,
6+
NavItem,
7+
NavLink,
8+
Row,
9+
Col,
10+
Container,
11+
} from 'reactstrap';
12+
import classnames from 'classnames';
13+
14+
import Table from '../Table';
15+
16+
const Tabs = () => {
17+
const [activeTab, setActiveTab] = useState('1');
18+
19+
const toggle = tab => {
20+
if (activeTab !== tab) setActiveTab(tab);
21+
};
22+
23+
return (
24+
<Container>
25+
<Nav tabs>
26+
<NavItem>
27+
<NavLink
28+
className={classnames({ active: activeTab === '1' })}
29+
onClick={() => {
30+
toggle('1');
31+
}}
32+
>
33+
Question List
34+
</NavLink>
35+
</NavItem>
36+
<NavItem>
37+
<NavLink
38+
className={classnames({ active: activeTab === '2' })}
39+
onClick={() => {
40+
toggle('2');
41+
}}
42+
>
43+
Moar Tabs
44+
</NavLink>
45+
</NavItem>
46+
</Nav>
47+
<TabContent activeTab={activeTab}>
48+
<TabPane tabId="1">
49+
<Row>
50+
<Col>
51+
<Table />
52+
</Col>
53+
</Row>
54+
</TabPane>
55+
<TabPane tabId="2">
56+
<Row>
57+
<Col>Tab pane 2</Col>
58+
</Row>
59+
</TabPane>
60+
</TabContent>
61+
</Container>
62+
);
63+
};
64+
65+
export default Tabs;

web/src/components/Tabs/styles.scss

Whitespace-only changes.

web/yarn.lock

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2694,7 +2694,7 @@ class-utils@^0.3.5:
26942694
isobject "^3.0.0"
26952695
static-extend "^0.1.1"
26962696

2697-
classnames@^2.2.3:
2697+
classnames@^2.2.3, classnames@^2.2.6:
26982698
version "2.2.6"
26992699
resolved "https://registry.yarnpkg.com/classnames/-/classnames-2.2.6.tgz#43935bffdd291f326dad0a205309b38d00f650ce"
27002700
integrity sha512-JR/iSQOSt+LQIWwrwEzJ9uk0xfN3mTVYMwt1Ir5mUcSN6pU+V4zQFFaJsclJbPuAUQH+yfWef6tm7l1quW3C8Q==

0 commit comments

Comments
 (0)