-
Notifications
You must be signed in to change notification settings - Fork 4
Add todoMVC example with React #4
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
Merged
Merged
Changes from all commits
Commits
Show all changes
75 commits
Select commit
Hold shift + click to select a range
ca7b603
Init project with Vite.
557de6e
Moving client-app files to separate folder.
ed0350c
Add yarn.lock.
8bff61f
Add .editorconfig.
0a1843e
fixup! Moving client-app files to separate folder.
c90b135
Add eslint.
c6e7461
fixup! Add eslint.
e5f2672
Add prettier for eslint.
60ae356
Implement basic client-server connection.
f6a30f2
Enable built-in logux features: status badge, log and leaving confirm…
e26c9aa
Add logux ErrorsContext.
116c48a
Add auth layer for server part.
ff050d3
Add stylelint.
e36681d
Add postcss-normalize and postcss-nested.
fd67346
fixup! Implement basic client-server connection.
a2ce9d1
Remove meta-tag «viewport».
2502cf8
Implement markup of TodoMVC.
128a7ff
WIP Add interactivity for interface.
a366e8b
Enable @typescript-eslint/no-shadow rule.
0bbea5d
Enable server proxy in Vite config.
c7db7bb
Add interactivity for interface.
ff98ba9
Move to @logux/stylelint-config.
69b82e4
Increase font-size of footer.
78afa8e
Add loader for todos list.
4a10ac0
Move TodoListItem to separate React component.
10d84d3
fixup! Add interactivity for interface.
6a73ee9
fixup! Add interactivity for interface.
ad7a54c
fixup! Move TodoListItem to separate React component.
4eb79e2
Add filter by user for getting tasks.
3453002
Fix async state updates while route changing error.
a0bde1d
Add indentation in index.html.
038b97e
Change title of index.html.
a781aba
Delete comment with link in vite.config.ts.
ef5a0b5
Ignore specific selector ::-moz-placeholder instead of general -moz s…
eda64d2
Move auth server-module to modules folder.
8b3347c
Add HttpOnly to cookies of POST /auth route.
4176ab2
Use «subprotocol» value as «supports» option for server.
45afa20
Remove redundant rules from .stylelintignore.
f6679e6
Move from yarn to pnpm.
2ae1167
Turn off the «skipLibCheck» TS option.
da79d99
Add @logux/actions.
82c7cee
Remove redundant rules from .gitignore.
a084c40
Add «client/dist» to linters' ignore lists.
c66f529
Turn on «import/extensions» Eslint rule.
cda604e
Separate repository into pnpm workspaces.
2ed70eb
Replace favicon.
ccf325b
Remove prettier.
31a19d1
Remove IDE's folders from .eslintignore.
0ca37ec
Remove redundant rules from .editorconfig.
9804034
Remove versions from package files.
33927bd
Update @logux/eslint-config.
cf22032
Update @logux/client, react, react-dom.
900e947
Use external favicon resource.
80e531e
Remove node_modules from .eslintignore.
c722cbc
Move Postcss config to json file.
c575b1d
Add global dist folders in ignore files.
4587065
Move production dependencies into "dependencies" section in client's …
fc14b81
Remove type for favicon.
a63fa70
Remove unnecessary inputs' placeholders.
5c0e2a5
Move server to addSyncMap API.
500af59
Improve redirects.
4844d4a
Add reminder about moving to cookie parsing library
252c203
Move labels into TextField component.
b904a84
Remove unnecessary code from TodosList.
7580c58
Restructure event handlers in TodosListItem.
4abde45
Add autoprefixer.
058693a
Change router from wouter to @nanostores/router.
2c5355e
Remove tsconfig.node.json.
cd9bb0c
Move TaskRecord type to server application.
c9a0f1e
Remove unused getAllTasks function.
7a2986a
Add "Routes" interface to router store.
366c16e
fixup! Move server to addSyncMap API.
1055bb3
Move module indication from api folder to root folder.
856550c
Move Typescript to devDependencies in client project.
64b8dc4
Clear of non-variable color usages.
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| root = true | ||
|
|
||
| [*] | ||
| indent_style = space | ||
| indent_size = 2 | ||
| end_of_line = lf | ||
| charset = utf-8 | ||
| trim_trailing_whitespace = true | ||
| insert_final_newline = true |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| dist |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| { | ||
| "extends": "@logux/eslint-config/ts", | ||
| "rules": { | ||
| "prefer-let/prefer-let": "off" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| pnpm-debug.log* | ||
|
|
||
| dist |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| { | ||
| "arrowParens": "avoid", | ||
| "jsxSingleQuote": false, | ||
| "quoteProps": "consistent", | ||
| "semi": false, | ||
| "singleQuote": true, | ||
| "trailingComma": "none" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| export const subprotocol = '1.0.0' | ||
|
|
||
| export type User = { | ||
| id: string | ||
| name: string | ||
| password: string | ||
| } | ||
|
|
||
| export type Task = { | ||
| text: string | ||
| completed: boolean | ||
| authorId?: string | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| { | ||
| "plugins": { | ||
| "postcss-normalize": {}, | ||
| "postcss-nested": {}, | ||
| "autoprefixer": {} | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| dist |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| { | ||
| "extends": [ | ||
| "@logux/stylelint-config" | ||
| ], | ||
| "rules": { | ||
| "at-rule-no-unknown": [ | ||
| true, | ||
| { | ||
| "ignoreAtRules": [ | ||
| "import-normalize" | ||
| ] | ||
| } | ||
| ] | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
| <head> | ||
| <meta charset="UTF-8" /> | ||
| <link href="https://logux.io/favicon.ico" rel="icon"/> | ||
| <title>Logux ToDo Example</title> | ||
| </head> | ||
| <body> | ||
| <div id="root"></div> | ||
| <script src="/src/main.tsx" type="module"></script> | ||
| </body> | ||
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| { | ||
| "name": "logux-to-do-example-client", | ||
| "private": true, | ||
| "engines": { | ||
| "node": ">=16" | ||
| }, | ||
| "scripts": { | ||
| "dev": "vite", | ||
| "build": "tsc && vite build", | ||
| "preview": "vite preview", | ||
| "lint:css": "stylelint '**/*.css' --fix" | ||
| }, | ||
| "dependencies": { | ||
| "@logux/client": "^0.15.2", | ||
| "@logux/core": "^0.7.3", | ||
| "@nanostores/react": "^0.1.5", | ||
| "@nanostores/router": "^0.3.1", | ||
| "@vitejs/plugin-react": "^1.0.7", | ||
| "autoprefixer": "^10.4.4", | ||
| "browserslist": "^4.20.2", | ||
| "classnames": "^2.3.1", | ||
| "nanoid": "^3.3.2", | ||
| "nanostores": "^0.5.12", | ||
| "postcss": "^8.4.12", | ||
| "postcss-nested": "^5.0.5", | ||
| "postcss-normalize": "^10.0.0", | ||
| "react": "^18.0.0", | ||
| "react-dom": "^18.0.0", | ||
| "stylelint": "^14.6.1", | ||
| "vite": "^2.8.0" | ||
| }, | ||
| "devDependencies": { | ||
| "@logux/stylelint-config": "^0.9.0", | ||
| "@types/react": "^17.0.33", | ||
| "@types/react-dom": "^17.0.10", | ||
| "typescript": "^4.6.3" | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| import { ClientContext, ErrorsContext } from '@logux/client/react' | ||
| import { useStore } from '@nanostores/react' | ||
|
|
||
| import './styles/theme.css' | ||
| import './styles/base.css' | ||
|
|
||
| import { AccessDeniedPage } from './pages/AccessDeniedPage.js' | ||
| import { ErrorPage } from './pages/ErrorPage.js' | ||
| import { NotFoundPage } from './pages/NotFoundPage.js' | ||
| import { Layout } from './components/Layout/Layout.js' | ||
| import Routes from './components/Routes/Routes.js' | ||
| import { clientStore } from './stores/logux-client.js' | ||
|
|
||
| const errorPages = { | ||
| NotFound: NotFoundPage, | ||
| AccessDenied: AccessDeniedPage, | ||
| Error: ErrorPage | ||
| } | ||
|
|
||
| export const App = (): JSX.Element => { | ||
| let client = useStore(clientStore) | ||
|
|
||
| return ( | ||
| <ErrorsContext.Provider value={errorPages}> | ||
| <ClientContext.Provider value={client}> | ||
| <Layout> | ||
| <Routes /> | ||
| </Layout> | ||
| </ClientContext.Provider> | ||
| </ErrorsContext.Provider> | ||
| ) | ||
| } |
78 changes: 78 additions & 0 deletions
78
client/src/components/ControlPanel/ControlPanel.module.css
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| .control-panel { | ||
| position: relative; | ||
| display: grid; | ||
| grid-template-columns: repeat(3, 1fr); | ||
| padding: 10px 15px; | ||
| color: var(--dark-gray); | ||
| border-top: 1px solid var(--light-gray); | ||
|
|
||
| &::before { | ||
| position: absolute; | ||
| right: 0; | ||
| bottom: 0; | ||
| left: 0; | ||
| height: 50px; | ||
| content: ""; | ||
| box-shadow: | ||
| 0 1px 1px var(--gray), | ||
| 0 8px 0 -3px var(--light-gray-100), | ||
| 0 9px 1px -3px var(--gray), | ||
| 0 16px 0 -6px var(--light-gray-100), | ||
| 0 17px 2px -6px var(--gray); | ||
| } | ||
| } | ||
|
|
||
| .items-count { | ||
| position: relative; | ||
| align-self: center; | ||
| justify-self: start; | ||
| } | ||
|
|
||
| .filters { | ||
| position: relative; | ||
| display: flex; | ||
| justify-self: center; | ||
| padding: 0; | ||
| margin: 0; | ||
| list-style: none; | ||
| } | ||
|
|
||
| .filters-item-content { | ||
| padding: 3px 7px; | ||
| margin: 3px; | ||
| font-weight: 300; | ||
| color: var(--dark-gray); | ||
| text-decoration: none; | ||
| background: transparent; | ||
| border: 1px solid transparent; | ||
| border-radius: 3px; | ||
|
|
||
| &:hover { | ||
| border-color: var(--accent-300); | ||
| } | ||
|
|
||
| &:focus { | ||
| border-color: var(--accent-200); | ||
| outline: none; | ||
| } | ||
|
|
||
| &_selected { | ||
| border-color: var(--accent-200); | ||
| } | ||
| } | ||
|
|
||
| .clear-action { | ||
| position: relative; | ||
| justify-self: end; | ||
| padding: 3px 7px; | ||
| font-weight: 300; | ||
| color: var(--dark-gray); | ||
| background: transparent; | ||
| border: 1px solid transparent; | ||
| border-radius: 3px; | ||
|
|
||
| &:hover, | ||
| &:focus { | ||
| border-color: var(--accent-300); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,83 @@ | ||
| import { useStore } from '@nanostores/react' | ||
| import cn from 'classnames' | ||
| import { useClient, useFilter } from '@logux/client/react' | ||
| import { deleteSyncMapById } from '@logux/client' | ||
| import { useCallback } from 'react' | ||
|
|
||
| import { Filter, filterStore } from '../../stores/filter.js' | ||
| import { tasksStore } from '../../stores/tasks.js' | ||
| import { authStore } from '../../stores/auth.js' | ||
| import styles from './ControlPanel.module.css' | ||
mikhin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| export const ControlPanel = (): JSX.Element => { | ||
| const client = useClient() | ||
| const filter = useStore(filterStore) | ||
| const { id: authorId } = useStore(authStore) | ||
| const tasks = useFilter(tasksStore, { authorId }) | ||
| const activeTasksCount = tasks.list.filter(task => !task.completed).length | ||
|
|
||
| const handleClearCompletedClick = useCallback(() => { | ||
| const tasksToDelete = tasks.list.filter(task => task.completed) | ||
|
|
||
| tasksToDelete.forEach(task => | ||
| deleteSyncMapById(client, tasksStore, task.id) | ||
| ) | ||
| }, [client, tasks]) | ||
|
|
||
| return ( | ||
| <footer className={styles.controlPanel}> | ||
| <span className={styles.itemsCount}>{activeTasksCount} items left</span> | ||
| <ul className={styles.filters}> | ||
| <li className={styles.filtersItem}> | ||
| <button | ||
| type="button" | ||
| className={cn( | ||
| styles.filtersItemContent, | ||
| filter === Filter.all && styles.filtersItemContentSelected | ||
| )} | ||
| onClick={() => { | ||
| filterStore.set(Filter.all) | ||
| }} | ||
| > | ||
| All | ||
| </button> | ||
| </li> | ||
| <li className={styles.filtersItem}> | ||
| <button | ||
| type="button" | ||
| className={cn( | ||
| styles.filtersItemContent, | ||
| filter === Filter.active && styles.filtersItemContentSelected | ||
| )} | ||
| onClick={() => { | ||
| filterStore.set(Filter.active) | ||
| }} | ||
| > | ||
| Active | ||
| </button> | ||
| </li> | ||
| <li className={styles.filtersItem}> | ||
| <button | ||
| type="button" | ||
| className={cn( | ||
| styles.filtersItemContent, | ||
| filter === Filter.completed && styles.filtersItemContentSelected | ||
| )} | ||
| onClick={() => { | ||
| filterStore.set(Filter.completed) | ||
| }} | ||
| > | ||
| Completed | ||
| </button> | ||
| </li> | ||
| </ul> | ||
| <button | ||
| type="button" | ||
| className={styles.clearAction} | ||
| onClick={handleClearCompletedClick} | ||
| > | ||
| Clear completed | ||
| </button> | ||
| </footer> | ||
| ) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| .layout { | ||
| width: 550px; | ||
| margin: 0 auto; | ||
| } | ||
|
|
||
| .title { | ||
| display: block; | ||
| margin: 8px 0; | ||
| font-size: 100px; | ||
| font-weight: 100; | ||
| color: var(--accent-200); | ||
| text-align: center; | ||
| } | ||
|
|
||
| .footer { | ||
| margin: 65px auto 0; | ||
| font-size: 14px; | ||
| color: var(--gray); | ||
| text-align: center; | ||
| } | ||
|
|
||
| .footer-link { | ||
| font-weight: 400; | ||
| color: inherit; | ||
| text-decoration: none; | ||
|
|
||
| &:hover { | ||
| text-decoration: underline; | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.