From 916236db5d6c5822dc69d13e2c08d60196fb1672 Mon Sep 17 00:00:00 2001 From: ransurf Date: Thu, 13 Jan 2022 12:47:36 -0800 Subject: [PATCH] Implement subtasks view and settings option, clean up CSS --- src/main.ts | 1 + src/settings.ts | 12 + src/view/App.tsx | 3 +- src/view/Components/Statsview/index.tsx | 1 - .../Taskview/Dailiesview/DailyItem.tsx | 5 +- .../Taskview/Dailiesview/DailySubTasks.tsx | 20 ++ .../Components/Taskview/Dailiesview/index.tsx | 18 +- .../Taskview/Habitsview/HabitItem.tsx | 16 +- .../Taskview/Rewardview/RewardItem.tsx | 10 +- .../Components/Taskview/Todoview/TodoItem.tsx | 4 +- .../Taskview/Todoview/TodoSubTasks.tsx | 20 ++ .../Components/Taskview/Todoview/index.tsx | 14 +- styles.css | 223 ++++++++++++------ 13 files changed, 257 insertions(+), 90 deletions(-) create mode 100644 src/view/Components/Taskview/Dailiesview/DailySubTasks.tsx create mode 100644 src/view/Components/Taskview/Todoview/TodoSubTasks.tsx diff --git a/src/main.ts b/src/main.ts index a0f350a..5b370f7 100644 --- a/src/main.ts +++ b/src/main.ts @@ -6,6 +6,7 @@ interface HabiticaSyncSettings { userID: string apiToken: string showTaskDescription: boolean + showSubTasks: boolean } const DEFAULT_SETTINGS: Partial = { userID: "", diff --git a/src/settings.ts b/src/settings.ts index 6957237..b223be2 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -50,6 +50,18 @@ export class HabiticaSyncSettingsTab extends PluginSettingTab { await this.plugin.saveSettings(); }) }); + + new Setting(containerEl) + .setName("Show Sub-Tasks") + .setDesc("Updates require pane re-opening") + .addToggle(cb => { + cb + .setValue(this.plugin.settings.showSubTasks) + .onChange(async (isEnable) => { + this.plugin.settings.showSubTasks = isEnable; + await this.plugin.saveSettings(); + }) + }); } } \ No newline at end of file diff --git a/src/view/App.tsx b/src/view/App.tsx index 7ca62c3..2f0abc5 100644 --- a/src/view/App.tsx +++ b/src/view/App.tsx @@ -194,9 +194,10 @@ class App extends React.Component { else { return (
{content} + - +
); } diff --git a/src/view/Components/Statsview/index.tsx b/src/view/Components/Statsview/index.tsx index c84d10e..6f5fc9e 100644 --- a/src/view/Components/Statsview/index.tsx +++ b/src/view/Components/Statsview/index.tsx @@ -4,7 +4,6 @@ export default function Index(props: any) { return(
{/*
{props.user_data.profile.name}
*/} - {console.log(props)}
HP: {(props.user_data.stats.hp).toPrecision(3)}
LEVEL: {props.user_data.stats.lvl}
GOLD: {(props.user_data.stats.gp).toPrecision(3)}
diff --git a/src/view/Components/Taskview/Dailiesview/DailyItem.tsx b/src/view/Components/Taskview/Dailiesview/DailyItem.tsx index 741eb8c..d5b2a93 100644 --- a/src/view/Components/Taskview/Dailiesview/DailyItem.tsx +++ b/src/view/Components/Taskview/Dailiesview/DailyItem.tsx @@ -1,6 +1,7 @@ import Emoji from "react-emoji-render"; import * as React from "react"; import ReactMarkdown from "react-markdown"; +import DailySubTasks from "./DailySubTasks"; function DailyItem(props: any) { return ( @@ -8,7 +9,9 @@ function DailyItem(props: any) {

- + + {console.log(props.checklist)} +
diff --git a/src/view/Components/Taskview/Dailiesview/DailySubTasks.tsx b/src/view/Components/Taskview/Dailiesview/DailySubTasks.tsx new file mode 100644 index 0000000..63d97d2 --- /dev/null +++ b/src/view/Components/Taskview/Dailiesview/DailySubTasks.tsx @@ -0,0 +1,20 @@ +import Emoji from "react-emoji-render"; +import * as React from "react"; + +function DailySubTasks(props: any) { + if (props.subtasks) { + const subtasks = props.subtasks.map((subtask: any) => { + return ( +
+ +

+
+ ) + }); + return subtasks + } + else { + return
+ } +} +export default DailySubTasks \ No newline at end of file diff --git a/src/view/Components/Taskview/Dailiesview/index.tsx b/src/view/Components/Taskview/Dailiesview/index.tsx index 9faafc2..27a988a 100644 --- a/src/view/Components/Taskview/Dailiesview/index.tsx +++ b/src/view/Components/Taskview/Dailiesview/index.tsx @@ -8,13 +8,21 @@ export default function Index(props: any){ } else { const incompleteDailies = props.dailys.map((daily: any) => { - if(!daily.completed) + if (!daily.completed) { + let daily_notes = ''; + let daily_subtasks = ''; if (props.settings.showTaskDescription) { - return - } else { - return + daily_notes = daily.notes; } - }) + + if (props.settings.showSubTasks) { + daily_subtasks = daily.checklist; + } + return + } + }) const completedDailies = props.dailys.map((daily: any) => { if(daily.completed) return diff --git a/src/view/Components/Taskview/Habitsview/HabitItem.tsx b/src/view/Components/Taskview/Habitsview/HabitItem.tsx index f458752..557adf6 100644 --- a/src/view/Components/Taskview/Habitsview/HabitItem.tsx +++ b/src/view/Components/Taskview/Habitsview/HabitItem.tsx @@ -5,15 +5,17 @@ import ReactMarkdown from "react-markdown"; function HabitItem(props: any) { return (
- - +
+ + +

- +
) diff --git a/src/view/Components/Taskview/Rewardview/RewardItem.tsx b/src/view/Components/Taskview/Rewardview/RewardItem.tsx index 0d86c01..983c909 100644 --- a/src/view/Components/Taskview/Rewardview/RewardItem.tsx +++ b/src/view/Components/Taskview/Rewardview/RewardItem.tsx @@ -3,11 +3,13 @@ import * as React from "react"; import ReactMarkdown from "react-markdown"; function RewardItem(props: any) { return ( -
- +
+
+ +
-

- +

+
diff --git a/src/view/Components/Taskview/Todoview/TodoItem.tsx b/src/view/Components/Taskview/Todoview/TodoItem.tsx index 92b3d7f..4c31505 100644 --- a/src/view/Components/Taskview/Todoview/TodoItem.tsx +++ b/src/view/Components/Taskview/Todoview/TodoItem.tsx @@ -1,6 +1,7 @@ import Emoji from "react-emoji-render"; import * as React from "react"; import ReactMarkdown from "react-markdown"; +import TodoSubTasks from "./TodoSubTasks"; function TodoItem(props: any) { return ( @@ -9,7 +10,8 @@ function TodoItem(props: any) { {/*

*/}

- + +
) diff --git a/src/view/Components/Taskview/Todoview/TodoSubTasks.tsx b/src/view/Components/Taskview/Todoview/TodoSubTasks.tsx new file mode 100644 index 0000000..79c7161 --- /dev/null +++ b/src/view/Components/Taskview/Todoview/TodoSubTasks.tsx @@ -0,0 +1,20 @@ +import Emoji from "react-emoji-render"; +import * as React from "react"; + +function TodoSubTasks(props: any) { + if (props.subtasks) { + const subtasks = props.subtasks.map((subtask: any) => { + return ( +
+ +

+
+ ) + }); + return subtasks + } + else { + return
+ } +} +export default TodoSubTasks \ No newline at end of file diff --git a/src/view/Components/Taskview/Todoview/index.tsx b/src/view/Components/Taskview/Todoview/index.tsx index 4f8c4e9..8c1f236 100644 --- a/src/view/Components/Taskview/Todoview/index.tsx +++ b/src/view/Components/Taskview/Todoview/index.tsx @@ -8,12 +8,20 @@ export default function Index(props: any){ } else { const incompleteTodos = props.todos.map((todo: any) => { + if(!todo.completed) { + let todo_notes = ''; + let todo_subtasks = ''; if (props.settings.showTaskDescription) { - return - } else { - return + todo_notes = todo.notes; } + + if (props.settings.showSubTasks) { + todo_subtasks = todo.checklist; + } + return } }) diff --git a/styles.css b/styles.css index c0feb7f..eef70b1 100644 --- a/styles.css +++ b/styles.css @@ -1,103 +1,156 @@ +@import url('https://fonts.googleapis.com/css2?family=Open+Sans:ital,wght@1,300&display=swap'); +@import url('https://fonts.googleapis.com/css2?family=Open Sans:ital,wght@0,400;1,100&family=Roboto&display=swap'); + +* { + padding: 0; +} + +.add-task-input { + display: flex; +} + +#profile-name { + font-size: x-large; + font-weight: bold; + padding-bottom: 3%; +} .stats { + width: 95%; display: flex; justify-content: space-between; + font-weight: bold; + padding-bottom: 5px; +} + +.stats-view { + border-bottom: 1px; +} +.modify-todo { + align-self: center; +} + +.delete-todo { + align-self: center; } .todo-item { - display: flex; - justify-content: flex-start; - align-items: center; - padding: 0px 0px 0; - width: 100%; - border-bottom: 1px solid #cecece; - font-family: Roboto, sans-serif; - font-weight: normal; - font-size: 16px; + display: grid; + grid-template-columns: 1fr 30fr 1fr 1fr; + justify-content: left; + align-items: flex-start; + padding-top: 5px; + padding-bottom: 5px; + width: 100%; + border-bottom: 1px solid #cecece; + font-family: Roboto, sans-serif; + font-weight: bold; + font-size: 16px; } -.reward-item { - display: flex; - justify-content: flex-start; - align-items: center; - padding: 0px 0px 0; - width: 100%; - border-bottom: 1px solid #cecece; - font-family: Roboto, sans-serif; - font-weight: normal; - font-size: 16px; +.description { + font-family: Open Sans, sans-serif; + font-style: italic; + font-weight: 100; +} +.description > ul { + list-style-type: none; +} +p { + margin: 0; } - .habit-text { text-align: left !important; - padding: 0px; + font-weight: bold; + padding-top: 5px; + width: 80%; margin-right: 20px; } -.habit-plus { +.habit-button { /* background-color: #fff; */ border: none; /* color: black; */ - padding: 7px 5px; - width: 40px; text-align: center; text-decoration: none; font-size: 16px; -} - -.habit-minus { - /* background-color: #fff; */ - /* border-radius: 50%; */ - border: none; - /* color: black; */ - padding: 7px 5px; - text-align: center; - text-decoration: none; - font-size: 16px; - width: 40px; + display: block; + width: 100%; } .habit-item { display: flex; - /* justify-content: center; */ - align-content: space-between; - align-items: center; - padding: 0px 0px 0; + grid-template-columns: 60px 1fr; width: 100%; + gap: 5px; border-bottom: 1px solid #cecece; - font-family: Roboto, sans-serif; - font-weight: 50%; + font-family: Open Sans, sans-serif; + font-weight: 100%; font-size: 16px; - + padding-top: 5px; + padding-bottom: 5px; +} + +.habit-button-grp { + display: flex; + flex-direction: column; + justify-content: flex-start; + align-content: stretch; + height: 100%; } input[type=checkbox] { margin-right: 10px; + margin-top: 5px; + align-self: start; +} + +.todo-content { + align-self: center; +} + +.submit-button { + /* padding: 5px 5px; */ + font-size: 15px; + border: 1px solid #aaa; + /* white-space: nowrap; */ + /* margin: 10px; */ + margin: 0; } input[type=checkbox]:focus { outline: 0; } -.task-view { - overflow: scroll; -} - ::-webkit-scrollbar { display: none; /* Chrome Safari */ } .plugin-root { min-width: 260px; - display: grid; - grid-template-rows: auto 1fr auto; - height: inherit; + display: flex; + flex-direction: column; + justify-content: flex-start; + align-items: center; +} + +#classDisplay { + height: 100%; +} + + +.view-content { + margin-bottom: 0; } .substats { font-size: medium; } +ul { + margin: 0; +} + /* react-tabs internal file :wink: */ .material-icons { font-size: 12px !important; @@ -114,12 +167,12 @@ input[type=checkbox]:focus { .react-tabs { -webkit-tap-highlight-color: transparent; - + height: 100%; } .react-tabs__tab-list { border-bottom: 1px solid #aaa; - margin: 0 0 10px; + margin: 0 0 5px; padding: 0; } @@ -165,6 +218,13 @@ input[type=checkbox]:focus { .react-tabs__tab-panel { display: none; left: 0px; + height: 88%; + /* overflow: scroll; */ +} + +.task-panel { + overflow: scroll; + height: 100%; } .react-tabs__tab-panel--selected { @@ -180,12 +240,47 @@ ul li:not(.task-list-item)::before { font-weight: bold; text-shadow: 0 0 0.5em transparent; } -body > div.app-container.is-left-sidedock-collapsed.is-right-sidedock-collapsed > div.horizontal-main-container > div > div.workspace-split.mod-horizontal.mod-right-split > div.workspace-tabs > div.workspace-leaf > div > div.view-content > div > div.cron > button { + +.task-operation { + align-self: center; + margin: 0; + padding: 0; +} + +.edit-item { + display: flex; + flex-direction: column; + width: 100%; +} + +.edit-button { + display: flex; + flex-direction: row; + justify-content: flex-end; +} + +.task-submit { + display: grid; + grid-template-columns: 10fr 5fr; +} + +.add-task-input { + display: block; + width: 100%; +} + +.task-input-box { + margin-right: 10px; +} + +button { margin: auto; margin-bottom: 5px; + white-space: nowrap; + padding: 5px 5px; + margin-right: 0; } .cron { - height: fit-content; display: inline-grid; justify-content: center; text-align: center;; @@ -193,7 +288,6 @@ body > div.app-container.is-left-sidedock-collapsed.is-right-sidedock-collapsed margin-left: 10%; margin-right: 10%; margin-bottom: 10px; - background-color: var(--background-primary-alt); border-radius: 10px; } #cronMessage { @@ -202,15 +296,10 @@ body > div.app-container.is-left-sidedock-collapsed.is-right-sidedock-collapsed color: var(--text-normal) } -button { - color: var(--text-normal); - background-color: var(--background-secondary-alt); - border-radius: 4px; - border: none; - padding: 6px 20px; - cursor: pointer; - margin-right: 12px; - font-family: 'Inter', sans-serif; - outline: none; - user-select: none; -} \ No newline at end of file +.subtask { + display: flex; + flex-direction: row; + font-weight: normal; + font-family: Roboto, sans-serif; + justify-content: flex-start; +}