Skip to content

Commit

Permalink
began small & extra-small screen width report table contents
Browse files Browse the repository at this point in the history
  • Loading branch information
djknit committed May 8, 2021
1 parent 4aa851b commit 8255019
Show file tree
Hide file tree
Showing 13 changed files with 471 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
import React from 'react';
import {
formatDurationForReportTable,
formatAmountEarnedForReportTable,
formatPayRateForReportTable
} from '../utilities';
import getStyle from './style';
import Times from '../../Times';
import TwoTzTimes from '../../TwoTzTimes';

function Row({
hasTimes,
primaryTimezone,
secondaryTimezone,
hasSecondTzCol,
hasSecondaryTzTimes,
hasEarningCols,
rowData: {
times: {
sessionTimezone: sessTzTimes,
officialTimezone: jobTzTimes
} = {},
rowLabel,
duration,
amountEarned,
payRate,
// _id, // segment id; only defined for rows that represent segments; not currently needed.
style: styleProp
},
isFirstInGroup,
date,
colWidths
}) {

const commonTimesAttrs = { dayDate: date };

const style = getStyle(styleProp, colWidths, isFirstInGroup);

return (
<tr style={style.tr}>
<td style={hasTimes ? style.timesTd : style.firstColNoTimes}>
{(hasTimes && hasSecondaryTzTimes && (
<TwoTzTimes
{...{
primaryTimezone,
secondaryTimezone
}}
primaryTimezoneTimes={sessTzTimes}
secondaryTimezoneTimes={jobTzTimes}
{...commonTimesAttrs}
/>
)) ||
(hasTimes && (
<Times {...sessTzTimes} {...commonTimesAttrs} />
)) ||
(rowLabel && (
<>{rowLabel}:</>
))}
</td>
<td style={style.durationTd}>
{formatDurationForReportTable(duration)}
</td>
{hasEarningCols && (
amountEarned ? (
<>
<td style={style.payRateTd}>
{formatPayRateForReportTable(payRate)}
</td>
<td style={style.amountEarnedTd}>
{formatAmountEarnedForReportTable(amountEarned)}
</td>
</>
) : (
<>
<td style={style.payRateTdUnpaid}>
{payRate === null && (
<> &mdash; </>
)}
</td>
<td style={style.amountEarnedTdUnpaid}>
{amountEarned === null && (
<> &mdash; </>
)}
</td>
</>
)
)}
{hasSecondTzCol && (
<td style={style.secondaryTzTimes}>
{hasTimes && hasSecondaryTzTimes && (
<Times {...jobTzTimes} {...commonTimesAttrs} />
)}
</td>
)}
</tr>
);
}

export default Row;
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import { labelWeight, contentAreaDividerColor, cellXPadding, cellYPadding } from '../style';

