From 81ba11839367d6371388c0e7eb0d09cb1f33f769 Mon Sep 17 00:00:00 2001 From: Gwyn Perry Date: Mon, 6 Nov 2023 01:28:46 +0000 Subject: [PATCH] Added dot grid option to Itinerary elements First iteration of adding dot grid option to Itinerary elements, including: - methods to render dot grid lines in Itinerary - UI to set dot grid option - config settings for dot grid option --- src/configuration.jsx | 12 +++++ src/locales/en/app.json | 4 ++ src/pdf/components/itinerary.jsx | 75 ++++++++++++++++++++++++++-- src/pdf/config.js | 2 + src/pdf/pages/day.jsx | 4 +- src/pdf/pages/month-overview.jsx | 4 +- src/pdf/pages/week-retrospective.jsx | 7 ++- 7 files changed, 99 insertions(+), 9 deletions(-) diff --git a/src/configuration.jsx b/src/configuration.jsx index 809083e..9761a44 100644 --- a/src/configuration.jsx +++ b/src/configuration.jsx @@ -460,6 +460,18 @@ class Configuration extends React.PureComponent { {t( 'configuration.general.sidebar.description' )} + + + + {t( 'configuration.general.dot-grid.description' )} + + {t( 'configuration.general.year' )} { switch ( type ) { case ITINERARY_ITEM: - return this.renderItem( value, index ); + return this.props.config.useDotGrid ? this.renderGridItem( value, index ) + : this.renderItem( value, index ); case ITINERARY_LINES: default: - return this.renderLines( value ); + return this.props.config.useDotGrid ? this.renderGridLines( value ) + : this.renderLines( value ); } }; @@ -44,6 +66,52 @@ class Itinerary extends React.PureComponent { return lines; } + renderDots( count ) { + const dots = []; + for ( let i = 0; i < count; i++ ) { + dots.push( ); + } + + return dots; + } + + renderDottedLine() { + return ( + + {this.renderDots( 21 )} + + ); + } + + renderGridItem( text, index ) { + return ( + <> + + {text} + + {this.renderDottedLine()} + + ); + } + + renderGridLine() { + return ( + <> + + {this.renderDottedLine()} + + ); + } + + renderGridLines( count ) { + const lines = []; + for ( let i = 0; i < count; i++ ) { + lines.push( this.renderGridLine() ); + } + + return lines; + } + render() { return <>{this.props.items.map( this.renderItineraryItem )}; } @@ -51,6 +119,7 @@ class Itinerary extends React.PureComponent { Itinerary.propTypes = { items: PropTypes.array.isRequired, + config: PropTypes.instanceOf( PdfConfig ).isRequired, }; export default Itinerary; diff --git a/src/pdf/config.js b/src/pdf/config.js index a17bd94..8a47702 100644 --- a/src/pdf/config.js +++ b/src/pdf/config.js @@ -18,6 +18,7 @@ const CONFIG_FIELDS = [ 'weekendDays', 'isLeftHanded', 'alwaysOnSidebar', + 'useDotGrid', 'isMonthOverviewEnabled', 'habits', 'monthItinerary', @@ -53,6 +54,7 @@ class PdfConfig { this.weekendDays = [ 0, 6 ]; this.isLeftHanded = false; this.alwaysOnSidebar = false; + this.useDotGrid = false; this.monthCount = 12; this.fontFamily = LATO; this.isMonthOverviewEnabled = true; diff --git a/src/pdf/pages/day.jsx b/src/pdf/pages/day.jsx index e0bcdff..ccaf05d 100644 --- a/src/pdf/pages/day.jsx +++ b/src/pdf/pages/day.jsx @@ -28,7 +28,7 @@ class DayPage extends React.Component { renderExtraItems = ( items, index ) => ( - + ); @@ -60,7 +60,7 @@ class DayPage extends React.Component { specialItems={ specialItems } /> - + diff --git a/src/pdf/pages/month-overview.jsx b/src/pdf/pages/month-overview.jsx index e9f33ae..9f6ea6f 100644 --- a/src/pdf/pages/month-overview.jsx +++ b/src/pdf/pages/month-overview.jsx @@ -221,14 +221,14 @@ class MonthOverviewPage extends React.Component { {this.renderHabitsTable()} - + {getItemsOnExtraPages( config.monthItinerary ).map( ( items, index ) => ( - + ) )} diff --git a/src/pdf/pages/week-retrospective.jsx b/src/pdf/pages/week-retrospective.jsx index 6fc2ef0..fe8ab9e 100644 --- a/src/pdf/pages/week-retrospective.jsx +++ b/src/pdf/pages/week-retrospective.jsx @@ -51,7 +51,10 @@ class WeekRetrospectivePage extends React.Component { } /> - + @@ -59,7 +62,7 @@ class WeekRetrospectivePage extends React.Component { ( items, index ) => ( - + ),