Skip to content

Commit 89c6334

Browse files
committed
Looks great.
1 parent 4fae0fa commit 89c6334

File tree

4 files changed

+28
-6
lines changed

4 files changed

+28
-6
lines changed

src/api.js

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,23 @@ export async function getPeopleToFollow(state) {
6363
// this is costly so we cache it
6464
}
6565

66-
export async function newPost(state) {
67-
66+
export async function newPost(submitEvent, state) {
67+
const form = submitEvent.target;
68+
const Gist = g.getGist();
69+
const obj = {
70+
description: form.description.value,
71+
public: true,
72+
files: {
73+
['post.md']: {
74+
filename: 'post.md',
75+
content: form.content.value
76+
}
77+
}
78+
};
79+
console.log({obj});
80+
const gist = await Gist.create(obj);
81+
form.reset();
82+
return gist;
6883
}
6984

7085
export function sortPostsByMostRecent(posts) {

src/views/NewPost.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
import {R,X} from '../../node_modules/brutalist-web/r.js';
2+
import {newPost} from '../api.js';
23

34
export default function NewPost(state) {
45
return R`${
56
showNewPost(state) ? R`
67
<div class=newpost>
78
<h1>${state.currentFeed !== state.name ? "My feed" : "My posts" }</h1>
89
<article class="post view edit">
9-
<section class="post edit">
10+
<form submit=${e => (e.preventDefault(), newPost(e, state))} action=#post class="post edit">
1011
<p>
11-
<input name=tags placeholder=tags>
12+
<input required name=description placeholder=description>
1213
<p>
13-
<textarea name=post class="markdown live-mode"></textarea>
14+
<textarea required placeholder="What do you want to say?" name=content></textarea>
1415
<p>
1516
<button class=post>Post</button>
1617
</section>

src/views/Post.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export default function Post(post) {
77
<ul>
88
${Object.values(post.files).map(file => X`
99
<li>
10-
<header>${file.filename}</header>
10+
<header>${file.filename !== 'post.md' ? file.filename : ''}</header>
1111
<section class=content>
1212
<pre>${R.skip((console.log(file.content),file.content))}</pre>
1313
</section>

style/style.css

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@
1919
display: none;
2020
}
2121

22+
article.post pre {
23+
overflow-x:auto;
24+
max-height: 200vh;
25+
overflow-y:auto;
26+
}
27+
2228
/* general semantic grid areas */
2329
.holygrail > header {
2430
display: flex;

0 commit comments

Comments
 (0)