export default function getStyle(styleProp, colWidths = {}, isFirstRowInGroup) {

const borderTopPxWidth = isFirstRowInGroup ? 1.5 : 0.7;
const td = {
borderColor: contentAreaDividerColor,
borderWidth: `${borderTopPxWidth}px 0 0`,
whiteSpace: 'nowrap',
padding: `${cellYPadding} ${cellXPadding}`
};
const numAmountTd = {
...td,
textAlign: 'right'
};

return {
tr: {
...styleProp
},
timesTd: {
...td,
textAlign: 'center',
width: colWidths.times
},
firstColNoTimes: {
...td,
textAlign: 'right',
fontWeight: labelWeight,
width: colWidths.times
},
durationTd: {
...numAmountTd,
width: colWidths.duration
},
payRateTd: {
...numAmountTd,
width: colWidths.payRate
},
amountEarnedTd: {
...numAmountTd,
width: colWidths.amountEarned
},
payRateTdUnpaid: {
...numAmountTd,
paddingRight: `calc(${cellXPadding} + 1.5em)`,
width: colWidths.payRate
},
amountEarnedTdUnpaid: {
...numAmountTd,
paddingRight: `calc(${cellXPadding} + 0.75em)`,
width: colWidths.amountEarned
},
secondaryTzTimes: {
...td,
width: colWidths.secondaryTzTimes
},
};
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import React from 'react';
// import getStyle from './style';
// import { getTimezoneAbbreviation } from './utilities';
import Thead from '../Head';
import RowsGroup from '../RowsGroup';
import Row from './Row';

function ExtraSmallWidthTableContent({
rowGroups,
hasTimes,
hasSecondaryTzTimes,
colRefs,
...otherProps
}) {

const commonAttrs = {
...otherProps,
hasSecondTzCol: false
};

const primaryTzLabel = hasTimes && hasSecondaryTzTimes && 'Times';
// const style = getStyle(styleProp, colWidths);

return (
<>
<Thead
{...{
...commonAttrs,
hasTimes,
hasSecondaryTzTimes,
colRefs,
primaryTzLabel
}}
/>
<tbody>
{rowGroups.map(
({ rows, hasTimes: groupHasTimes = hasTimes }, index) => (
<RowsGroup
key={index}
{...commonAttrs}
{...{ rows }}
RowComponent={Row}
hasTimes={groupHasTimes}
hasSecondaryTzTimes={groupHasTimes && hasSecondaryTzTimes}
/>
)
)}
</tbody>
</>
);
}

export default ExtraSmallWidthTableContent;
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export * from '../style';

export default function getStyle() {
return {};
};
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from '../../utilities';
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,21 @@ function Thead({
hasSecondaryTzTimes,
colRefs,
colWidths,
style: styleProp
style: styleProp,
isTwoCol,
twoColValuesLabel = 'Values'
}) {

let firstColLabel, lastColLabel;

const _getTzAbbrev = _tzName => getTimezoneAbbreviation(_tzName, date, true);

if (hasTimes) {
firstColLabel = (
primaryTzLabel ||
`Times (${getTimezoneAbbreviation(primaryTimezone, date, true)})`
);
lastColLabel = (
secondaryTzLabel ||
`Job Timezone (${getTimezoneAbbreviation(secondaryTimezone, date, true)})`
(hasSecondaryTzTimes ? 'Times' : `Times ${_getTzAbbrev(primaryTimezone)}`)
);
lastColLabel = secondaryTzLabel || `Job Timezone (${_getTzAbbrev(secondaryTimezone)})`;
}

const style = getStyle(styleProp, colWidths);
Expand All @@ -39,7 +40,7 @@ function Thead({
{firstColLabel}
</th>
<th style={style.durationTh} ref={colRefs.duration}>
Hours Worked
{isTwoCol ? twoColValuesLabel : 'Hours Worked'}
</th>
{hasEarningCols && (
<>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import Thead from '../Head';
import RowsGroup from '../RowsGroup';
import Row from './Row';

function Table({
function MediumWidthTableContent({
rowGroups,
hasTimes,
hasSecondaryTzTimes,
Expand Down Expand Up @@ -50,4 +50,4 @@ function Table({
);
}

export default Table;
export default MediumWidthTableContent;
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
import React from 'react';
import {
formatDurationForReportTable,
formatAmountEarnedForReportTable,
formatPayRateForReportTable
} from '../utilities';
import getStyle from './style';
import Times from '../../Times';
import TwoTzTimes from '../../TwoTzTimes';

function Row({
hasTimes,
primaryTimezone,
secondaryTimezone,
hasSecondTzCol,
hasSecondaryTzTimes,
hasEarningCols,
rowData: {
times: {
sessionTimezone: sessTzTimes,
officialTimezone: jobTzTimes
} = {},
rowLabel,
duration,
amountEarned,
payRate,
// _id, // segment id; only defined for rows that represent segments; not currently needed.
style: styleProp
},
isFirstInGroup,
date,
colWidths
}) {

const commonTimesAttrs = { dayDate: date };

const style = getStyle(styleProp, colWidths, isFirstInGroup);

return (
<tr style={style.tr}>
<td style={hasTimes ? style.timesTd : style.firstColNoTimes}>
{(hasTimes && hasSecondaryTzTimes && (
<TwoTzTimes
{...{
primaryTimezone,
secondaryTimezone
}}
primaryTimezoneTimes={sessTzTimes}
secondaryTimezoneTimes={jobTzTimes}
{...commonTimesAttrs}
/>
)) ||
(hasTimes && (
<Times {...sessTzTimes} {...commonTimesAttrs} />
)) ||
(rowLabel && (
<>{rowLabel}:</>
))}
</td>
<td style={style.durationTd}>
{formatDurationForReportTable(duration)}
</td>
{hasEarningCols && (
amountEarned ? (
<>
<td style={style.payRateTd}>
{formatPayRateForReportTable(payRate)}
</td>
<td style={style.amountEarnedTd}>
{formatAmountEarnedForReportTable(amountEarned)}
</td>
</>
) : (
<>
<td style={style.payRateTdUnpaid}>
{payRate === null && (
<> &mdash; </>
)}
</td>
<td style={style.amountEarnedTdUnpaid}>
{amountEarned === null && (
<> &mdash; </>
)}
</td>
</>
)
)}
{hasSecondTzCol && (
<td style={style.secondaryTzTimes}>
{hasTimes && hasSecondaryTzTimes && (
<Times {...jobTzTimes} {...commonTimesAttrs} />
)}
</td>
)}
</tr>
);
}

export default Row;
Loading

0 comments on commit 8255019

Please sign in to comment.