Skip to content

Commit b9712a4

Browse files
committed
alpha version
1 parent addbed0 commit b9712a4

28 files changed

Lines changed: 403 additions & 407 deletions

.prettierrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"trailingComma": "none",
3+
"tabWidth": 2,
4+
"semi": true,
5+
"singleQuote": false,
6+
"printWidth": 100
7+
}

FRONTEND_INSTRUCTIONS.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ Alternatively, if you want to make modifications to the theme, check out the [th
4747
- [Settings](#settings)
4848
- [Create/Edit Article](#createedit-article)
4949
- [Article](#article)
50-
50+
5151

5252
## Layout
5353

readme.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
1-
# WIP Not Functional Yet!!
2-
31
# ![RealWorld Example App](logo.png)
42

53
> ### Solid.js codebase containing real world examples (CRUD, auth, advanced patterns, etc) that adheres to the [RealWorld](https://github.com/gothinkster/realworld) spec and API.
64
75

8-
### [Demo](https://github.com/gothinkster/realworld)    [RealWorld](https://github.com/ryansolid/solid-realworld)
6+
### [Demo](https://ryansolid.github.io/solid-realworld)    [RealWorld](https://github.com/ryansolid/solid-realworld)
97

108

119
This codebase was created to demonstrate a fully fledged fullstack application built with Solid.js including CRUD operations, authentication, routing, pagination, and more.
@@ -14,12 +12,15 @@ We've gone to great lengths to adhere to the Solid.js community styleguides & be
1412

1513
For more information on how to this works with other frontends/backends, head over to the [RealWorld](https://github.com/gothinkster/realworld) repo.
1614

15+
# Getting started
1716

18-
# How it works
17+
To run locally during development:
1918

20-
> Describe the general architecture of your app here
19+
- `npm install` to install all dependencies
20+
- `npm start` to build and serve app locally
21+
- browse to http://localhost:5000/
2122

22-
# Getting started
23+
To create a production build:
2324

24-
> npm install, npm start, etc.
25+
- `npm run build` creates a development build, with all source compiled into ./dist/ folder
2526

rollup.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const plugins = [
1616
}),
1717
resolve({ extensions: [".js", ".jsx"] }),
1818
commonjs(),
19-
process.env.production && terser()
19+
terser()
2020
];
2121

2222
export default {

src/App.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ import NavBar from "./components/NavBar";
44
import Home from "./pages/Home";
55
import Article from "./pages/Article";
66
import Profile from "./pages/Profile";
7+
import Editor from "./pages/Editor";
78

8-
const Editor = lazy(() => import("./pages/Editor")),
9-
Settings = lazy(() => import("./pages/Settings")),
9+
const Settings = lazy(() => import("./pages/Settings")),
1010
Auth = lazy(() => import("./pages/Auth"));
1111

1212
export default () => {
@@ -20,7 +20,7 @@ export default () => {
2020
<>
2121
<NavBar />
2222
<Show when={store.appLoaded}>
23-
<Suspense fallback={"Loading..."}>
23+
<Suspense fallback={<div class="container">Loading...</div>}>
2424
<Switch>
2525
<Match when={match("editor", /^editor\/?(.*)/)}><Editor {...getParams()} /></Match>
2626
<Match when={match("settings", /^settings/)}><Settings /></Match>

src/components/ArticleList.js

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,26 @@
1+
import { useStore } from "../store";
12
import ArticlePreview from "./ArticlePreview";
23

34
export default props => {
4-
const handlePage = (e, v) => {
5-
e.preventDefault();
6-
props.onSetPage(v);
7-
setTimeout(() => window.scrollTo(0, 0), 200);
8-
};
5+
const [{ token }, { unmakeFavorite, makeFavorite }] = useStore(),
6+
handleClickFavorite = (e, article) => {
7+
e.preventDefault();
8+
article.favorited ? unmakeFavorite(slug) : makeFavorite(slug);
9+
},
10+
handlePage = (e, v) => {
11+
e.preventDefault();
12+
props.onSetPage(v);
13+
setTimeout(() => window.scrollTo(0, 0), 200);
14+
};
915
return (
1016
<Suspense fallback={<div class="article-preview">Loading articles...</div>}>
1117
<For
1218
each={props.articles}
1319
fallback={<div class="article-preview">No articles are here... yet.</div>}
1420
>
15-
{article => <ArticlePreview article={article} />}
21+
{article => (
22+
<ArticlePreview article={article} token={token} onClickFavorite={handleClickFavorite} />
23+
)}
1624
</For>
1725
<Show when={props.totalPagesCount > 1}>
1826
<nav>

src/components/ArticlePreview.js

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,20 @@
1-
import { useStore } from "../store";
21
import NavLink from "./NavLink";
32

4-
const FAVORITED_CLASS = 'btn btn-sm btn-primary';
5-
const NOT_FAVORITED_CLASS = 'btn btn-sm btn-outline-primary';
3+
const FAVORITED_CLASS = "btn btn-sm btn-primary";
4+
const NOT_FAVORITED_CLASS = "btn btn-sm btn-outline-primary";
65

7-
export default ({ article }) => {
8-
const [{ token }, { unmakeFavorite, makeFavorite }] = useStore(),
9-
{ title, description, slug, createdAt, tagList, author: { username, image }} = article;
10-
11-
const handleClickFavorite = e => {
12-
e.preventDefault();
13-
article.favorited
14-
? unmakeFavorite(slug)
15-
: makeFavorite(slug);
16-
};
6+
export default ({ article, token, onClickFavorite }) => {
7+
const {
8+
title,
9+
description,
10+
slug,
11+
createdAt,
12+
tagList,
13+
author: { username, image }
14+
} = article;
1715

1816
return (
19-
<div class="article-preview">
17+
<div class="article-preview" model={article}>
2018
<div class="article-meta">
2119
<NavLink href={`@${username}`} route="profile">
2220
<img src={image} alt="" />
@@ -26,14 +24,14 @@ export default ({ article }) => {
2624
<NavLink class="author" href={`@${username}`} route="profile">
2725
{username}
2826
</NavLink>
29-
<span class="date" textContent={/*@once*/new Date(createdAt).toDateString()} />
27+
<span class="date" textContent={/*@once*/ new Date(createdAt).toDateString()} />
3028
</div>
3129

3230
{token && (
3331
<div class="pull-xs-right">
3432
<button
3533
class={article.favorited ? FAVORITED_CLASS : NOT_FAVORITED_CLASS}
36-
onClick={handleClickFavorite}
34+
onClick={onClickFavorite}
3735
>
3836
<i class="ion-heart" /> {article.favoritesCount}
3937
</button>

src/components/NavLink.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { useTransition } from "solid-js";
33

44
export default props => {
55
const { getParams } = useRouter(),
6-
[, start] = useTransition({ timeoutMs: 250 })
6+
[, start] = useTransition({ timeoutMs: 250 });
77
return (
88
<a
99
class={props.class}

0 commit comments

Comments
 (0)