Skip to content

Commit 2d95c58

Browse files
authored
Merge pull request #22 from tatomyr/v7/use-purity-core
v7: Move modules reexports into one file. Refactor CHANGE_INPUT handler
2 parents 8184b6d + 62516b4 commit 2d95c58

25 files changed

+92
-92
lines changed

src/modules.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
export {
2+
createStore,
3+
render,
4+
} from 'https://tatomyr.github.io/purity/core.min.js'
5+
export { registerAsync } from 'https://tatomyr.github.io/purity/register-async.min.js'
6+
export { debounce } from 'https://tatomyr.github.io/purity/lib/debounce.min.js'
7+
// TODO: use minified version after fixing md5.min.js
8+
export { md5 } from 'https://tatomyr.github.io/purity/lib/md5.js'
9+
export { sanitize } from 'https://tatomyr.github.io/purity/lib/sanitize.min.js'
10+
11+
// Local:
12+
13+
// export { createStore, render } from 'http://192.168.1.3:8081/core.js'
14+
// export { registerAsync } from 'http://192.168.1.3:8081/register-async.js'
15+
// export { debounce } from 'http://192.168.1.3:8081/lib/debounce.js'
16+
// export { md5 } from 'http://192.168.1.3:8081/lib/md5.js'
17+
// export { sanitize } from 'http://192.168.1.3:8081/lib/sanitize.js'

src/modules/debounce.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/modules/md5.js

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/modules/purity.js

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/modules/sanitize.js

Lines changed: 0 additions & 4 deletions
This file was deleted.

src/store/action-types.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ export const types = {
1313
NOTIFICATION_HIDE: 'NOTIFICATION_HIDE',
1414
CHANGE_IMAGE: 'CHANGE_IMAGE',
1515
CAPTURE_PHOTO: 'CAPTURE_PHOTO',
16-
SUBSTITUTE_ROUTE: 'SUBSTITUTE_ROUTE',
1716
CHANGE_INPUT: 'CHANGE_INPUT',
1817
MOVE_TASK: 'MOVE_TASK',
1918
SHOW_INFO: 'SHOW_INFO',

src/store/async-handler.js

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
import { registerAsync } from '/modules/purity.js'
2-
import { md5 } from '/modules/md5.js'
1+
import { registerAsync, md5 } from '/modules.js'
32
import * as services from '/services/index.js'
43
import { types } from './action-types.js'
54

@@ -74,10 +73,6 @@ export function deleteTask(action, dispatch, state) {
7473
})
7574
}
7675

77-
export function changeInput(action, dispatch, state) {
78-
dispatch({ type: types.SUBSTITUTE_ROUTE, hasInput: !!action.input })
79-
}
80-
8176
export function notify(action, dispatch, state) {
8277
const pass = ({ type, ...rest }) => rest
8378
if (state.notification.notificationId)
@@ -284,8 +279,8 @@ async function uploadUserData(action, dispatch, state) {
284279
)
285280
) {
286281
services.saveTasks(tasks)
287-
dispatch({ type: 'FILTER', view: 'active' })
288-
dispatch({ type: 'RESET_TASKS', tasks })
282+
dispatch({ type: types.FILTER, view: 'active' })
283+
dispatch({ type: types.RESET_TASKS, tasks })
289284
}
290285
} catch (err) {
291286
dispatch({ type: types.NOTIFY, text: err.message })
@@ -299,7 +294,6 @@ export default registerAsync(
299294
[types.TRIGGER_TASK]: triggerTask,
300295
[types.DELETE_TASK]: deleteTask,
301296
[types.UPDATE_TASK]: saveTasks,
302-
[types.CHANGE_INPUT]: changeInput,
303297
[types.NOTIFY]: notify,
304298
[types.MOVE_TASK]: moveTask,
305299
[types.CHANGE_IMAGE]: changeImage,

src/store/provider.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { createStore } from '/modules/purity.js'
1+
import { createStore } from '/modules.js'
22
import { stateHandler } from './state-handler.js'
33
import asyncWatcher from './async-handler.js'
44

src/store/state-handler.js

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@ import { getCachedTasks } from '/services/index.js'
44
// Default Application state
55
const defaults = {
66
tasks: getCachedTasks(),
7+
taskId: undefined,
8+
input: '',
79
view: 'active',
8-
_backupRoute: undefined, // TODO: -> startedInputAt: [view]
10+
startedInputAt: 'active',
911
notification: {
1012
text: '',
1113
notificationId: undefined,
1214
pageY: undefined,
1315
},
14-
input: '',
15-
taskId: undefined,
1616
}
1717

1818
// Main syncronous Application handler. Handle all App state changes.
@@ -22,7 +22,7 @@ export const stateHandler = (state = defaults, action = {}) => {
2222
return {
2323
view: action.view,
2424
// If we've intentionally changed view, apparently we don't want go back.
25-
_backupRoute: undefined,
25+
startedInputAt: action.view,
2626
}
2727
case types.ADD_TASK:
2828
return {
@@ -74,19 +74,11 @@ export const stateHandler = (state = defaults, action = {}) => {
7474
notificationId: undefined,
7575
},
7676
}
77-
// TODO: combine this with CHANGE_INPUT
78-
case types.SUBSTITUTE_ROUTE:
79-
return action.hasInput
80-
? {
81-
view: 'all',
82-
_backupRoute: state._backupRoute || state.view,
83-
}
84-
: {
85-
view: state._backupRoute || state.view,
86-
_backupRoute: undefined,
87-
}
8877
case types.CHANGE_INPUT:
89-
return { input: action.input }
78+
return {
79+
input: action.input,
80+
view: action.input ? 'all' : state.startedInputAt,
81+
}
9082
case types.SHOW_INFO:
9183
return { view: 'show-info' }
9284
case types.RESET_TASKS:

src/style.css

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,18 @@ textarea {
9797
display: none;
9898
}
9999

100+
/* TODO: refactor styles */
101+
/* Todo page styles */
102+
.todo-page {
103+
height: calc(100% - 2 * var(--height));
104+
max-height: calc(100% - 2 * var(--height));
105+
}
106+
100107
/* TasksList style */
101108
.tasks-list {
102109
overflow-y: auto;
103-
height: calc(100% - 2 * var(--height));
104-
max-height: calc(100% - 2 * var(--height));
110+
height: 100%;
111+
max-height: 100%;
105112
background: lightgrey;
106113

107114
/* TODO: box-shadow: inset 0px 8px 5px -5px grey; */

0 commit comments

Comments
 (0)