From a0c4c906fb45dc37be38683f3caf13d310e8961d Mon Sep 17 00:00:00 2001 From: Determinant Date: Tue, 19 Feb 2019 17:28:31 -0500 Subject: more improvements --- src/Analyze.tsx | 8 +++---- src/PatternTable.tsx | 63 +++++++++++++++++++++++++++++++++------------------- src/Settings.tsx | 21 ++++++++++-------- src/background.ts | 8 +++---- src/tab.tsx | 1 + 5 files changed, 61 insertions(+), 40 deletions(-) (limited to 'src') diff --git a/src/Analyze.tsx b/src/Analyze.tsx index bb3f38c..b272f30 100644 --- a/src/Analyze.tsx +++ b/src/Analyze.tsx @@ -194,7 +194,7 @@ class Analyze extends React.Component { const { classes } = this.props; return ( - + {
- + - + - + diff --git a/src/PatternTable.tsx b/src/PatternTable.tsx index e514551..075cafe 100644 --- a/src/PatternTable.tsx +++ b/src/PatternTable.tsx @@ -18,12 +18,12 @@ import { PatternEntry, PatternEntryColor } from './pattern'; import { GCalendarMeta } from './gapi'; const styles = (theme: Theme): StyleRules => ({ - deleteButton: { + deleteButtonRow: { width: 0, position: 'absolute', paddingRight: '24px', right: 0, - lineHeight: '48px', + lineHeight: '47px', }, deleteButtonHide: { display: 'none' @@ -32,15 +32,22 @@ const styles = (theme: Theme): StyleRules => ({ backgroundColor: theme.palette.background.default, zIndex: 1 }, - deleteIcon: { + deleteButton: { position: 'absolute', cursor: 'pointer' }, + deleteIcon: { + verticalAlign: 'middle' + }, patternTableWrapper: { - overflowX: 'auto', - overflowY: 'hidden' + width: '100%', + position: 'relative' }, patternTable: { + overflowX: 'auto', + overflowY: 'hidden', + }, + patternTableInner: { minWidth: 600 } }); @@ -52,12 +59,18 @@ let nameFieldstyles = { width: 30, marginRight: 10, cursor: 'pointer' + }, + wrapper: { + minWidth: 250 } }; type NameFieldProps = { value: PatternEntry, - classes: { colorSample: string }, + classes: { + colorSample: string, + wrapper: string + }, colorOnClick: (e: React.MouseEvent) => void, onChange: (f: string, v: string) => void }; @@ -65,7 +78,7 @@ type NameFieldProps = { function NameField(props: NameFieldProps) { let color = props.value.color.background; return ( -
+
{ let rows = patterns.slice(page * rowsPerPage, (page + 1) * rowsPerPage).map((p, i) => { let setActive = () => this.setState({ activePattern: p.idx }); let unsetActive = () => this.setState({ activePattern: null }); + let deleteButtonClass = this.state.activePattern !== p.idx ? + classes.deleteButtonHide : classes.deleteButtonShow; return [ + className={classes.deleteButtonRow}> -
+
this.props.onRemovePattern(p.idx)} />
@@ -169,7 +186,7 @@ class PatternTable extends React.Component { rows.flat(); return ( -
+
{ resetLabel='Reset' /> -
- +
+
{patternHead.map((s, i) => ({s.label}))} @@ -211,17 +228,17 @@ class PatternTable extends React.Component { }
-
+
); } } diff --git a/src/Settings.tsx b/src/Settings.tsx index 1e5df42..d44f1f6 100644 --- a/src/Settings.tsx +++ b/src/Settings.tsx @@ -38,7 +38,8 @@ const styles = (theme: Theme): StyleRules => ({ verticalAlign: 'top', textAlign: 'right', lineHeight: '3em', - minWidth: 250 + minWidth: 250, + width: '20%' }, tableContent: { textAlign: 'left', @@ -48,13 +49,13 @@ const styles = (theme: Theme): StyleRules => ({ marginLeft: -12 }, calendarList: { - maxHeight: 400, + maxHeight: 200, overflowY: 'auto' }, bottomButtons: { marginTop: 10, textAlign: 'right', - minWidth: 600 + minWidth: 650 }, trackedPeriodInput: { paddingTop: 10, @@ -158,6 +159,7 @@ type SettingsProps = { tableHead: string, tableContent: string, calendarList: string, + patternTableCell: string, bottomButtons: string, trackedPeriodInput: string, list: string, @@ -442,9 +444,10 @@ class Settings extends React.Component { Calendars - + +
{(this.state.isLoggedIn && - + {Object.keys(this.state.calendars).sort().map(id => { disableRipple /> )} - ) || 'Please Login.'} + ) || 'Please Login.'}
@@ -473,7 +476,7 @@ class Settings extends React.Component { onClick={this.handleLoadDefault}>Load Default
- + {(this.state.isLoggedIn && { Misc - - + + this.toggleOverrideNewTab()} diff --git a/src/background.ts b/src/background.ts index 9b95061..f536005 100644 --- a/src/background.ts +++ b/src/background.ts @@ -139,12 +139,12 @@ function updateMainGraphData() { let startD = p.start.toMoment(); let endD = p.end.toMoment(); if (!(startD && endD)) return; - let start = moment().endOf('day'); + let start = moment().add(1, 'days').startOf('day'); if (endD.valueOf() == 0) { switch (p.start.unit) { - case 'days': start = moment().endOf('day'); break; - case 'weeks': start = moment().endOf('week'); break; - case 'months': start = moment().endOf('month'); break; + case 'days': start = moment().add(1, 'days').startOf('day'); break; + case 'weeks': start = moment().add(1, 'weeks').startOf('isoWeek'); break; + case 'months': start = moment().add(1, 'months').startOf('month'); break; default: } } diff --git a/src/tab.tsx b/src/tab.tsx index ebddc70..5777dbe 100644 --- a/src/tab.tsx +++ b/src/tab.tsx @@ -74,6 +74,7 @@ class Tab extends React.Component { render() { let { classes } = this.props; let data = this.state.patternGraphData; + console.log(data); return ( -- cgit v1.2.3-70-g09d2