Initial commit

This commit is contained in:
He4eT 2020-12-17 18:30:42 +05:00
commit 11523c975b
13 changed files with 15621 additions and 0 deletions

9
.babelrc Normal file
View file

@ -0,0 +1,9 @@
{
"env": {
"test": {
"presets": [
["preact-cli/babel", { "modules": "commonjs" }]
]
}
}
}

4
.gitignore vendored Normal file
View file

@ -0,0 +1,4 @@
node_modules
size-plugin.json
/build
/*.log

22
README.md Normal file
View file

@ -0,0 +1,22 @@
# huge-link
## CLI Commands
``` bash
# install dependencies
npm install
# serve with hot reload at localhost:8080
npm run dev
# build for production with minification
npm run build
# test the production build locally
npm run serve
# run tests with jest and enzyme
npm run test
```
For detailed explanation on how things work, checkout the [CLI Readme](https://github.com/developit/preact-cli/blob/master/README.md).

15419
package-lock.json generated Normal file

File diff suppressed because it is too large Load diff

41
package.json Normal file
View file

@ -0,0 +1,41 @@
{
"private": true,
"name": "huge-link",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"build": "preact build",
"serve": "sirv build --port 8080 --cors --single",
"dev": "preact watch",
"lint": "eslint src",
"test": "jest"
},
"eslintConfig": {
"extends": "preact",
"ignorePatterns": [
"build/"
]
},
"devDependencies": {
"enzyme": "^3.10.0",
"enzyme-adapter-preact-pure": "^2.0.0",
"eslint": "^6.0.1",
"eslint-config-preact": "^1.1.0",
"jest": "^24.9.0",
"jest-preset-preact": "^1.0.0",
"preact-cli": "^3.0.0",
"sirv-cli": "1.0.3"
},
"dependencies": {
"preact": "^10.3.2",
"preact-render-to-string": "^5.1.4",
"preact-router": "^3.2.1"
},
"jest": {
"preset": "jest-preset-preact",
"setupFiles": [
"<rootDir>/tests/__mocks__/browserMocks.js",
"<rootDir>/tests/__mocks__/setupTests.js"
]
}
}

30
src/app.js Normal file
View file

@ -0,0 +1,30 @@
import {h} from 'preact'
import {useState} from 'preact/hooks'
import {Router} from 'preact-router'
import Editor from './routes/editor'
import Post from './routes/post'
const App = () => {
const [markdown, setMarkdown] = useState('')
return (<main>
<Router>
<Editor
path='/'
markdown={ markdown }
{ ...{setMarkdown} } />
<Post
path='/preview/'
mode='preview'
payload={ markdown }
{ ...{setMarkdown} } />
<Post
path='/p/:payload'
mode='post'
{ ...{setMarkdown} } />
</Router>
</main>)
}
export default App

4
src/index.js Normal file
View file

@ -0,0 +1,4 @@
import './style'
import App from './app'
export default App

21
src/manifest.json Normal file
View file

@ -0,0 +1,21 @@
{
"name": "huge-link",
"short_name": "huge-link",
"start_url": "/",
"display": "standalone",
"orientation": "portrait",
"background_color": "#fff",
"theme_color": "#673ab8",
"icons": [
{
"src": "/assets/icons/android-chrome-192x192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "/assets/icons/android-chrome-512x512.png",
"type": "image/png",
"sizes": "512x512"
}
]
}

View file

@ -0,0 +1,16 @@
import {h} from 'preact'
import {Link} from 'preact-router/match'
const Editor = ({markdown, setMarkdown}) => (
<section>
<textarea
onInput={ ({target}) => setMarkdown(target.value) }>
{ markdown }
</textarea>
<Link href='/preview'>
Preview
</Link>
</section>)
export default Editor

33
src/routes/post/index.js Normal file
View file

@ -0,0 +1,33 @@
import {h} from 'preact'
import {Link} from 'preact-router/match'
const emptyControls = null
const previewContorls = 'controls placeholder'
const noop = _ => _
const decode = noop
const Post = ({mode, payload, setMarkdown}) => {
const [controls, decodeFn] = {
preview: [previewContorls, noop],
post: [emptyControls, decode]
}[mode]
const markdown = decodeFn(payload)
setMarkdown(markdown)
return (<section>
{ controls }
<article>
{ markdown }
</article>
<Link href='/'>
Edit post
</Link>
</section>)
}
export default Post

3
src/style/index.css Normal file
View file

@ -0,0 +1,3 @@
html, body {
}

4
src/sw.js Normal file
View file

@ -0,0 +1,4 @@
import { getFiles, setupPrecaching, setupRouting } from 'preact-cli/sw/'
setupRouting()
setupPrecaching(getFiles())

15
src/template.html Normal file
View file

@ -0,0 +1,15 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title><% preact.title %></title>
<meta name="viewport" content="width=device-width,initial-scale=1">
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes">
<link rel="apple-touch-icon" href="/assets/icons/apple-touch-icon.png">
<% preact.headEnd %>
</head>
<body>
<% preact.bodyEnd %>
</body>
</html>