From bc97bcfc3f12770b077db825d9defeec8ff6f2e0 Mon Sep 17 00:00:00 2001 From: kkzzhizhou <806508401@qq.com> Date: Thu, 18 Nov 2021 14:16:20 +0800 Subject: [PATCH 01/16] add rewards panels and change styles --- src/main.ts | 3 +- src/view.tsx | 6 +- src/view/App.tsx | 130 +++++++++++------- src/view/Components/Statsview/index.tsx | 8 +- .../Taskview/Habitsview/HabitItem.tsx | 7 +- src/view/Components/Taskview/index.tsx | 22 ++- src/view/habiticaAPI.ts | 16 ++- styles.css | 47 +++++-- 8 files changed, 163 insertions(+), 76 deletions(-) diff --git a/src/main.ts b/src/main.ts index bdf0312..7e628b9 100644 --- a/src/main.ts +++ b/src/main.ts @@ -15,6 +15,7 @@ export default class HabiticaSync extends Plugin { view: HabiticaSyncView; async onload() { + console.log("正在加载habitica-sync") await this.loadSettings(); this.addSettingTab(new HabiticaSyncSettingsTab(this.app, this)); this.registerView( @@ -40,7 +41,7 @@ export default class HabiticaSync extends Plugin { await this.saveData(this.settings); } async onunload() { - await this.view.onClose(); + // await this.view.onClose(); this.app.workspace .getLeavesOfType(VIEW_TYPE) diff --git a/src/view.tsx b/src/view.tsx index e73dbb7..827b893 100644 --- a/src/view.tsx +++ b/src/view.tsx @@ -32,7 +32,7 @@ export class HabiticaSyncView extends ItemView { ) } - async onClose(){ - ReactDOM.unmountComponentAtNode(this.containerEl.children[1]); - } + // async onClose(){ + // ReactDOM.unmountComponentAtNode(this.containerEl.children[1]); + // } } \ No newline at end of file diff --git a/src/view/App.tsx b/src/view/App.tsx index aaf4cc0..e456b0b 100644 --- a/src/view/App.tsx +++ b/src/view/App.tsx @@ -1,10 +1,10 @@ import * as React from "react"; import { Notice } from "obsidian"; -import { getStats, scoreTask, makeCronReq } from "./habiticaAPI" +import { getStats, scoreTask, makeCronReq, costReward } from "./habiticaAPI" import Statsview from "./Components/Statsview" import Taskview from "./Components/Taskview" -class App extends React.Component { +class App extends React.Component { private _username = ""; public get username() { return this._username; @@ -43,6 +43,7 @@ class App extends React.Component { this.handleChangeTodos = this.handleChangeTodos.bind(this); this.handleChangeDailys = this.handleChangeDailys.bind(this); this.handleChangeHabits = this.handleChangeHabits.bind(this); + this.handleChangeRewards = this.handleChangeRewards.bind(this); this.runCron = this.runCron.bind(this); } @@ -50,7 +51,7 @@ class App extends React.Component { let cronDate = new Date(lastCron); let now = new Date(); if (cronDate.getDate() != now.getDate() || (cronDate.getMonth() != now.getMonth() || cronDate.getFullYear() != now.getFullYear())) { - return( + return (
Welcome back! Please check your tasks for the last day and hit continue to get your daily rewards.
@@ -73,102 +74,131 @@ class App extends React.Component { new Notice("There was an error running the cron. Please try again later."); } this.reloadData(); - } + } async reloadData() { try { - let response = await getStats(this.username, this.credentials); - let result = await response.json(); - if (result.success === false) { - new Notice('Login Failed, Please check credentials and try again!'); - } - else { - this.setState({ - isLoaded: true, - user_data: result, - tasks: result.tasks, - }); - } - } catch (e) { + let response = await getStats(this.username, this.credentials); + let result = await response.json(); + if (result.success === false) { + new Notice('Login Failed, Please check credentials and try again!'); + } + else { + this.setState({ + isLoaded: true, + user_data: result, + tasks: result.tasks, + }); + } + } catch (e) { console.log(e); new Notice("API Error: Please check credentials") - } + } } componentDidMount() { this.reloadData() } - - async sendScore(id:string , score: string, message: string){ + + async sendScore(id: string, score: string, message: string) { try { - let response = await scoreTask(this.username, this.credentials, id, score); - let result = await response.json(); - if(result.success === true){ + let response = await scoreTask(this.username, this.credentials, id, score); + let result = await response.json(); + if (result.success === true) { new Notice(message); this.reloadData(); } else { new Notice("Resyncing, please try again"); this.reloadData(); } - } catch (e) { + } catch (e) { console.log(e); new Notice("API Error: Please check credentials") - } + } } - handleChangeTodos(event: any){ + async sendReward(id: string, score: string, message: string) { + try { + let response = await costReward(this.username, this.credentials, id, score); + let result = await response.json(); + if (result.success === true) { + new Notice(message); + this.reloadData(); + } else { + new Notice("Resyncing, please try again"); + this.reloadData(); + } + } catch (e) { + console.log(e); + new Notice("API Error: Please check credentials") + } + } + + handleChangeTodos(event: any) { this.state.tasks.todos.forEach((element: any) => { - if(element.id == event.target.id){ - if(!element.completed){ - this.sendScore(event.target.id,"up", "Checked!") + if (element.id == event.target.id) { + if (!element.completed) { + this.sendScore(event.target.id, "up", "Checked!") } else { - this.sendScore(event.target.id,"down", "Un-Checked!") + this.sendScore(event.target.id, "down", "Un-Checked!") } } }) } - handleChangeDailys(event: any){ + + + handleChangeDailys(event: any) { this.state.tasks.dailys.forEach((element: any) => { - if(element.id == event.target.id){ - if(element.id == event.target.id){ - if(!element.completed){ - this.sendScore(event.target.id,"up", "Checked!") + if (element.id == event.target.id) { + if (element.id == event.target.id) { + if (!element.completed) { + this.sendScore(event.target.id, "up", "Checked!") } else { - this.sendScore(event.target.id,"down", "Un-Checked!") + this.sendScore(event.target.id, "down", "Un-Checked!") } } } }) } - handleChangeHabits(event: any){ + handleChangeHabits(event: any) { const target_id = event.target.id.slice(4) - if(event.target.id.slice(0,4) == "plus"){ + if (event.target.id.slice(0, 4) == "plus") { this.state.tasks.habits.forEach((element: any) => { - if(element.id == target_id){ - this.sendScore(target_id,"up", "Plus!") + if (element.id == target_id) { + this.sendScore(target_id, "up", "Plus!") } }) } else { this.state.tasks.habits.forEach((element: any) => { - if(element.id == target_id){ - this.sendScore(target_id,"down", "Minus :(") + if (element.id == target_id) { + this.sendScore(target_id, "down", "Minus :(") } }) } } - - render(){ + handleChangeRewards(event: any) { + const target_id = event.target.id + this.state.tasks.rewards.forEach((element: any) => { + if (element.id == event.target.id) { + if (element.id == target_id) { + this.sendReward(target_id, "down", "Cost!") + } + } + }) + } + render() { let content = this.CheckCron(this.state.user_data.lastCron); - if(this.state.error) - return(
Loading....
) - else if(!this.state.isLoaded) + if (this.state.error) + return (
Loading....
) + else if (!this.state.isLoaded) return
Loading....
else { return (
- - + {content} -
+
+ +
); } } diff --git a/src/view/Components/Statsview/index.tsx b/src/view/Components/Statsview/index.tsx index f15d886..c84d10e 100644 --- a/src/view/Components/Statsview/index.tsx +++ b/src/view/Components/Statsview/index.tsx @@ -3,9 +3,11 @@ import * as React from 'react'; export default function Index(props: any) { return(
-
{props.user_data.profile.name}
-
favoriteHP: {(props.user_data.stats.hp).toPrecision(3)}
-
starLVL: {props.user_data.stats.lvl}
+ {/*
{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)}
); } \ No newline at end of file diff --git a/src/view/Components/Taskview/Habitsview/HabitItem.tsx b/src/view/Components/Taskview/Habitsview/HabitItem.tsx index fa397cc..b09c217 100644 --- a/src/view/Components/Taskview/Habitsview/HabitItem.tsx +++ b/src/view/Components/Taskview/Habitsview/HabitItem.tsx @@ -4,13 +4,14 @@ import * as React from "react"; function HabitItem(props: any) { return (
- -

- +

+
) } diff --git a/src/view/Components/Taskview/index.tsx b/src/view/Components/Taskview/index.tsx index 9546979..64898b2 100644 --- a/src/view/Components/Taskview/index.tsx +++ b/src/view/Components/Taskview/index.tsx @@ -2,31 +2,39 @@ import * as React from "react"; import Dailiesview from "./Dailiesview" import Habitsview from "./Habitsview" import Todoview from "./Todoview" +import Rewardview from "./Rewardview" import { Tab, Tabs, TabList, TabPanel } from "react-tabs"; export default function Index(props: any){ const display =
- - task_alt - + today + + add_chart + - add_circle_outline + assignment_turned_in + + + account_balance - - - + + + + + +
return(display); diff --git a/src/view/habiticaAPI.ts b/src/view/habiticaAPI.ts index 142a923..478211b 100644 --- a/src/view/habiticaAPI.ts +++ b/src/view/habiticaAPI.ts @@ -39,4 +39,18 @@ export async function makeCronReq(username: string, credentials: string){ } }) return(response) -} \ No newline at end of file +} + +export async function costReward(username: string, credentials: string, taskID: string, direction: string) { + const url = "https://habitica.com/api/v4/tasks/".concat(taskID).concat("/score/").concat(direction) + const response = fetch(url, { + method: 'POST', + headers: { + "Content-Type": "application/json", + "x-client": "278e719e-5f9c-43b1-9dba-8b73343dc062-HabiticaSync", + "x-api-user": username, + "x-api-key": credentials, + } + }) + return(response) +} diff --git a/styles.css b/styles.css index b31b4a2..f2c7e5c 100644 --- a/styles.css +++ b/styles.css @@ -1,3 +1,8 @@ +* { + margin: 0; + padding: 0; +} + #profile-name { font-size: x-large; @@ -5,7 +10,8 @@ padding-bottom: 3%; } .stats { - padding-bottom: 6px; + display: flex; + justify-content: space-between; } .todo-item { @@ -13,25 +19,38 @@ justify-content: flex-start; align-items: center; padding: 0px 0px 0; - width: 80%; + width: 100%; border-bottom: 1px solid #cecece; font-family: Roboto, sans-serif; font-weight: normal; 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; +} + + .habit-text { - text-align: center !important; + text-align: left !important; padding: 0px; - width: 50%; + width: 80%; margin-right: 20px; } .habit-plus { /* background-color: #fff; */ border: none; - color: white; - padding: 7px 10px; + color: black; + padding: 7px 5px; text-align: center; text-decoration: none; font-size: 16px; @@ -41,8 +60,8 @@ /* background-color: #fff; */ /* border-radius: 50%; */ border: none; - color: white; - padding: 7px 10px; + color: black; + padding: 7px 5px; text-align: center; text-decoration: none; font-size: 16px; @@ -70,8 +89,19 @@ 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: 93% 5% 2%; + height: inherit; } .substats { @@ -144,6 +174,7 @@ input[type=checkbox]:focus { .react-tabs__tab-panel { display: none; + left: 0px; } .react-tabs__tab-panel--selected { From 9b15bb12361904af9a504f2457b36a1142e8eaa9 Mon Sep 17 00:00:00 2001 From: kkzzhizhou <806508401@qq.com> Date: Sat, 20 Nov 2021 13:49:24 +0800 Subject: [PATCH 02/16] add Rewardview Panel --- .gitignore | 3 +++ .hotreload | 0 .../Taskview/Rewardview/RewardItem.tsx | 13 ++++++++++++ .../Components/Taskview/Rewardview/index.tsx | 21 +++++++++++++++++++ 4 files changed, 37 insertions(+) create mode 100644 .hotreload create mode 100644 src/view/Components/Taskview/Rewardview/RewardItem.tsx create mode 100644 src/view/Components/Taskview/Rewardview/index.tsx diff --git a/.gitignore b/.gitignore index f36d0a2..de7c3d1 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,9 @@ node_modules package-lock.json +# yarn +yarn.lock + *.js.map diff --git a/.hotreload b/.hotreload new file mode 100644 index 0000000..e69de29 diff --git a/src/view/Components/Taskview/Rewardview/RewardItem.tsx b/src/view/Components/Taskview/Rewardview/RewardItem.tsx new file mode 100644 index 0000000..0a23b2d --- /dev/null +++ b/src/view/Components/Taskview/Rewardview/RewardItem.tsx @@ -0,0 +1,13 @@ +import Emoji from "react-emoji-render"; +import * as React from "react"; + +function RewardItem(props: any) { + return ( +
+ +

+
+ ) +} + +export default RewardItem \ No newline at end of file diff --git a/src/view/Components/Taskview/Rewardview/index.tsx b/src/view/Components/Taskview/Rewardview/index.tsx new file mode 100644 index 0000000..6ef7a61 --- /dev/null +++ b/src/view/Components/Taskview/Rewardview/index.tsx @@ -0,0 +1,21 @@ +import * as React from "react"; +import RewardItem from "./RewardItem" + +export default function Index(props: any){ + if(props.rewards == undefined) { + return (
+ No Rewards present. +
) + } + else { + const allRewards = props.rewards.map((reward: any) => { + return + }) + const display =
+
    {allRewards}
+
+ + return(display); + } +} + From e45182547f1993b15a1648632ff378cb5969ebad Mon Sep 17 00:00:00 2001 From: kkzzhizhou <806508401@qq.com> Date: Sat, 20 Nov 2021 17:11:13 +0800 Subject: [PATCH 03/16] add markdown render --- package.json | 5 ++++- src/main.ts | 7 +++++-- src/view.tsx | 7 +++---- src/view/App.tsx | 13 ++++++++----- .../Components/Taskview/Dailiesview/DailyItem.tsx | 9 +++++++-- src/view/Components/Taskview/Dailiesview/index.tsx | 4 ++-- .../Components/Taskview/Habitsview/HabitItem.tsx | 7 +++++-- src/view/Components/Taskview/Habitsview/index.tsx | 2 +- .../Components/Taskview/Rewardview/RewardItem.tsx | 6 +++++- src/view/Components/Taskview/Rewardview/index.tsx | 2 +- src/view/Components/Taskview/TodoItem.tsx | 2 +- src/view/Components/Taskview/Todoview/TodoItem.tsx | 7 ++++++- src/view/Components/Taskview/Todoview/index.tsx | 4 ++-- styles.css | 6 +++--- 14 files changed, 53 insertions(+), 28 deletions(-) diff --git a/package.json b/package.json index 344ca09..174f5f6 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,8 @@ "main": "main.js", "scripts": { "dev": "rollup --config rollup.config.js -w", - "build": "rollup --config rollup.config.js --environment BUILD:production" + "build": "rollup --config rollup.config.js --environment BUILD:production", + "dev2": "obsidian-plugin dev src/main.ts" }, "keywords": [], "author": "Leonard and Ran", @@ -21,6 +22,7 @@ "css-loader": "^6.4.0", "extract-text-webpack-plugin": "^2.1.2", "obsidian": "^0.12.0", + "obsidian-plugin-cli": "^0.4.3", "rollup": "^2.32.1", "style-loader": "^3.3.0", "tslib": "^2.2.0", @@ -32,6 +34,7 @@ "react": "^17.0.2", "react-dom": "^17.0.2", "react-emoji-render": "^1.2.4", + "react-markdown": "^7.1.0", "react-tabs": "^3.2.2" } } diff --git a/src/main.ts b/src/main.ts index 7e628b9..7fdc89b 100644 --- a/src/main.ts +++ b/src/main.ts @@ -15,7 +15,7 @@ export default class HabiticaSync extends Plugin { view: HabiticaSyncView; async onload() { - console.log("正在加载habitica-sync") + console.log("load plugin: habitica-sync") await this.loadSettings(); this.addSettingTab(new HabiticaSyncSettingsTab(this.app, this)); this.registerView( @@ -33,6 +33,8 @@ export default class HabiticaSync extends Plugin { this.activateView(); } }); + this.activateView(); + } async loadSettings() { this.settings = Object.assign(DEFAULT_SETTINGS, await this.loadData()) @@ -40,9 +42,10 @@ export default class HabiticaSync extends Plugin { async saveSettings() { await this.saveData(this.settings); } + async onunload() { // await this.view.onClose(); - + this.app.workspace .getLeavesOfType(VIEW_TYPE) .forEach((leaf) => leaf.detach()); diff --git a/src/view.tsx b/src/view.tsx index 827b893..be66720 100644 --- a/src/view.tsx +++ b/src/view.tsx @@ -31,8 +31,7 @@ export class HabiticaSyncView extends ItemView { this.containerEl.children[1] ) } - - // async onClose(){ - // ReactDOM.unmountComponentAtNode(this.containerEl.children[1]); - // } + async onClose(){ + ReactDOM.unmountComponentAtNode(this.containerEl.children[1]); + } } \ No newline at end of file diff --git a/src/view/App.tsx b/src/view/App.tsx index e456b0b..36879c9 100644 --- a/src/view/App.tsx +++ b/src/view/App.tsx @@ -51,12 +51,15 @@ class App extends React.Component { let cronDate = new Date(lastCron); let now = new Date(); if (cronDate.getDate() != now.getDate() || (cronDate.getMonth() != now.getMonth() || cronDate.getFullYear() != now.getFullYear())) { + // return ( + //
+ //
Welcome back! Please check your tasks for the last day and hit continue to get your daily rewards.
+ // + //
+ // ); return ( -
-
Welcome back! Please check your tasks for the last day and hit continue to get your daily rewards.
- -
- ); +
+ ) } else { return null diff --git a/src/view/Components/Taskview/Dailiesview/DailyItem.tsx b/src/view/Components/Taskview/Dailiesview/DailyItem.tsx index d2d308e..741eb8c 100644 --- a/src/view/Components/Taskview/Dailiesview/DailyItem.tsx +++ b/src/view/Components/Taskview/Dailiesview/DailyItem.tsx @@ -1,11 +1,16 @@ import Emoji from "react-emoji-render"; import * as React from "react"; +import ReactMarkdown from "react-markdown"; function DailyItem(props: any) { return (
- -

+ +
+

+ +
+
) } diff --git a/src/view/Components/Taskview/Dailiesview/index.tsx b/src/view/Components/Taskview/Dailiesview/index.tsx index 0d0f192..e45c421 100644 --- a/src/view/Components/Taskview/Dailiesview/index.tsx +++ b/src/view/Components/Taskview/Dailiesview/index.tsx @@ -9,11 +9,11 @@ export default function Index(props: any){ else { const incompleteDailies = props.dailys.map((daily: any) => { if(!daily.completed) - return + return }) const completedDailies = props.dailys.map((daily: any) => { if(daily.completed) - return + return }) const display =
diff --git a/src/view/Components/Taskview/Habitsview/HabitItem.tsx b/src/view/Components/Taskview/Habitsview/HabitItem.tsx index b09c217..f458752 100644 --- a/src/view/Components/Taskview/Habitsview/HabitItem.tsx +++ b/src/view/Components/Taskview/Habitsview/HabitItem.tsx @@ -1,5 +1,6 @@ import Emoji from "react-emoji-render"; import * as React from "react"; +import ReactMarkdown from "react-markdown"; function HabitItem(props: any) { return ( @@ -10,8 +11,10 @@ function HabitItem(props: any) { -

- +
+

+ +
) } diff --git a/src/view/Components/Taskview/Habitsview/index.tsx b/src/view/Components/Taskview/Habitsview/index.tsx index dc322bb..1ee9eab 100644 --- a/src/view/Components/Taskview/Habitsview/index.tsx +++ b/src/view/Components/Taskview/Habitsview/index.tsx @@ -9,7 +9,7 @@ export default function Index(props: any){ } else { const allHabits = props.habits.map((habit: any) => { - return + return }) const display =
    {allHabits}
diff --git a/src/view/Components/Taskview/Rewardview/RewardItem.tsx b/src/view/Components/Taskview/Rewardview/RewardItem.tsx index 0a23b2d..0d86c01 100644 --- a/src/view/Components/Taskview/Rewardview/RewardItem.tsx +++ b/src/view/Components/Taskview/Rewardview/RewardItem.tsx @@ -1,11 +1,15 @@ import Emoji from "react-emoji-render"; import * as React from "react"; - +import ReactMarkdown from "react-markdown"; function RewardItem(props: any) { return (
+

+ +
+
) } diff --git a/src/view/Components/Taskview/Rewardview/index.tsx b/src/view/Components/Taskview/Rewardview/index.tsx index 6ef7a61..ff60917 100644 --- a/src/view/Components/Taskview/Rewardview/index.tsx +++ b/src/view/Components/Taskview/Rewardview/index.tsx @@ -9,7 +9,7 @@ export default function Index(props: any){ } else { const allRewards = props.rewards.map((reward: any) => { - return + return }) const display =
    {allRewards}
diff --git a/src/view/Components/Taskview/TodoItem.tsx b/src/view/Components/Taskview/TodoItem.tsx index c02e230..586fdc9 100644 --- a/src/view/Components/Taskview/TodoItem.tsx +++ b/src/view/Components/Taskview/TodoItem.tsx @@ -5,7 +5,7 @@ function TodoItem(props: any) { return (
- +
) } diff --git a/src/view/Components/Taskview/Todoview/TodoItem.tsx b/src/view/Components/Taskview/Todoview/TodoItem.tsx index 2766dbe..92b3d7f 100644 --- a/src/view/Components/Taskview/Todoview/TodoItem.tsx +++ b/src/view/Components/Taskview/Todoview/TodoItem.tsx @@ -1,11 +1,16 @@ import Emoji from "react-emoji-render"; import * as React from "react"; +import ReactMarkdown from "react-markdown"; function TodoItem(props: any) { return (
-

+ {/*

*/} +
+

+ +
) } diff --git a/src/view/Components/Taskview/Todoview/index.tsx b/src/view/Components/Taskview/Todoview/index.tsx index 7ce2edf..ec61448 100644 --- a/src/view/Components/Taskview/Todoview/index.tsx +++ b/src/view/Components/Taskview/Todoview/index.tsx @@ -9,11 +9,11 @@ export default function Index(props: any){ else { const incompleteTodos = props.todos.map((todo: any) => { if(!todo.completed) - return + return }) const completedTodos = props.todos.map((todo: any) => { if(todo.completed) - return + return }) const display =
diff --git a/styles.css b/styles.css index f2c7e5c..10a2bd6 100644 --- a/styles.css +++ b/styles.css @@ -1,5 +1,5 @@ * { - margin: 0; + /* margin: 0; */ padding: 0; } @@ -49,7 +49,7 @@ .habit-plus { /* background-color: #fff; */ border: none; - color: black; + /* color: black; */ padding: 7px 5px; text-align: center; text-decoration: none; @@ -60,7 +60,7 @@ /* background-color: #fff; */ /* border-radius: 50%; */ border: none; - color: black; + /* color: black; */ padding: 7px 5px; text-align: center; text-decoration: none; From d10a2ca747c1ada5e255bef6d39eddc45b0dcf26 Mon Sep 17 00:00:00 2001 From: Zain Date: Sun, 21 Nov 2021 12:17:46 +0530 Subject: [PATCH 04/16] Fixed cron and minor CSS tweaks --- src/view/App.tsx | 15 ++++++--------- styles.css | 31 +++++++++++++++++-------------- 2 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/view/App.tsx b/src/view/App.tsx index 36879c9..616beed 100644 --- a/src/view/App.tsx +++ b/src/view/App.tsx @@ -51,15 +51,12 @@ class App extends React.Component { let cronDate = new Date(lastCron); let now = new Date(); if (cronDate.getDate() != now.getDate() || (cronDate.getMonth() != now.getMonth() || cronDate.getFullYear() != now.getFullYear())) { - // return ( - //
- //
Welcome back! Please check your tasks for the last day and hit continue to get your daily rewards.
- // - //
- // ); return ( -
- ) +
+
Welcome back! Please check your tasks for the last day and hit continue to get your daily rewards.
+ +
+ ); } else { return null @@ -196,9 +193,9 @@ class App extends React.Component { return
Loading....
else { return (
+ {content} - {content}
diff --git a/styles.css b/styles.css index 10a2bd6..99bb4b5 100644 --- a/styles.css +++ b/styles.css @@ -1,14 +1,3 @@ -* { - /* margin: 0; */ - padding: 0; -} - - -#profile-name { - font-size: x-large; - font-weight: bold; - padding-bottom: 3%; -} .stats { display: flex; justify-content: space-between; @@ -42,7 +31,6 @@ .habit-text { text-align: left !important; padding: 0px; - width: 80%; margin-right: 20px; } @@ -51,6 +39,7 @@ border: none; /* color: black; */ padding: 7px 5px; + width: 40px; text-align: center; text-decoration: none; font-size: 16px; @@ -65,6 +54,7 @@ text-align: center; text-decoration: none; font-size: 16px; + width: 40px; } .habit-item { @@ -100,7 +90,6 @@ input[type=checkbox]:focus { .plugin-root { min-width: 260px; display: grid; - grid-template-rows: 93% 5% 2%; height: inherit; } @@ -195,6 +184,7 @@ body > div.app-container.is-left-sidedock-collapsed.is-right-sidedock-collapsed margin-bottom: 5px; } .cron { + height: fit-content; display: inline-grid; justify-content: center; text-align: center;; @@ -202,7 +192,7 @@ 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-secondary-alt); + background-color: var(--background-primary-alt); border-radius: 10px; } #cronMessage { @@ -210,3 +200,16 @@ body > div.app-container.is-left-sidedock-collapsed.is-right-sidedock-collapsed margin-bottom: 10px; 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 From 54e6000eb8811968a7e3082a4995c6e40f96654e Mon Sep 17 00:00:00 2001 From: Zain Date: Sun, 21 Nov 2021 12:47:21 +0530 Subject: [PATCH 05/16] Fixed empty space at the bottom, fixed warning at main.ts --- src/main.ts | 4 ++-- src/view/App.tsx | 1 - styles.css | 1 + 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main.ts b/src/main.ts index 7fdc89b..193f9f1 100644 --- a/src/main.ts +++ b/src/main.ts @@ -33,7 +33,7 @@ export default class HabiticaSync extends Plugin { this.activateView(); } }); - this.activateView(); + // this.activateView(); } async loadSettings() { @@ -44,7 +44,7 @@ export default class HabiticaSync extends Plugin { } async onunload() { - // await this.view.onClose(); + await this.view.onClose(); this.app.workspace .getLeavesOfType(VIEW_TYPE) diff --git a/src/view/App.tsx b/src/view/App.tsx index 616beed..080bd70 100644 --- a/src/view/App.tsx +++ b/src/view/App.tsx @@ -196,7 +196,6 @@ class App extends React.Component { {content} -
); diff --git a/styles.css b/styles.css index 99bb4b5..c0feb7f 100644 --- a/styles.css +++ b/styles.css @@ -90,6 +90,7 @@ input[type=checkbox]:focus { .plugin-root { min-width: 260px; display: grid; + grid-template-rows: auto 1fr auto; height: inherit; } From 6384c98181cfc3f61fa8891a11591fefcea8c915 Mon Sep 17 00:00:00 2001 From: ransurf Date: Sat, 20 Nov 2021 23:39:09 -0800 Subject: [PATCH 06/16] Added "Show Task Description" Setting --- src/main.ts | 1 + src/settings.ts | 13 +++++++++++++ src/view/App.tsx | 2 +- src/view/Components/Taskview/Dailiesview/index.tsx | 6 +++++- src/view/Components/Taskview/Habitsview/index.tsx | 4 ++++ src/view/Components/Taskview/Rewardview/index.tsx | 6 +++++- src/view/Components/Taskview/Todoview/index.tsx | 10 ++++++++-- src/view/Components/Taskview/index.tsx | 8 ++++---- 8 files changed, 41 insertions(+), 9 deletions(-) diff --git a/src/main.ts b/src/main.ts index 7fdc89b..45e1054 100644 --- a/src/main.ts +++ b/src/main.ts @@ -5,6 +5,7 @@ import { HabiticaSyncView, VIEW_TYPE} from "./view" interface HabiticaSyncSettings { userID: string apiToken: string + showTaskDescription: boolean } const DEFAULT_SETTINGS: Partial = { userID: "", diff --git a/src/settings.ts b/src/settings.ts index bd298e5..6957237 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -38,5 +38,18 @@ export class HabiticaSyncSettingsTab extends PluginSettingTab { await this.plugin.saveSettings(); }) ); + + new Setting(containerEl) + .setName("Show Task Descriptions") + .setDesc("Updates require pane re-opening") + .addToggle(cb => { + cb + .setValue(this.plugin.settings.showTaskDescription) + .onChange(async (isEnable) => { + this.plugin.settings.showTaskDescription = isEnable; + await this.plugin.saveSettings(); + }) + }); + } } \ No newline at end of file diff --git a/src/view/App.tsx b/src/view/App.tsx index 616beed..445268e 100644 --- a/src/view/App.tsx +++ b/src/view/App.tsx @@ -195,7 +195,7 @@ class App extends React.Component { return (
{content} - +
diff --git a/src/view/Components/Taskview/Dailiesview/index.tsx b/src/view/Components/Taskview/Dailiesview/index.tsx index e45c421..9faafc2 100644 --- a/src/view/Components/Taskview/Dailiesview/index.tsx +++ b/src/view/Components/Taskview/Dailiesview/index.tsx @@ -9,8 +9,12 @@ export default function Index(props: any){ else { const incompleteDailies = props.dailys.map((daily: any) => { if(!daily.completed) + if (props.settings.showTaskDescription) { return - }) + } else { + return + } + }) const completedDailies = props.dailys.map((daily: any) => { if(daily.completed) return diff --git a/src/view/Components/Taskview/Habitsview/index.tsx b/src/view/Components/Taskview/Habitsview/index.tsx index 1ee9eab..1d0107c 100644 --- a/src/view/Components/Taskview/Habitsview/index.tsx +++ b/src/view/Components/Taskview/Habitsview/index.tsx @@ -9,7 +9,11 @@ export default function Index(props: any){ } else { const allHabits = props.habits.map((habit: any) => { + if (props.settings.showTaskDescription) { return + } else { + return + } }) const display =
    {allHabits}
diff --git a/src/view/Components/Taskview/Rewardview/index.tsx b/src/view/Components/Taskview/Rewardview/index.tsx index ff60917..4ddc21a 100644 --- a/src/view/Components/Taskview/Rewardview/index.tsx +++ b/src/view/Components/Taskview/Rewardview/index.tsx @@ -9,7 +9,11 @@ export default function Index(props: any){ } else { const allRewards = props.rewards.map((reward: any) => { - return + if (props.settings.showTaskDescription) { + return + } else { + return + } }) const display =
    {allRewards}
diff --git a/src/view/Components/Taskview/Todoview/index.tsx b/src/view/Components/Taskview/Todoview/index.tsx index ec61448..4f8c4e9 100644 --- a/src/view/Components/Taskview/Todoview/index.tsx +++ b/src/view/Components/Taskview/Todoview/index.tsx @@ -8,8 +8,14 @@ export default function Index(props: any){ } else { const incompleteTodos = props.todos.map((todo: any) => { - if(!todo.completed) - return + if(!todo.completed) { + if (props.settings.showTaskDescription) { + return + } else { + return + } + } + }) const completedTodos = props.todos.map((todo: any) => { if(todo.completed) diff --git a/src/view/Components/Taskview/index.tsx b/src/view/Components/Taskview/index.tsx index 64898b2..7001ac9 100644 --- a/src/view/Components/Taskview/index.tsx +++ b/src/view/Components/Taskview/index.tsx @@ -24,16 +24,16 @@ export default function Index(props: any){ - + - + - + - +
From 6865d4f080abb7308631d01b88a160829f2c1bc5 Mon Sep 17 00:00:00 2001 From: Zain Date: Sun, 21 Nov 2021 13:18:07 +0530 Subject: [PATCH 07/16] Fixed merge conflict error made by Ran lol --- src/view/App.tsx | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/view/App.tsx b/src/view/App.tsx index f81736f..7ca62c3 100644 --- a/src/view/App.tsx +++ b/src/view/App.tsx @@ -195,12 +195,7 @@ class App extends React.Component { return (
{content} -<<<<<<< HEAD -
-======= - ->>>>>>> 54e6000eb8811968a7e3082a4995c6e40f96654e
); From 0ac05ef6d399625b70bf2d1e88615f1215623d56 Mon Sep 17 00:00:00 2001 From: ransurf <80801637+ransurf@users.noreply.github.com> Date: Sun, 21 Nov 2021 02:14:41 -0600 Subject: [PATCH 08/16] Update README.md --- README.md | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index ce90528..ffd8731 100644 --- a/README.md +++ b/README.md @@ -9,26 +9,32 @@ The plugin's view is enabled by clicking on the "Open Habitica Pane" option in t To sync your Habitica account, go to the settings page of the plugin and enter your user ID and API token credentials. ## Features ### Pane View -#### View HP, XP, todos, dailies, and habits [![Image from Gyazo](https://i.gyazo.com/4266d01941e71fef41819ea8a6b6592e.png)](https://gyazo.com/4266d01941e71fef41819ea8a6b6592e) [![Image from Gyazo](https://i.gyazo.com/697a58b8e7ffd3df86a2944b6abbaa92.png)](https://gyazo.com/697a58b8e7ffd3df86a2944b6abbaa92) -- Tab for active/completed tasks +- View stats (HP, XP, coins) +- View to do's, dailies, and habits + - Tab for active/completed tasks and dailies #### Check off tasks/dailies in the view, modify habit counters (+/-) [![Image from Gyazo](https://i.gyazo.com/5759e12bc5267711c5e03485a6d72c2f.gif)](https://gyazo.com/5759e12bc5267711c5e03485a6d72c2f) - Can uncheck completed habits/todos as shown above ## Settings + +The following two inputs help fetch your user data to be displayed in the Obsidian view: - **Habitica User ID:** You can find this by clicking on the "User" icon in the top right of the Habitica webapp, "Settings", then "API" - **Habitica Token API:** You can find this by clicking on the "User" icon in the top right of the Habitica webapp, "Settings", then "API" -The following two inputs help fetch your user data to be displayed in the Obsidian view. + +**Show Task Descriptions:** Toggles whether description/notes for tasks will be shown or not + + ## Roadmap We will be implementing additional features including: - Add/delete/customize tasks and habits -- View/claim rewards *Feel free to support us and donate!* Buy Me a Coffee at ko-fi.com + From 916236db5d6c5822dc69d13e2c08d60196fb1672 Mon Sep 17 00:00:00 2001 From: ransurf Date: Thu, 13 Jan 2022 12:47:36 -0800 Subject: [PATCH 09/16] 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; +} From 88fdde519dbaae4f7e919d6b4fbd07776deea20a Mon Sep 17 00:00:00 2001 From: SuperChamp234 Date: Fri, 14 Jan 2022 14:39:21 +0530 Subject: [PATCH 10/16] Added a wrapper Markdown Rendered to render BOTH Emojis and Mardown as HTML --- package.json | 11 ++++++++++- rollup.config.js | 2 ++ src/main.ts | 3 +-- src/view/App.tsx | 1 + .../Taskview/Dailiesview/DailyItem.tsx | 9 +++++---- .../Taskview/Dailiesview/DailySubTasks.tsx | 6 ++++-- .../Taskview/Habitsview/HabitItem.tsx | 9 +++++---- .../Taskview/Rewardview/RewardItem.tsx | 10 ++++++---- src/view/Components/Taskview/TodoItem.tsx | 13 ------------- .../Components/Taskview/Todoview/TodoItem.tsx | 10 +++++----- .../Taskview/Todoview/TodoSubTasks.tsx | 5 +++-- src/view/Components/Taskview/Todoview/index.tsx | 2 +- src/view/Components/Taskview/Todoview/tabs.ts | 1 - src/view/Components/Taskview/index.tsx | 2 +- src/view/Components/Taskview/markdownRender.ts | 17 +++++++++++++++++ styles.css | 4 +++- tsconfig.json | 1 + 17 files changed, 65 insertions(+), 41 deletions(-) delete mode 100644 src/view/Components/Taskview/TodoItem.tsx delete mode 100644 src/view/Components/Taskview/Todoview/tabs.ts create mode 100644 src/view/Components/Taskview/markdownRender.ts diff --git a/package.json b/package.json index 174f5f6..7dbcea4 100644 --- a/package.json +++ b/package.json @@ -13,12 +13,17 @@ "license": "MIT", "devDependencies": { "@rollup/plugin-commonjs": "^18.0.0", + "@rollup/plugin-json": "^4.1.0", "@rollup/plugin-node-resolve": "^11.2.1", "@rollup/plugin-typescript": "^8.2.1", + "@types/markdown-it": "^12.2.3", + "@types/markdown-it-emoji": "^2.0.2", "@types/node": "^14.14.37", + "@types/node-emoji": "^1.8.1", "@types/react": "^17.0.27", "@types/react-dom": "^17.0.9", "@types/react-tabs": "^2.3.3", + "@types/twemoji": "^12.1.2", "css-loader": "^6.4.0", "extract-text-webpack-plugin": "^2.1.2", "obsidian": "^0.12.0", @@ -29,12 +34,16 @@ "typescript": "^4.2.4" }, "dependencies": { + "markdown-it": "^12.3.2", + "markdown-it-emoji": "^2.0.0", "node": "^16.10.0", + "node-emoji": "^1.11.0", "node-fetch": "^3.0.0", "react": "^17.0.2", "react-dom": "^17.0.2", "react-emoji-render": "^1.2.4", "react-markdown": "^7.1.0", - "react-tabs": "^3.2.2" + "react-tabs": "^3.2.2", + "twemoji": "^13.1.0" } } diff --git a/rollup.config.js b/rollup.config.js index 8e28e8d..6da9767 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -1,6 +1,7 @@ import typescript from '@rollup/plugin-typescript'; import {nodeResolve} from '@rollup/plugin-node-resolve'; import commonjs from '@rollup/plugin-commonjs'; +import json from '@rollup/plugin-json'; const isProd = (process.env.BUILD === 'production'); @@ -26,5 +27,6 @@ export default { typescript(), nodeResolve({browser: true}), commonjs(), + json(), ] }; \ No newline at end of file diff --git a/src/main.ts b/src/main.ts index 5b370f7..5677142 100644 --- a/src/main.ts +++ b/src/main.ts @@ -24,7 +24,7 @@ export default class HabiticaSync extends Plugin { VIEW_TYPE, (leaf) => (new HabiticaSyncView(leaf, this)) ); - this.addRibbonIcon("popup-open", "Open Habitica Pane", () => { //activate view + this.addRibbonIcon("popup-open", "Open Habitica Pane", () => { this.activateView(); }); this.addCommand({ @@ -35,7 +35,6 @@ export default class HabiticaSync extends Plugin { this.activateView(); } }); - // this.activateView(); } async loadSettings() { diff --git a/src/view/App.tsx b/src/view/App.tsx index 2f0abc5..149304c 100644 --- a/src/view/App.tsx +++ b/src/view/App.tsx @@ -83,6 +83,7 @@ class App extends React.Component { new Notice('Login Failed, Please check credentials and try again!'); } else { + console.log(result); this.setState({ isLoaded: true, user_data: result, diff --git a/src/view/Components/Taskview/Dailiesview/DailyItem.tsx b/src/view/Components/Taskview/Dailiesview/DailyItem.tsx index d5b2a93..a59d02c 100644 --- a/src/view/Components/Taskview/Dailiesview/DailyItem.tsx +++ b/src/view/Components/Taskview/Dailiesview/DailyItem.tsx @@ -1,15 +1,16 @@ -import Emoji from "react-emoji-render"; import * as React from "react"; -import ReactMarkdown from "react-markdown"; import DailySubTasks from "./DailySubTasks"; +import renderMarkdown from "../markdownRender"; function DailyItem(props: any) { + var text_html = renderMarkdown(props.daily_text); + var note_html = renderMarkdown(props.daily_notes); return (
-

- +

+
{console.log(props.checklist)}
diff --git a/src/view/Components/Taskview/Dailiesview/DailySubTasks.tsx b/src/view/Components/Taskview/Dailiesview/DailySubTasks.tsx index 63d97d2..cd30f13 100644 --- a/src/view/Components/Taskview/Dailiesview/DailySubTasks.tsx +++ b/src/view/Components/Taskview/Dailiesview/DailySubTasks.tsx @@ -1,13 +1,15 @@ -import Emoji from "react-emoji-render"; import * as React from "react"; +import renderMarkdown from "../markdownRender"; function DailySubTasks(props: any) { + if (props.subtasks) { const subtasks = props.subtasks.map((subtask: any) => { + let subtask_text = renderMarkdown(subtask.text); return (
-

+

) }); diff --git a/src/view/Components/Taskview/Habitsview/HabitItem.tsx b/src/view/Components/Taskview/Habitsview/HabitItem.tsx index 557adf6..37d672c 100644 --- a/src/view/Components/Taskview/Habitsview/HabitItem.tsx +++ b/src/view/Components/Taskview/Habitsview/HabitItem.tsx @@ -1,8 +1,9 @@ -import Emoji from "react-emoji-render"; import * as React from "react"; -import ReactMarkdown from "react-markdown"; +import renderMarkdown from "../markdownRender"; function HabitItem(props: any) { + let habit_text = renderMarkdown(props.habit_text); + let habit_notes = renderMarkdown(props.habit_notes); return (
@@ -14,8 +15,8 @@ function HabitItem(props: any) {
-

- +

+
) diff --git a/src/view/Components/Taskview/Rewardview/RewardItem.tsx b/src/view/Components/Taskview/Rewardview/RewardItem.tsx index 983c909..5f331e2 100644 --- a/src/view/Components/Taskview/Rewardview/RewardItem.tsx +++ b/src/view/Components/Taskview/Rewardview/RewardItem.tsx @@ -1,15 +1,17 @@ -import Emoji from "react-emoji-render"; import * as React from "react"; -import ReactMarkdown from "react-markdown"; +import renderMarkdown from "../markdownRender"; + function RewardItem(props: any) { + let reward_text = renderMarkdown(props.reward_text); + let reward_notes = renderMarkdown(props.reward_notes); return (
-

- +

+
diff --git a/src/view/Components/Taskview/TodoItem.tsx b/src/view/Components/Taskview/TodoItem.tsx deleted file mode 100644 index 586fdc9..0000000 --- a/src/view/Components/Taskview/TodoItem.tsx +++ /dev/null @@ -1,13 +0,0 @@ -import { Emoji } from 'react-emoji-render'; -import * as React from "react"; - -function TodoItem(props: any) { - return ( -
- - -
- ) -} - -export default TodoItem \ No newline at end of file diff --git a/src/view/Components/Taskview/Todoview/TodoItem.tsx b/src/view/Components/Taskview/Todoview/TodoItem.tsx index 4c31505..0843657 100644 --- a/src/view/Components/Taskview/Todoview/TodoItem.tsx +++ b/src/view/Components/Taskview/Todoview/TodoItem.tsx @@ -1,16 +1,16 @@ -import Emoji from "react-emoji-render"; import * as React from "react"; -import ReactMarkdown from "react-markdown"; import TodoSubTasks from "./TodoSubTasks"; +import renderMarkdown from "../markdownRender" function TodoItem(props: any) { + var text_html = renderMarkdown(props.todo_text); + var note_html = renderMarkdown(props.todo_notes); return (
- {/*

*/}
-

- +

+
diff --git a/src/view/Components/Taskview/Todoview/TodoSubTasks.tsx b/src/view/Components/Taskview/Todoview/TodoSubTasks.tsx index 79c7161..ef74d92 100644 --- a/src/view/Components/Taskview/Todoview/TodoSubTasks.tsx +++ b/src/view/Components/Taskview/Todoview/TodoSubTasks.tsx @@ -1,13 +1,14 @@ -import Emoji from "react-emoji-render"; import * as React from "react"; +import renderMarkdown from "../markdownRender"; function TodoSubTasks(props: any) { if (props.subtasks) { const subtasks = props.subtasks.map((subtask: any) => { + let subtask_text = renderMarkdown(subtask.text); return (
-

+

) }); diff --git a/src/view/Components/Taskview/Todoview/index.tsx b/src/view/Components/Taskview/Todoview/index.tsx index 8c1f236..682e2ef 100644 --- a/src/view/Components/Taskview/Todoview/index.tsx +++ b/src/view/Components/Taskview/Todoview/index.tsx @@ -20,7 +20,7 @@ export default function Index(props: any){ todo_subtasks = todo.checklist; } return } diff --git a/src/view/Components/Taskview/Todoview/tabs.ts b/src/view/Components/Taskview/Todoview/tabs.ts deleted file mode 100644 index 55153e7..0000000 --- a/src/view/Components/Taskview/Todoview/tabs.ts +++ /dev/null @@ -1 +0,0 @@ -import * as React from "react" diff --git a/src/view/Components/Taskview/index.tsx b/src/view/Components/Taskview/index.tsx index 7001ac9..58f95fb 100644 --- a/src/view/Components/Taskview/index.tsx +++ b/src/view/Components/Taskview/index.tsx @@ -38,5 +38,5 @@ export default function Index(props: any){
return(display); -} //yes +} diff --git a/src/view/Components/Taskview/markdownRender.ts b/src/view/Components/Taskview/markdownRender.ts new file mode 100644 index 0000000..9e95a59 --- /dev/null +++ b/src/view/Components/Taskview/markdownRender.ts @@ -0,0 +1,17 @@ +import MarkdownIt from "markdown-it"; +import markdownitEmoji from "markdown-it-emoji" +import twemoji from "twemoji"; + +export default function renderMarkdown(markdown: string) { + const md = new MarkdownIt({ + html: true, + breaks: true, + linkify: true, + typographer: true + }); + md.use(markdownitEmoji); + md.renderer.rules.emoji = function(token, idx) { + return twemoji.parse(token[idx].content); + }; + return md.render(markdown); +} \ No newline at end of file diff --git a/styles.css b/styles.css index eef70b1..118caa0 100644 --- a/styles.css +++ b/styles.css @@ -49,7 +49,6 @@ .description { font-family: Open Sans, sans-serif; - font-style: italic; font-weight: 100; } .description > ul { @@ -303,3 +302,6 @@ button { font-family: Roboto, sans-serif; justify-content: flex-start; } +.emoji { + height: 1em; +} \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index 48f3cf9..95b95d2 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -9,6 +9,7 @@ "noImplicitAny": true, "moduleResolution": "node", "importHelpers": true, + "allowSyntheticDefaultImports": true, "lib": [ "dom", "es5", From 22616cbed9acb708abb39e7ea5d3b94d9c15a169 Mon Sep 17 00:00:00 2001 From: SuperChamp234 Date: Fri, 14 Jan 2022 17:55:47 +0530 Subject: [PATCH 11/16] Commit to dev branch includes - Due date on Todos - Dailies segragation to not include non-due Dailies - Checklist-items are now working - Made a completely new wrapper for markdown+emojis, can render emojis in description as well as task name --- package.json | 1 + src/main.ts | 6 ++- src/settings.ts | 13 ++++++ src/view/App.tsx | 28 +++++++++++-- .../Taskview/Dailiesview/DailyItem.tsx | 4 +- .../Taskview/Dailiesview/DailySubTasks.tsx | 2 +- .../Components/Taskview/Dailiesview/index.tsx | 42 +++++++++++++++++-- .../Components/Taskview/Todoview/TodoItem.tsx | 5 ++- .../Taskview/Todoview/TodoSubTasks.tsx | 2 +- .../Components/Taskview/Todoview/index.tsx | 2 +- src/view/Components/Taskview/index.tsx | 4 +- src/view/habiticaAPI.ts | 14 +++++++ styles.css | 4 ++ 13 files changed, 110 insertions(+), 17 deletions(-) diff --git a/package.json b/package.json index 7dbcea4..870cee1 100644 --- a/package.json +++ b/package.json @@ -36,6 +36,7 @@ "dependencies": { "markdown-it": "^12.3.2", "markdown-it-emoji": "^2.0.0", + "moment": "^2.29.1", "node": "^16.10.0", "node-emoji": "^1.11.0", "node-fetch": "^3.0.0", diff --git a/src/main.ts b/src/main.ts index 5677142..13cae87 100644 --- a/src/main.ts +++ b/src/main.ts @@ -7,10 +7,14 @@ interface HabiticaSyncSettings { apiToken: string showTaskDescription: boolean showSubTasks: boolean + dueDateFormat: string } const DEFAULT_SETTINGS: Partial = { userID: "", - apiToken: "" + apiToken: "", + showTaskDescription: true, + showSubTasks: true, + dueDateFormat: "DD-MM-YYYY" } export default class HabiticaSync extends Plugin { settings: HabiticaSyncSettings; diff --git a/src/settings.ts b/src/settings.ts index b223be2..974fe44 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -1,5 +1,6 @@ import HabiticaSync from "./main"; import { App, PluginSettingTab, Setting } from "obsidian"; +import moment from "moment"; export class HabiticaSyncSettingsTab extends PluginSettingTab { plugin: HabiticaSync; @@ -62,6 +63,18 @@ export class HabiticaSyncSettingsTab extends PluginSettingTab { await this.plugin.saveSettings(); }) }); + new Setting(containerEl) + .setName("Due Date Format") + .setDesc("Update requires pane re-opening, check moment.js docs for formatting. Current Format: " + moment().format(this.plugin.settings.dueDateFormat)) + .addText((text) => + text + .setPlaceholder("DD-MM-YYYY") + .setValue(this.plugin.settings.dueDateFormat) + .onChange(async (value) => { + this.plugin.settings.dueDateFormat = value; + await this.plugin.saveSettings(); + }) + ); } } \ No newline at end of file diff --git a/src/view/App.tsx b/src/view/App.tsx index 149304c..fdb748d 100644 --- a/src/view/App.tsx +++ b/src/view/App.tsx @@ -1,8 +1,9 @@ import * as React from "react"; import { Notice } from "obsidian"; -import { getStats, scoreTask, makeCronReq, costReward } from "./habiticaAPI" +import { getStats, scoreTask, makeCronReq, costReward, scoreChecklistItem } from "./habiticaAPI" import Statsview from "./Components/Statsview" import Taskview from "./Components/Taskview" +import ReactDOM from "react-dom"; class App extends React.Component { private _username = ""; @@ -44,6 +45,7 @@ class App extends React.Component { this.handleChangeDailys = this.handleChangeDailys.bind(this); this.handleChangeHabits = this.handleChangeHabits.bind(this); this.handleChangeRewards = this.handleChangeRewards.bind(this); + this.handleChangeChecklistItem = this.handleChangeChecklistItem.bind(this); this.runCron = this.runCron.bind(this); } @@ -144,8 +146,6 @@ class App extends React.Component { } }) } - - handleChangeDailys(event: any) { this.state.tasks.dailys.forEach((element: any) => { if (element.id == event.target.id) { @@ -186,6 +186,26 @@ class App extends React.Component { } }) } + async handleChangeChecklistItem(event: any){ + let parentID = event.target.parentNode.parentNode.parentNode.getAttribute("id") + let targetID = event.target.id + console.log(parentID+ " , " + targetID) + try{ + let response = await scoreChecklistItem(this.username, this.credentials, targetID, parentID); + let result = await response.json(); + if (result.success === true) { + new Notice("Checked!"); + this.reloadData(); + } else { + new Notice("Resyncing, please try again"); + this.reloadData(); + } + } catch (e) { + console.log(e); + new Notice("API Error: Please check credentials") + } + } + render() { let content = this.CheckCron(this.state.user_data.lastCron); if (this.state.error) @@ -197,7 +217,7 @@ class App extends React.Component { {content} - +
); diff --git a/src/view/Components/Taskview/Dailiesview/DailyItem.tsx b/src/view/Components/Taskview/Dailiesview/DailyItem.tsx index a59d02c..ac950ee 100644 --- a/src/view/Components/Taskview/Dailiesview/DailyItem.tsx +++ b/src/view/Components/Taskview/Dailiesview/DailyItem.tsx @@ -11,8 +11,8 @@ function DailyItem(props: any) {

- {console.log(props.checklist)} - + {/* {console.log(props.checklist)} */} +
diff --git a/src/view/Components/Taskview/Dailiesview/DailySubTasks.tsx b/src/view/Components/Taskview/Dailiesview/DailySubTasks.tsx index cd30f13..71b2b09 100644 --- a/src/view/Components/Taskview/Dailiesview/DailySubTasks.tsx +++ b/src/view/Components/Taskview/Dailiesview/DailySubTasks.tsx @@ -8,7 +8,7 @@ function DailySubTasks(props: any) { let subtask_text = renderMarkdown(subtask.text); return (
- +

) diff --git a/src/view/Components/Taskview/Dailiesview/index.tsx b/src/view/Components/Taskview/Dailiesview/index.tsx index 27a988a..bf8b952 100644 --- a/src/view/Components/Taskview/Dailiesview/index.tsx +++ b/src/view/Components/Taskview/Dailiesview/index.tsx @@ -7,8 +7,24 @@ export default function Index(props: any){ return
No Dailies Present
} else { + const notDueDailies = props.dailys.map((daily: any) => { + if (!daily.isDue) { + let daily_notes = ''; + let daily_subtasks = ''; + if (props.settings.showTaskDescription) { + daily_notes = daily.notes; + } + + if (props.settings.showSubTasks) { + daily_subtasks = daily.checklist; + } + return + } + }) const incompleteDailies = props.dailys.map((daily: any) => { - if (!daily.completed) { + if (!daily.completed&&daily.isDue) { let daily_notes = ''; let daily_subtasks = ''; if (props.settings.showTaskDescription) { @@ -20,18 +36,33 @@ export default function Index(props: any){ } return + onChange={props.onChange} completed={daily.completed} onChangeChecklistItem={props.onChangeChecklistItem}/> } }) const completedDailies = props.dailys.map((daily: any) => { - if(daily.completed) - return + // if(daily.completed) + // return + if (!daily.completed) { + let daily_notes = ''; + let daily_subtasks = ''; + if (props.settings.showTaskDescription) { + daily_notes = daily.notes; + } + + if (props.settings.showSubTasks) { + daily_subtasks = daily.checklist; + } + return + } }) const display =
Active Completed + Not Due
    {incompleteDailies}
@@ -39,6 +70,9 @@ export default function Index(props: any){
    {completedDailies}
+ +
    {notDueDailies}
+
return(display); diff --git a/src/view/Components/Taskview/Todoview/TodoItem.tsx b/src/view/Components/Taskview/Todoview/TodoItem.tsx index 0843657..7c1653b 100644 --- a/src/view/Components/Taskview/Todoview/TodoItem.tsx +++ b/src/view/Components/Taskview/Todoview/TodoItem.tsx @@ -1,8 +1,10 @@ import * as React from "react"; import TodoSubTasks from "./TodoSubTasks"; import renderMarkdown from "../markdownRender" +import moment from "moment"; function TodoItem(props: any) { + var dueDate = (props.dueDate==null)?"":("Due Date:"+(moment(props.dueDate).format(props.dueDateFormat))); var text_html = renderMarkdown(props.todo_text); var note_html = renderMarkdown(props.todo_notes); return ( @@ -11,7 +13,8 @@ function TodoItem(props: any) {

- + +
{dueDate}
) diff --git a/src/view/Components/Taskview/Todoview/TodoSubTasks.tsx b/src/view/Components/Taskview/Todoview/TodoSubTasks.tsx index ef74d92..0ba83d7 100644 --- a/src/view/Components/Taskview/Todoview/TodoSubTasks.tsx +++ b/src/view/Components/Taskview/Todoview/TodoSubTasks.tsx @@ -7,7 +7,7 @@ function TodoSubTasks(props: any) { let subtask_text = renderMarkdown(subtask.text); return (
- +

) diff --git a/src/view/Components/Taskview/Todoview/index.tsx b/src/view/Components/Taskview/Todoview/index.tsx index 682e2ef..a050528 100644 --- a/src/view/Components/Taskview/Todoview/index.tsx +++ b/src/view/Components/Taskview/Todoview/index.tsx @@ -21,7 +21,7 @@ export default function Index(props: any){ } return + onChange={props.onChange} onChangeChecklistItem={props.onChangeChecklistItem} completed={todo.completed} dueDate={todo.date} dueDateFormat={props.settings.dueDateFormat}/> } }) diff --git a/src/view/Components/Taskview/index.tsx b/src/view/Components/Taskview/index.tsx index 58f95fb..06d2874 100644 --- a/src/view/Components/Taskview/index.tsx +++ b/src/view/Components/Taskview/index.tsx @@ -24,13 +24,13 @@ export default function Index(props: any){ - + - + diff --git a/src/view/habiticaAPI.ts b/src/view/habiticaAPI.ts index 478211b..eae3ab8 100644 --- a/src/view/habiticaAPI.ts +++ b/src/view/habiticaAPI.ts @@ -54,3 +54,17 @@ export async function costReward(username: string, credentials: string, taskID: }) return(response) } + +export async function scoreChecklistItem(username: string, credentials: string, checklistItemID: string, taskID: string) { + const url = "https://habitica.com/api/v3/tasks/".concat(taskID).concat("/checklist/").concat(checklistItemID).concat("/score") + const response = fetch(url, { + method: 'POST', + headers: { + "Content-Type": "application/json", + "x-client": "278e719e-5f9c-43b1-9dba-8b73343dc062-HabiticaSync", + "x-api-user": username, + "x-api-key": credentials, + } + }) + return(response) +} \ No newline at end of file diff --git a/styles.css b/styles.css index 118caa0..c265c56 100644 --- a/styles.css +++ b/styles.css @@ -304,4 +304,8 @@ button { } .emoji { height: 1em; +} +.description>ul { + list-style-type: disc; + margin-left: 10% !important; } \ No newline at end of file From 932562ab2ec676efa2183d2e84a06dc7ba070eb2 Mon Sep 17 00:00:00 2001 From: ransurf Date: Fri, 14 Jan 2022 15:53:03 -0800 Subject: [PATCH 12/16] fix flexbox issue for empty tabs --- src/view/Components/Taskview/Dailiesview/index.tsx | 8 ++++++-- styles.css | 3 ++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/view/Components/Taskview/Dailiesview/index.tsx b/src/view/Components/Taskview/Dailiesview/index.tsx index bf8b952..9785888 100644 --- a/src/view/Components/Taskview/Dailiesview/index.tsx +++ b/src/view/Components/Taskview/Dailiesview/index.tsx @@ -3,11 +3,14 @@ import DailyItem from "./DailyItem" import { Tab, Tabs, TabList, TabPanel } from "react-tabs"; export default function Index(props: any){ + if(props.dailys == undefined) { return
No Dailies Present
} else { + const notDueDailies = props.dailys.map((daily: any) => { + if (!daily.isDue) { let daily_notes = ''; let daily_subtasks = ''; @@ -23,6 +26,7 @@ export default function Index(props: any){ onChange={props.onChange} completed={daily.completed} onChangeChecklistItem={props.onChangeChecklistItem}/> } }) + const incompleteDailies = props.dailys.map((daily: any) => { if (!daily.completed&&daily.isDue) { let daily_notes = ''; @@ -42,7 +46,7 @@ export default function Index(props: any){ const completedDailies = props.dailys.map((daily: any) => { // if(daily.completed) // return - if (!daily.completed) { + if (daily.completed) { let daily_notes = ''; let daily_subtasks = ''; if (props.settings.showTaskDescription) { @@ -57,6 +61,7 @@ export default function Index(props: any){ onChange={props.onChange} completed={daily.completed} onChangeChecklistItem={props.onChangeChecklistItem}/> } }) + const display =
@@ -79,4 +84,3 @@ export default function Index(props: any){ } } - diff --git a/styles.css b/styles.css index c265c56..9cc820b 100644 --- a/styles.css +++ b/styles.css @@ -130,11 +130,12 @@ input[type=checkbox]:focus { display: flex; flex-direction: column; justify-content: flex-start; - align-items: center; + align-items: stretch; } #classDisplay { height: 100%; + width: 100%; } From e4d3c78a9feae6cfb0e05a0f977d0d966d199f86 Mon Sep 17 00:00:00 2001 From: SuperChamp234 Date: Sat, 15 Jan 2022 09:00:21 +0530 Subject: [PATCH 13/16] Small CSS changes to cron button --- styles.css | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/styles.css b/styles.css index 9cc820b..8bf78e5 100644 --- a/styles.css +++ b/styles.css @@ -295,6 +295,14 @@ button { margin-bottom: 10px; color: var(--text-normal) } +#cronButton { + margin: auto; + margin-bottom: 5px; + white-space: nowrap; + padding: 5px 5px; + color: var(--interactive-accent); + margin-right: auto; +} .subtask { display: flex; From 82780ba589a70e51d71ae62f08a9ffe4e6c08f6b Mon Sep 17 00:00:00 2001 From: SuperChamp234 Date: Sat, 15 Jan 2022 09:23:35 +0530 Subject: [PATCH 14/16] CSS changes for buttons, fixed numbers in stats --- src/view/App.tsx | 1 + src/view/Components/Statsview/index.tsx | 7 +++++-- styles.css | 10 ++++++++-- 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/view/App.tsx b/src/view/App.tsx index fdb748d..ed3e62c 100644 --- a/src/view/App.tsx +++ b/src/view/App.tsx @@ -34,6 +34,7 @@ class App extends React.Component { stats: { hp: 0, lvl: 0, + gold: 0, }, lastCron: "", }, diff --git a/src/view/Components/Statsview/index.tsx b/src/view/Components/Statsview/index.tsx index 6f5fc9e..506cae4 100644 --- a/src/view/Components/Statsview/index.tsx +++ b/src/view/Components/Statsview/index.tsx @@ -4,9 +4,12 @@ export default function Index(props: any) { return(
{/*
{props.user_data.profile.name}
*/} -
HP: {(props.user_data.stats.hp).toPrecision(3)}
+
HP: {numberWithCommas((props.user_data.stats.hp).toFixed(0))}
LEVEL: {props.user_data.stats.lvl}
-
GOLD: {(props.user_data.stats.gp).toPrecision(3)}
+
GOLD: {numberWithCommas(props.user_data.stats.gp.toFixed(2))}
); +} +function numberWithCommas(x: any) { + return x.toString().replace(/\B(? Date: Sat, 15 Jan 2022 09:45:50 +0530 Subject: [PATCH 15/16] Minor error fixes --- src/view/App.tsx | 1 - src/view/Components/Taskview/Dailiesview/DailyItem.tsx | 2 +- src/view/Components/Taskview/Dailiesview/DailySubTasks.tsx | 2 +- src/view/Components/Taskview/Todoview/TodoSubTasks.tsx | 2 +- src/view/Components/Taskview/markdownRender.ts | 4 ++++ 5 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/view/App.tsx b/src/view/App.tsx index ed3e62c..9ae5826 100644 --- a/src/view/App.tsx +++ b/src/view/App.tsx @@ -86,7 +86,6 @@ class App extends React.Component { new Notice('Login Failed, Please check credentials and try again!'); } else { - console.log(result); this.setState({ isLoaded: true, user_data: result, diff --git a/src/view/Components/Taskview/Dailiesview/DailyItem.tsx b/src/view/Components/Taskview/Dailiesview/DailyItem.tsx index ac950ee..4443cd3 100644 --- a/src/view/Components/Taskview/Dailiesview/DailyItem.tsx +++ b/src/view/Components/Taskview/Dailiesview/DailyItem.tsx @@ -12,7 +12,7 @@ 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 index 71b2b09..09e4c99 100644 --- a/src/view/Components/Taskview/Dailiesview/DailySubTasks.tsx +++ b/src/view/Components/Taskview/Dailiesview/DailySubTasks.tsx @@ -7,7 +7,7 @@ function DailySubTasks(props: any) { const subtasks = props.subtasks.map((subtask: any) => { let subtask_text = renderMarkdown(subtask.text); return ( -
+

diff --git a/src/view/Components/Taskview/Todoview/TodoSubTasks.tsx b/src/view/Components/Taskview/Todoview/TodoSubTasks.tsx index 0ba83d7..92ab97a 100644 --- a/src/view/Components/Taskview/Todoview/TodoSubTasks.tsx +++ b/src/view/Components/Taskview/Todoview/TodoSubTasks.tsx @@ -6,7 +6,7 @@ function TodoSubTasks(props: any) { const subtasks = props.subtasks.map((subtask: any) => { let subtask_text = renderMarkdown(subtask.text); return ( -
+

diff --git a/src/view/Components/Taskview/markdownRender.ts b/src/view/Components/Taskview/markdownRender.ts index 9e95a59..e09aa1f 100644 --- a/src/view/Components/Taskview/markdownRender.ts +++ b/src/view/Components/Taskview/markdownRender.ts @@ -3,6 +3,10 @@ import markdownitEmoji from "markdown-it-emoji" import twemoji from "twemoji"; export default function renderMarkdown(markdown: string) { + //check if markdown is empty or not a string + if (markdown === "" || markdown === undefined) { + return ""; + } const md = new MarkdownIt({ html: true, breaks: true, From 615f3e8a78c76faa53e2bf20327498419f6f2cab Mon Sep 17 00:00:00 2001 From: SuperChamp234 Date: Sat, 15 Jan 2022 09:47:49 +0530 Subject: [PATCH 16/16] Bumped up the version no(1.0.0) --- manifest.json | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/manifest.json b/manifest.json index c9b0afa..19dbe5b 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "obsidian-habitica-integration", "name": "Habitica Sync", - "version": "0.9.15", + "version": "1.0.0", "minAppVersion": "0.9.12", "description": "This plugin helps integrate Habitica user tasks and stats into Obsidian", "author": "Leoh and Ran", diff --git a/package.json b/package.json index 870cee1..80f9f65 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "obsidian-habitica-integration", - "version": "0.12.0", + "version": "1.0.0", "description": "This plugin allows for Habitica integration into Obsidian", "main": "main.js", "scripts": {