Skip to content

Commit 165072b

Browse files
Added todo docs and story. Also a few css fixes (#623)
1 parent 6abf8ff commit 165072b

File tree

4 files changed

+135
-23
lines changed

4 files changed

+135
-23
lines changed

docs/preview/mgt-todo.md

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
# MgtTodo Component
2+
3+
The Todo component enables the user to view, add, remove, complete, or edit tasks. It works with tasks from the Microsoft To-Do API.
4+
5+
## Properties
6+
7+
| Attribute | Property | Description |
8+
| -- | -- | -- |
9+
| read-only | readOnly | A Boolean to set the task interface to be read only (no adding or removing tasks). Default is `false`. |
10+
| hide-header | hideHeader | A Boolean to show or hide the header of the component. Default is `false`. |
11+
| hide-options | hideOptions | A Boolean to show or hide the options in tasks. Default is `false`.
12+
| initial-id="folder_id" | initialId | A string ID to set the initially displayed folder to the provided ID. |
13+
| target-id="folder_id"| targetId | A string ID to lock the tasks interface to the provided folder ID. |
14+
| N/A | isNewTaskVisible | Determines whether new task view is visible at render. |
15+
| N/A | taskFilter | An optional function to filter which tasks are shown to the user. |
16+
17+
The following example shows only tasks from the folder with ID *12345* and does not allow the user to create new tasks.
18+
19+
```html
20+
<mgt-todo read-only initial-id="12345"></mgt-todo>
21+
```
22+
23+
## Custom CSS variables
24+
25+
````css
26+
mgt-todo {
27+
--tasks-background-color
28+
--tasks-header-padding
29+
--tasks-title-padding
30+
--tasks-plan-title-font-size
31+
--tasks-plan-title-padding
32+
33+
--tasks-new-button-width
34+
--tasks-new-button-height
35+
--tasks-new-button-color
36+
--tasks-new-button-background
37+
--tasks-new-button-border
38+
--tasks-new-button-hover-background
39+
--tasks-new-button-active-background
40+
41+
--task-margin
42+
--task-background
43+
--task-border
44+
--task-header-color
45+
--task-header-margin
46+
47+
--task-new-margin
48+
--task-new-border
49+
--task-new-input-margin
50+
--task-new-input-padding
51+
--task-new-input-font-size
52+
--task-new-select-border
53+
54+
--task-new-add-button-background
55+
--task-new-add-button-disabled-background
56+
--task-new-cancel-button-color
57+
58+
--task-complete-background
59+
--task-complete-border
60+
61+
--task-icon-alignment: flex-start (default) | center | flex-end
62+
--task-icon-background
63+
--task-icon-background-completed
64+
--task-icon-border
65+
--task-icon-border-completed
66+
--task-icon-border-radius
67+
--task-icon-color
68+
--task-icon-color-completed
69+
}
70+
````
71+
72+
## Events
73+
| Event | Detail | Description |
74+
| --- | --- | --- |
75+
| taskAdded | The detail contains the respective `task` object | Fires when a new task has been created. |
76+
| taskChanged | The detail contains the respective `task` object | Fires when task metadata has been changed, such as marking completed. |
77+
| taskClick | The detail contains the respective `task` object | Fires when the user clicks or taps on a task. |
78+
| taskRemoved | The detail contains the respective `task` object | Fires when an existing task has been deleted. |
79+
80+
## Templates
81+
82+
The `tasks` component supports several [templates](../templates.md) that allow you to replace certain parts of the component. To specify a template, include a `<template>` element inside a component and set the `data-type` value to one of the following:
83+
84+
| Data type | Data context | Description |
85+
| --------- | ------------------------- | ----------------------------------------------------------------- |
86+
| task | task: a to-do task object | replaces the whole default task. |
87+
| task-details | task: a to-do task object | template replaces the details section of the task. |
88+
89+
The following example defines a template for the tasks component.
90+
91+
```html
92+
<mgt-todo>
93+
<template data-type="task-details">
94+
<div>
95+
Importance Level: {{task.importance}}
96+
</div>
97+
</template>
98+
</mgt-todo>
99+
```
100+
101+
## Microsoft Graph permissions
102+
103+
This control uses the following Microsoft Graph APIs and permissions.
104+
105+
| Resource | Permission |
106+
| - | - |
107+
| /me/todo/lists/ | Tasks.ReadWrite |
108+
| /me/todo/lists/{todoTaskListId}/tasks | Tasks.ReadWrite |
109+
| /me/todo/lists/{todoTaskListId}/tasks/{taskId} | Tasks.ReadWrite |

packages/mgt/src/components/mgt-tasks-base/mgt-tasks-base.scss

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ $task-icon-color-completed: var(--task-icon-color-completed, white);
104104
justify-content: center;
105105
align-items: center;
106106

107-
width: var(--task-new-button-width, auto);
107+
width: var(--tasks-new-button-width, auto);
108108
height: var(--tasks-new-button-height, 32px);
109109
border-radius: 2px;
110110
padding: 0 20px;
@@ -384,13 +384,6 @@ $task-icon-color-completed: var(--task-icon-color-completed, white);
384384
}
385385
}
386386

