Skip to content

Commit

Permalink
feat: add button for open section tasks in the right side
Browse files Browse the repository at this point in the history
  • Loading branch information
ahonn committed Feb 26, 2023
1 parent 55da5d1 commit 8c37636
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/components/TaskItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ const TaskItem: React.FC<ITaskItemProps> = (props) => {
}}
>
<ArrowDownCircle
size={22}
className={classnames('stroke-gray-300', {
size={20}
className={classnames('stroke-gray-400 dark:stroke-gray-300', {
'cursor-pointer': task.page.journalDay !== task.scheduled,
'cursor-not-allowed': task.page.journalDay === task.scheduled,
})}
Expand Down
33 changes: 26 additions & 7 deletions src/components/TaskSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ import { themeStyleState } from '../state/theme';
import { visibleState } from '../state/visible';
import TaskItem from './TaskItem';
import { settingsState } from '../state/settings';
import { openTaskPage } from '../api';
import { openTask, openTaskPage } from '../api';
import { inputState } from '../state/input';
import { ChevronsRight, LayoutSidebarRight } from 'tabler-icons-react';

export enum GroupBy {
Page,
Expand Down Expand Up @@ -76,18 +77,36 @@ const TaskSection: React.FC<ITaskSectionProps> = (props) => {
}
}, [props.groupBy, tasks]);

const openTaskGroups = React.useCallback(() => {
console.log(tasks);
tasks.forEach((task) => {
openTask(task, {
openInRightSidebar: true,
});
});
window.logseq.hideMainUI();
}, [tasks]);

if (tasks.length === 0) {
return null;
}

return (
<div className="py-1">
<h2
className="py-1 text-blue-400"
style={{ color: themeStyle.sectionTitleColor }}
>
{title}
</h2>
<div className="flex flex-row justify-between items-center">
<h2
className="py-1 mr-2 text-blue-400"
style={{ color: themeStyle.sectionTitleColor }}
>
{title}
</h2>
<div className="pl-2 pr-1" onClick={openTaskGroups}>
<ChevronsRight
size={20}
className="stroke-gray-300 cursor-pointer"
/>
</div>
</div>
<div>
{(Object.entries(taskGroups) ?? []).map(([name, tasks]) => {
const [{ page }] = tasks;
Expand Down

0 comments on commit 8c37636

Please sign in to comment.