Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
75 commits
Select commit Hold shift + click to select a range
ca7b603
Init project with Vite.
Mar 28, 2022
557de6e
Moving client-app files to separate folder.
Mar 28, 2022
ed0350c
Add yarn.lock.
Mar 28, 2022
8bff61f
Add .editorconfig.
Mar 28, 2022
0a1843e
fixup! Moving client-app files to separate folder.
Mar 28, 2022
c90b135
Add eslint.
Mar 28, 2022
c6e7461
fixup! Add eslint.
Mar 28, 2022
e5f2672
Add prettier for eslint.
Mar 28, 2022
60ae356
Implement basic client-server connection.
Mar 28, 2022
f6a30f2
Enable built-in logux features: status badge, log and leaving confirm…
Mar 28, 2022
e26c9aa
Add logux ErrorsContext.
Mar 28, 2022
116c48a
Add auth layer for server part.
Mar 28, 2022
ff050d3
Add stylelint.
Mar 28, 2022
e36681d
Add postcss-normalize and postcss-nested.
Mar 29, 2022
fd67346
fixup! Implement basic client-server connection.
Mar 29, 2022
a2ce9d1
Remove meta-tag «viewport».
Mar 29, 2022
2502cf8
Implement markup of TodoMVC.
Mar 29, 2022
128a7ff
WIP Add interactivity for interface.
Mar 29, 2022
a366e8b
Enable @typescript-eslint/no-shadow rule.
Mar 31, 2022
0bbea5d
Enable server proxy in Vite config.
Mar 31, 2022
c7db7bb
Add interactivity for interface.
Apr 1, 2022
ff98ba9
Move to @logux/stylelint-config.
Apr 1, 2022
69b82e4
Increase font-size of footer.
Apr 1, 2022
78afa8e
Add loader for todos list.
Apr 1, 2022
4a10ac0
Move TodoListItem to separate React component.
Apr 1, 2022
10d84d3
fixup! Add interactivity for interface.
Apr 1, 2022
6a73ee9
fixup! Add interactivity for interface.
Apr 1, 2022
ad7a54c
fixup! Move TodoListItem to separate React component.
Apr 1, 2022
4eb79e2
Add filter by user for getting tasks.
Apr 1, 2022
3453002
Fix async state updates while route changing error.
Apr 1, 2022
a0bde1d
Add indentation in index.html.
Apr 4, 2022
038b97e
Change title of index.html.
Apr 4, 2022
a781aba
Delete comment with link in vite.config.ts.
Apr 4, 2022
ef5a0b5
Ignore specific selector ::-moz-placeholder instead of general -moz s…
Apr 4, 2022
eda64d2
Move auth server-module to modules folder.
Apr 4, 2022
8b3347c
Add HttpOnly to cookies of POST /auth route.
Apr 4, 2022
4176ab2
Use «subprotocol» value as «supports» option for server.
Apr 4, 2022
45afa20
Remove redundant rules from .stylelintignore.
Apr 4, 2022
f6679e6
Move from yarn to pnpm.
Apr 4, 2022
2ae1167
Turn off the «skipLibCheck» TS option.
Apr 4, 2022
da79d99
Add @logux/actions.
Apr 4, 2022
82c7cee
Remove redundant rules from .gitignore.
Apr 4, 2022
a084c40
Add «client/dist» to linters' ignore lists.
Apr 4, 2022
c66f529
Turn on «import/extensions» Eslint rule.
Apr 4, 2022
cda604e
Separate repository into pnpm workspaces.
Apr 5, 2022
2ed70eb
Replace favicon.
Apr 5, 2022
ccf325b
Remove prettier.
Apr 5, 2022
31a19d1
Remove IDE's folders from .eslintignore.
Apr 6, 2022
0ca37ec
Remove redundant rules from .editorconfig.
Apr 6, 2022
9804034
Remove versions from package files.
Apr 6, 2022
33927bd
Update @logux/eslint-config.
Apr 6, 2022
cf22032
Update @logux/client, react, react-dom.
Apr 6, 2022
900e947
Use external favicon resource.
Apr 6, 2022
80e531e
Remove node_modules from .eslintignore.
Apr 6, 2022
c722cbc
Move Postcss config to json file.
Apr 6, 2022
c575b1d
Add global dist folders in ignore files.
Apr 6, 2022
4587065
Move production dependencies into "dependencies" section in client's …
Apr 6, 2022
fc14b81
Remove type for favicon.
Apr 6, 2022
a63fa70
Remove unnecessary inputs' placeholders.
Apr 6, 2022
5c0e2a5
Move server to addSyncMap API.
Apr 5, 2022
500af59
Improve redirects.
Apr 7, 2022
4844d4a
Add reminder about moving to cookie parsing library
Apr 7, 2022
252c203
Move labels into TextField component.
Apr 7, 2022
b904a84
Remove unnecessary code from TodosList.
Apr 7, 2022
7580c58
Restructure event handlers in TodosListItem.
Apr 7, 2022
4abde45
Add autoprefixer.
Apr 7, 2022
058693a
Change router from wouter to @nanostores/router.
Apr 7, 2022
2c5355e
Remove tsconfig.node.json.
Apr 7, 2022
cd9bb0c
Move TaskRecord type to server application.
Apr 7, 2022
c9a0f1e
Remove unused getAllTasks function.
Apr 7, 2022
7a2986a
Add "Routes" interface to router store.
Apr 7, 2022
366c16e
fixup! Move server to addSyncMap API.
Apr 7, 2022
1055bb3
Move module indication from api folder to root folder.
Apr 7, 2022
856550c
Move Typescript to devDependencies in client project.
Apr 7, 2022
64b8dc4
Clear of non-variable color usages.
Apr 7, 2022
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
9 changes: 9 additions & 0 deletions .editorconfig
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
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist
6 changes: 6 additions & 0 deletions .eslintrc
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"
}
}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
pnpm-debug.log*

dist
8 changes: 8 additions & 0 deletions .prettierrc.json
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"
}
13 changes: 13 additions & 0 deletions api/index.ts
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
}
7 changes: 7 additions & 0 deletions client/.postcssrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"plugins": {
"postcss-normalize": {},
"postcss-nested": {},
"autoprefixer": {}
}
}
1 change: 1 addition & 0 deletions client/.stylelintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist
15 changes: 15 additions & 0 deletions client/.stylelintrc
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"
]
}
]
}
}
12 changes: 12 additions & 0 deletions client/index.html
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>
38 changes: 38 additions & 0 deletions client/package.json
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"
}
}
32 changes: 32 additions & 0 deletions client/src/App.tsx
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 client/src/components/ControlPanel/ControlPanel.module.css
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);
}
}
83 changes: 83 additions & 0 deletions client/src/components/ControlPanel/ControlPanel.tsx
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'

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>
)
}
30 changes: 30 additions & 0 deletions client/src/components/Layout/Layout.module.css
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;
}
}
Loading