387-
.TaskHeader {
388-
display: flex;
389-
justify-content: center;
390-
color: var(--task-header-color, #333333);
391-
margin: var(--task-header-margin, 0 0 0 10px);
392-
}
393-
394387
.TaskCheckContainer {
395388
font-family: 'FabricMDL2Icons';
396389
display: inline-block;
@@ -452,6 +445,7 @@ $task-icon-color-completed: var(--task-icon-color-completed, white);
452445

453446
&.Complete {
454447
background: var(--task-complete-background, $ms-color-gray30);
448+
border: var(--task-complete-border, inherit);
455449
}
456450

457451
&.NewTask {
@@ -631,10 +625,6 @@ $task-icon-color-completed: var(--task-icon-color-completed, white);
631625
border-color: #f2f2f2;
632626
cursor: default;
633627
}
634-
.TaskHeader {
635-
justify-content: flex-start;
636-
justify-items: flex-start;
637-
}
638628
.TaskDetailIcon {
639629
width: 16px;
640630
height: 16px;

packages/mgt/src/components/mgt-todo/mgt-todo.ts

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -36,8 +36,8 @@ import { styles } from './mgt-todo-css';
3636
* @class MgtTodo
3737
* @extends {MgtTasksBase}
3838
*
39+
* @cssprop --tasks-background-color - {Color} Task background color
3940
* @cssprop --tasks-header-padding - {String} Tasks header padding
40-
* @cssprop --tasks-header-margin - {String} Tasks header margin
4141
* @cssprop --tasks-title-padding - {String} Tasks title padding
4242
* @cssprop --tasks-plan-title-font-size - {Length} Tasks plan title font size
4343
* @cssprop --tasks-plan-title-padding - {String} Tasks plan title padding
@@ -48,32 +48,22 @@ import { styles } from './mgt-todo-css';
4848
* @cssprop --tasks-new-button-border - {String} Tasks new button border
4949
* @cssprop --tasks-new-button-hover-background - {Color} Tasks new button hover background
5050
* @cssprop --tasks-new-button-active-background - {Color} Tasks new button active background
51-
* @cssprop --tasks-new-task-name-margin - {String} Tasks new task name margin
5251
* @cssprop --task-margin - {String} Task margin
53-
* @cssprop --task-box-shadow - {String} Task box shadow
5452
* @cssprop --task-background - {Color} Task background
5553
* @cssprop --task-border - {String} Task border
5654
* @cssprop --task-header-color - {Color} Task header color
5755
* @cssprop --task-header-margin - {String} Task header margin
58-
* @cssprop --task-detail-icon-margin -{String} Task detail icon margin
5956
* @cssprop --task-new-margin - {String} Task new margin
6057
* @cssprop --task-new-border - {String} Task new border
61-
* @cssprop --task-new-line-margin - {String} Task new line margin
62-
* @cssprop --tasks-new-line-border - {String} Tasks new line border
6358
* @cssprop --task-new-input-margin - {String} Task new input margin
6459
* @cssprop --task-new-input-padding - {String} Task new input padding
6560
* @cssprop --task-new-input-font-size - {Length} Task new input font size
66-
* @cssprop --task-new-input-active-border - {String} Task new input active border
6761
* @cssprop --task-new-select-border - {String} Task new select border
6862
* @cssprop --task-new-add-button-background - {Color} Task new add button background
6963
* @cssprop --task-new-add-button-disabled-background - {Color} Task new add button disabled background
7064
* @cssprop --task-new-cancel-button-color - {Color} Task new cancel button color
7165
* @cssprop --task-complete-background - {Color} Task complete background
7266
* @cssprop --task-complete-border - {String} Task complete border
73-
* @cssprop --task-complete-header-color - {Color} Task complete header color
74-
* @cssprop --task-complete-detail-color - {Color} Task complete detail color
75-
* @cssprop --task-complete-detail-icon-color - {Color} Task complete detail icon color
76-
* @cssprop --tasks-background-color - {Color} Task background color
7767
* @cssprop --task-icon-alignment - {String} Task icon alignment
7868
* @cssprop --task-icon-background - {Color} Task icon color
7969
* @cssprop --task-icon-background-completed - {Color} Task icon background color when completed

stories/components/todo.stories.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
/**
2+
* -------------------------------------------------------------------------------------------
3+
* Copyright (c) Microsoft Corporation. All Rights Reserved. Licensed under the MIT License.
4+
* See License in the project root for license information.
5+
* -------------------------------------------------------------------------------------------
6+
*/
7+
8+
import { html } from 'lit-element';
9+
import { withA11y } from '@storybook/addon-a11y';
10+
import { withSignIn } from '../../.storybook/addons/signInAddon/signInAddon';
11+
import { withCodeEditor } from '../../.storybook/addons/codeEditorAddon/codeAddon';
12+
import '../../packages/mgt/dist/es6/components/mgt-todo/mgt-todo';
13+
14+
export default {
15+
title: 'Components | mgt-todo',
16+
component: 'mgt-todo',
17+
decorators: [withA11y, withSignIn, withCodeEditor],
18+
parameters: { options: { selectedPanel: 'storybookjs/knobs/panel' } }
19+
};
20+
21+
export const tasks = () => html`
22+
<mgt-todo></mgt-todo>
23+
`;

0 commit comments

Comments
 (0)