Skip to content

Commit

Permalink
feat: style selected column header when stats are displayed
Browse files Browse the repository at this point in the history
  • Loading branch information
chriswhong committed Nov 15, 2019
1 parent 4d2bc8b commit 439cff5
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 10 deletions.
3 changes: 2 additions & 1 deletion app/components/Body.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,9 @@ const Body: React.FunctionComponent<BodyProps> = (props) => {
? <BodyTable
headers={headers}
body={value}
onFetch={onFetch}
pageInfo={pageInfo}
highlighedColumnIndex={details.type !== DetailsType.NoDetails ? details.index : undefined}
onFetch={onFetch}
setDetailsBar={handleToggleDetailsBar}
/>
: <BodyJson
Expand Down
5 changes: 3 additions & 2 deletions app/components/BodyTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { ApiAction } from '../store/api'
interface BodyTableProps {
headers?: any[]
body: any[]
highlighedColumnIndex: number | undefined
onFetch: (page?: number, pageSize?: number) => Promise<ApiAction>
setDetailsBar: (index: number) => void
pageInfo: PageInfo
Expand Down Expand Up @@ -95,7 +96,7 @@ export default class BodyTable extends React.Component<BodyTableProps> {
}

render () {
const { body, headers, pageInfo, setDetailsBar } = this.props
const { body, headers, pageInfo, highlighedColumnIndex, setDetailsBar } = this.props
const { fetchedAll } = pageInfo

const tableRows = body.map((row, i) => {
Expand Down Expand Up @@ -128,7 +129,7 @@ export default class BodyTable extends React.Component<BodyTableProps> {
</th>
{headers && headers.map((d: any, j: number) => {
return (
<th key={j}>
<th key={j} className={(j === highlighedColumnIndex) ? 'highlighted' : '' }>
<div className='cell' onClick={() => setDetailsBar(j)}>{d}</div>
</th>
)
Expand Down
4 changes: 2 additions & 2 deletions app/components/DetailsBar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react'
import { Details, DetailsType, StatsDetails } from '../models/details'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { faTimes } from '@fortawesome/free-solid-svg-icons'
import Stat from './stats/Stat'
import Stat from './StatsChart'

export interface DetailsBarProps {
details: Details
Expand All @@ -19,7 +19,7 @@ const DetailsBar: React.FunctionComponent<DetailsBarProps> = (props) => {
return (
<div>
<h4>{statsDetails.title}</h4>
<Stat data={details.stats} />
<Stat data={statsDetails.stats} />
</div>
)
}
Expand Down
16 changes: 11 additions & 5 deletions app/scss/_body.scss
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@
// body table

#body-table-container {
th:hover:not(.highlighted) {
background: #dcdcdc;
}

.highlighted {
background: #cdcdcd;
font-weight: 600;
text-decoration: underline;
}

.cell {
display: block;
Expand All @@ -56,7 +65,7 @@
white-space: nowrap;
}

th:first-child .cell, td:first-child .cell {
th:first-child .cell, td:first-child .cell, td:nth-child(2) .cell {
border-left: none;
}

Expand All @@ -71,10 +80,7 @@
top: 0;
background: #e6e6e6;
font-weight: 500;
}

thead .cell {
border-bottom: 1px solid #ECECEC;
cursor: pointer;
}

tfoot {
Expand Down

0 comments on commit 439cff5

Please sign in to comment.