Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed fields for editable tasks and added some styling #38

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion sidebar/public/content.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ function toggleSidebar() {
"\
display: flex;\
width:300px;\
background-color: gray;\
background-color: #e8e8e8;\
";
element.appendChild(sidebar); //append a sidebar element to the calendar.
const iframe = document.getElementById("twainFetcher");
Expand Down
Binary file added sidebar/src/back_arrow.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
14 changes: 0 additions & 14 deletions sidebar/src/components/Card.js

This file was deleted.

142 changes: 84 additions & 58 deletions sidebar/src/components/TaskCard.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
import * as React from "react";
import styled from "styled-components";
import Card from "./Card";
import { Header, Subheader, Paragraph } from "./Typography";
import Button from "./Button";

const ExpandedTaskCardWrapper = styled.div`
const Card = styled.div`
font-family: Cabin;
font-style: normal;
font-weight: normal;
font-size: 12px;
line-height: 15px;

&:hover {
cursor: pointer;
}
`;

const CompactTaskCardWrapper = styled.div`
margin-bottom: 1.25em;
align-content: space-evenly;
grid-column: 1 / span 4;
grid-row: span 4;
`;

const ButtonWrapper = styled.div`
Expand All @@ -23,16 +33,22 @@ const Input = styled.input`
font-family: inherit;
background-color: inherit;
font-size: inherit;
width: 100%;
width: 90%;
padding: 0.5em;
margin-bottom: 1.5em;
margin-top: -0.5em;
`;

const CompactTaskCardWrapper = styled.div`
margin-bottom: 1.25em;
const EditTaskWrapper = styled.div`
font-family: Cabin;
font-style: normal;
font-weight: normal;
font-size: 12px;
line-height: 15px;

align-content: space-evenly;
grid-column: 1 / span 4;
grid-row: 2 / span 4;
`;

export default class TaskCard extends React.Component {
Expand All @@ -41,24 +57,16 @@ export default class TaskCard extends React.Component {
this.state = {
expanded: false,
editedTask: {
name: "Editable task name",
dueDate: "",
isActive: false,
isRecurrent: false,
flags: "",
description: "Some description of the task"
},
uneditedTask: {
name: "Editable task name",
dueDate: "",
isActive: false,
isRecurrent: false,
flags: "",
description: "Some description of the task"
name: props.name,
duration: props.duration,
dueDate: props.dueDate,
isActive: props.isActive,
isRecurrent: props.isRecurrent
}
};
}

/** Value Change Functions */
onNameChange = e => {
this.setState({
editedTask: {
Expand All @@ -68,6 +76,25 @@ export default class TaskCard extends React.Component {
});
};

onDurationChange = e => {
this.setState({
editedTask: {
...this.state.editedTask,
duration: e.target.value
}
});
};

onDueDateChange = e => {
this.setState({
editedTask: {
...this.state.editedTask,
dueDate: e.target.value
}
});
};

/** Toggle Functions */
toggleTaskCard = () => {
console.log("clicked");
this.setState({
Expand All @@ -77,63 +104,62 @@ export default class TaskCard extends React.Component {
};

cancelTaskCard = () => {
this.toggleTaskCard();
this.setState({
editedTask: this.state.uneditedTask
editedTask: {
name: this.props.name,
description: this.props.description
}
});
this.toggleTaskCard();
};

updateTaskCard = () => {
this.setState({
uneditedTask: this.state.editedTask
editedTask: this.state.editedTask
});
this.toggleTaskCard();

/* connect with Redux in the future */
};

onDescriptionChange = e => {
this.setState({
editedTask: {
...this.state.editedTask,
description: e.target.value
}
});
};

render() {
if (this.state.expanded) {
return (
<ExpandedTaskCardWrapper>
<Card>
<Paragraph>
<Input
value={this.state.editedTask.name}
onChange={this.onNameChange}
/>
</Paragraph>
<Subheader>Description</Subheader>
<Paragraph>
<Input
value={this.state.editedTask.description}
onChange={this.onDescriptionChange}
/>
</Paragraph>
<Subheader>Label</Subheader>
<Button fillWidth primary /> <br />
<ButtonWrapper>
<Button onClick={this.cancelTaskCard}>Cancel</Button>
<Button onClick={this.updateTaskCard} primary>
Submit
</Button>
</ButtonWrapper>
</Card>
</ExpandedTaskCardWrapper>
<EditTaskWrapper>
<Button className="button icon-left" onClick={this.toggleTaskCard}>
Back
</Button>{" "}
<Header>
<Input
value={this.state.editedTask.name}
onChange={this.onNameChange}
/>
</Header>
<Subheader>Duration</Subheader>
<Paragraph>
<Input
value={this.state.editedTask.duration}
onChange={this.onDurationChange}
/>
</Paragraph>
<Subheader>Due Date</Subheader>
<Paragraph>
<Input
value={this.state.editedTask.dueDate}
onChange={this.onDueDateChange}
/>
</Paragraph>
<ButtonWrapper>
<Button onClick={this.updateTaskCard} primary>
Save
</Button>
</ButtonWrapper>
</EditTaskWrapper>
);
}
return (
<CompactTaskCardWrapper onClick={this.toggleTaskCard}>
<Card>{this.state.editedTask.name}</Card>
<Card>{this.props.name}</Card>
</CompactTaskCardWrapper>
);
}
Expand Down
5 changes: 2 additions & 3 deletions sidebar/src/components/TaskList.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import TaskCard from "./TaskCard";

const TaskListWrapper = styled.div`
display: grid;
background-color: #c4c4c4;
background-color: #e8e8e8;
grid-template-rows: repeat(12, 1fr);
grid-template-columns: repeat(4, 1fr);
font-family: Cabin;
Expand All @@ -21,10 +21,9 @@ export default class TaskList extends React.Component {
className="TaskCard"
name="Go grocery shopping"
dueDate="March 14"
duration="30 minutes"
isActive={true}
isRecurrent={false}
flags="Personal"
description=""
/>
</TaskListWrapper>
);
Expand Down
2 changes: 2 additions & 0 deletions sidebar/src/components/Typography.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export const Header = styled.div`
font-size: 1.5em;
font-weight: 700;
font-family: Cabin;
line-height: 19px;
margin: 0.8125em 0;
`;

Expand All @@ -12,6 +13,7 @@ export const Subheader = styled.div`
font-weight: 700;
font-family: Cabin;
margin: 0.75em 0;
padding: 0.5em;
`;

export const Paragraph = styled.p`
Expand Down