-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Date selection added to UI. Only dates with reading history can be selected * Using React toolbox components * Removed footer, entries, and date logic from Dokusho module * Removed some modules, no need for a module when a file only contains component
- Loading branch information
Showing
23 changed files
with
797 additions
and
166 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,3 +24,5 @@ | |
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
toolbox/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
[%bs.raw {|require('./toolbox/theme.css')|}]; | ||
|
||
open Dokusho; | ||
|
||
[@bs.module] | ||
external theme : ReactToolbox.ThemeProvider.theme = "./toolbox/theme"; | ||
[%bs.raw {|require('./toolbox/theme.css')|}]; | ||
|
||
let component = ReasonReact.statelessComponent("App"); | ||
|
||
let make = _children => { | ||
...component, | ||
render: _self => | ||
<ReactToolbox.ThemeProvider theme> | ||
<div className="app"> | ||
<Dokusho/> | ||
</div> | ||
</ReactToolbox.ThemeProvider> | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
let component = ReasonReact.reducerComponent("DateSelector"); | ||
|
||
let make = (~onChangeSelect, ~enabledDates, _children) => { | ||
...component, | ||
initialState: () => Js.Date.make(), | ||
reducer: (state, _ext) => | ||
ReasonReact.Update({ state }), | ||
render: ( | ||
{state, reduce}) => | ||
<div> | ||
<ReactToolbox.DatePicker | ||
label="Date" | ||
value=(`Date(state)) | ||
enabledDates=(enabledDates) | ||
onChange=((date, _mouse) => | ||
{ | ||
onChangeSelect(date); | ||
(reduce(() => { date }))(); | ||
} | ||
)/> | ||
</div> | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,56 +1,67 @@ | ||
open Input; | ||
open Entry; | ||
open Types; | ||
open Day; | ||
open PageTypeSelection; | ||
open Actions; | ||
open DokuUtil; | ||
open Rationale; | ||
|
||
module Dokusho { | ||
let component = ReasonReact.reducerComponent("Dokusho"); | ||
let initState = () => { | ||
readingData: { days : [Day.now()] }, | ||
selectedEntry: Book | ||
selectedEntry: Book, | ||
selectedDate: Js.Date.make() | ||
}; | ||
|
||
let make = (_children) => { | ||
...component, | ||
initialState: () => initState(), | ||
reducer: (action, { readingData, selectedEntry }) => | ||
reducer: (action, { readingData, selectedEntry, selectedDate }) => | ||
switch action { | ||
| ChangeSelection(pageType) => | ||
ReasonReact.Update({readingData: readingData, selectedEntry: pageType}); | ||
ReasonReact.Update({readingData: readingData, selectedEntry: pageType, selectedDate: selectedDate}); | ||
| AddEntry(pageType, count) => | ||
Actions.addNewEntry(pageType, count); | ||
| UpdateHistory(days) => | ||
ReasonReact.Update({readingData: {days: days}, selectedEntry: selectedEntry}); | ||
ReasonReact.Update({readingData: {days: days}, selectedEntry: selectedEntry, selectedDate: selectedDate}); | ||
| LoadUserData(userId) => | ||
Actions.loadUserData(userId); | ||
| SelectDate(date) => | ||
ReasonReact.Update({readingData: readingData, selectedEntry: selectedEntry, selectedDate: date}); | ||
}, | ||
didMount: (_self) => { | ||
Actions.loadUserData(testUser); | ||
}, | ||
render: (self) => { | ||
let pageCount = Day.pageCount(List.hd(self.state.readingData.days)); | ||
let dateKey = self.state.selectedDate |> DateUtil.dateWithoutTime |> DateUtil.asDateKey; | ||
|
||
<div className="app"> | ||
<div className="title"> | ||
(ReasonReact.stringToElement("Dokusho")) | ||
<Input | ||
selection=self.state.selectedEntry | ||
onSubmit=(self.reduce((text) => AddEntry(self.state.selectedEntry, int_of_string(text)))) | ||
/> | ||
<PageTypeSelection onChangeSelect=(self.reduce(selected => ChangeSelection(selected))) /> | ||
</div> | ||
<div className="entries"> | ||
(List.hd(self.state.readingData.days).entries | ||
|> List.map((entry: entry) => <Entry key=(string_of_int(entry.id)) entry=entry />) | ||
|> Array.of_list | ||
|> ReasonReact.arrayToElement) | ||
</div> | ||
<div className="footer"> | ||
(ReasonReact.stringToElement(string_of_float(pageCount) ++ " pages")) | ||
</div> | ||
</div> | ||
let day = RList.find(d => d.date == dateKey, self.state.readingData.days); | ||
let pageCount = day |> Option.fmap(Day.pageCount) |> Option.default(0.); | ||
let entries = day |> Option.fmap(d => d.entries) |> Option.default([]); | ||
|
||
let availableDates = DateUtil.availableDates(self.state.readingData); | ||
|
||
<div> | ||
<div className="title"> | ||
(ReasonReact.stringToElement("Dokusho")) | ||
</div> | ||
<div className="dokusho"> | ||
<Input | ||
selection=self.state.selectedEntry | ||
onSubmit=(self.reduce((text) => AddEntry(self.state.selectedEntry, int_of_string(text)))) | ||
/> | ||
|
||
<PageTypeSelection onChangeSelect=(self.reduce(selected => ChangeSelection(selected))) /> | ||
|
||
<DateSelector | ||
onChangeSelect=(self.reduce(date => SelectDate(date))) | ||
enabledDates=(availableDates) /> | ||
|
||
<Entries entries=(entries) /> | ||
|
||
<Footer pageCount=(pageCount) /> | ||
</div> | ||
</div> | ||
} | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
open Types; | ||
|
||
let component = ReasonReact.statelessComponent("Entry"); | ||
|
||
let make = (~entries: list(entry), _children) => { | ||
...component, | ||
render: (_) => | ||
<div className="entries"> | ||
( | ||
entries | ||
|> List.map((entry: entry) => | ||
<Entry key=(string_of_int(entry.id)) entry /> | ||
) | ||
|> Array.of_list | ||
|> ReasonReact.arrayToElement | ||
) | ||
</div> | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,18 @@ | ||
open Types; | ||
|
||
open PageType; | ||
|
||
module Entry = { | ||
let component = ReasonReact.statelessComponent("Entry"); | ||
let make = (~entry: entry, _children) => { | ||
...component, | ||
render: (_) => | ||
<div className="entry"> | ||
(entry.kind |> | ||
PageType.toString |> | ||
(str) => str ++ ": " ++ string_of_int(entry.value) |> | ||
ReasonReact.stringToElement) | ||
</div> | ||
}; | ||
let component = ReasonReact.statelessComponent("Entry"); | ||
|
||
let make = (~entry: entry, _children) => { | ||
...component, | ||
render: (_) => | ||
<div className="entry"> | ||
( | ||
entry.kind | ||
|> PageType.toString | ||
|> ((str) => str ++ ": " ++ string_of_int(entry.value) | ||
|> ReasonReact.stringToElement) | ||
) | ||
</div> | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
let component = ReasonReact.statelessComponent("Footer"); | ||
|
||
let make = (~pageCount: float, _children) => { | ||
...component, | ||
render: (_) => | ||
<div className="footer"> | ||
(ReasonReact.stringToElement(string_of_float(pageCount) ++ " pages")) | ||
</div> | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.