better design,

fix crash when register after logout with user with todos
This commit is contained in:
2018-06-07 18:28:09 +03:00
parent a09d7518b3
commit 293f939ec7
5 changed files with 41 additions and 11 deletions

View File

@@ -103,5 +103,7 @@ export function reset() {
export function logout() {
localStorage.removeItem('jwt');
localStorage.removeItem('lists');
localStorage.removeItem('items');
return { type: LOGOUT };
}

View File

@@ -102,7 +102,7 @@ li button {
background: none;
width: 2rem;
font-size: 1rem;
transition: 0.4s ease-in-out;
transition: 0.17s ease-in-out;
overflow: hidden;
box-shadow: inset -3px 0 6px -3px rgba(0, 0, 0, 0.3);
}
@@ -137,11 +137,11 @@ li {
font-weight: 400;
flex-grow: 2;
flex-shrink: 1;
transition: 0.3s ease-in-out;
transition: 0.1s ease-in-out;
}
.todo--input {
background: white;
textarea.todo--input {
background: #fafafa;
color: black;
resize: none;
border: none;
@@ -152,12 +152,15 @@ li {
width: 100%;
height: 100%;
max-height: 100%;
transition: 0.3s ease-in-out;
font-size: 1rem;
transition: 0.1s ease-in-out;
}
.disabled {
width: 0;
padding: 0.5rem 0;
width: 1rem;
opacity: 0;
padding: 0.5rem 1rem;
border-top: 1px solid #f0f0f0;
}
.filter {

View File

@@ -74,13 +74,13 @@ class Todo extends React.Component {
<ButtonBase
style={{
justifyContent: 'left',
paddingLeft: '1.5rem',
paddingLeft: '1rem',
borderTop: '1px solid #f0f0f0',
textDecoration: this.props.todo.completed ? 'line-through' : 'none',
color: this.props.todo.completed ? '#888888' : 'black',
}}
className="todo"
onClick={this.state.hover ? this.props.toggleTodo : null}
onClick={this.props.toggleTodo}
>
{this.props.todo.text}
</ButtonBase>
@@ -102,6 +102,10 @@ class Todo extends React.Component {
style={{ backgroundColor: 'pink' }}
className={deleteClasses.join(' ')}
onClick={this.props.removeTodo}
onMouseOver={this.onMouseOver}
onFocus={this.onMouseOver}
onMouseOut={this.onMouseOut}
onBlur={this.onMouseOut}
>
<DeleteIcon style={icon} />
</ButtonBase>,
@@ -110,6 +114,10 @@ class Todo extends React.Component {
style={{ backgroundColor: 'lightcyan' }}
className={editClasses.join(' ')}
onClick={this.startEdit}
onMouseOver={this.onMouseOver}
onFocus={this.onMouseOver}
onMouseOut={this.onMouseOut}
onBlur={this.onMouseOut}
>
<EditIcon style={icon} />
</ButtonBase>,
@@ -117,9 +125,8 @@ class Todo extends React.Component {
return (
<animated.li
style={this.props.style}
onMouseOver={this.onMouseOver}
// onFocus and onBlur triggers when long pressing on smartphones
onFocus={this.onMouseOver}
onMouseOut={this.onMouseOut}
onBlur={this.onMouseOut}
>
{ButtonBases}

View File

@@ -13,6 +13,7 @@ import {
STOP_EDIT_LIST,
} from '../actions/lists';
import { REMOVE_TODO, ADD_TODO } from '../actions/todos';
import { LOGOUT } from '../actions/user';
export default function lists(
state = {
@@ -27,6 +28,16 @@ export default function lists(
action,
) {
switch (action.type) {
case LOGOUT:
return {
dirty: true,
fetching: false,
lists: null,
loaded: false,
creating: false,
list: null,
editing: false,
};
case CHANGE_LIST:
return { ...state, list: action.list };
case RECIEVE_LISTS:

View File

@@ -9,6 +9,7 @@ import {
EDIT_TODO,
} from '../actions/todos';
import { REMOVE_LIST } from '../actions/lists';
import { LOGOUT } from '../actions/user';
export default function todos(
state = {
@@ -19,6 +20,12 @@ export default function todos(
action,
) {
switch (action.type) {
case LOGOUT:
return {
dirty: true,
fetching: false,
todos: null,
};
case RECIEVE_TODOS:
return {
...state,