Skip to content

Commit e70940c

Browse files
author
Tim Cuthbert
committed
search -> question nav flow
1 parent 68ac52c commit e70940c

File tree

6 files changed

+262
-7
lines changed

6 files changed

+262
-7
lines changed

app/src/App.svelte

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
}
3030
3131
function handleGotoSearch() {
32+
console.log("tron");
33+
3234
section = "search";
3335
}
3436
</script>
@@ -47,9 +49,9 @@
4749
</h3>
4850

4951
{#if section === 'question'}
50-
<Question on:gotoSearch={handleGotoSearch} {questionId} {vscode} />
52+
<Question on:back={handleGotoSearch} {questionId} {vscode} />
5153
{:else if section === 'leeeeeeet'}
5254
<Leet />
5355
{:else if section === 'search'}
54-
<Search {searchQuery} {vscode} />
56+
<Search on:gotoQuestion={handleGotoQuestion} {searchQuery} {vscode} />
5557
{/if}

app/src/question/Question.svelte

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import Tag from "../common/Tag.svelte";
1212
1313
export let questionId;
14+
export let vscode;
1415
let question;
1516
1617
const baseUri = "https://api.stackexchange.com/2.2/";
@@ -90,11 +91,13 @@
9091
</style>
9192

9293
{#if question}
94+
9395
<QuestionTitle
9496
title={question.title}
9597
asked={question.creation_date}
9698
active={question.last_activity_date}
97-
viewed={question.view_count} />
99+
viewed={question.view_count}
100+
on:back />
98101

99102
<div class="question-container">
100103

app/src/question/QuestionTitle.svelte

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
<script>
2+
import { createEventDispatcher } from "svelte";
23
import { fade } from "svelte/transition";
34
import { fromUnixTime, formatDistanceToNow } from "date-fns";
45
@@ -7,6 +8,12 @@
78
export let active;
89
export let viewed;
910
11+
const dispatch = createEventDispatcher();
12+
function navigateBack() {
13+
dispatch("back", {
14+
isBack: true
15+
});
16+
}
1017
</script>
1118

1219
<style>
@@ -21,11 +28,29 @@
2128
span {
2229
margin-right: 20px;
2330
}
31+
.back::before {
32+
border-style: solid;
33+
border-width: 2px 2px 0 0;
34+
content: "";
35+
display: inline-block;
36+
height: 0.45em;
37+
left: 12px;
38+
position: relative;
39+
top: 13px;
40+
transform: rotate(-135deg);
41+
vertical-align: top;
42+
width: 0.45em;
43+
cursor: pointer;
44+
}
2445
</style>
2546

2647
<div class="title-container" in:fade>
2748
<!-- <small on:click={navigateBack}>back</small> -->
28-
<h1>{title}</h1>
49+
50+
<h1>
51+
<span class="back" on:click={navigateBack} />
52+
{title}
53+
</h1>
2954
<div>
3055
Asked
3156
<span>

app/src/search/Search.svelte

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
let isLoading = true;
1313
1414
const baseUri = "https://api.stackexchange.com/2.2/";
15-
const filter = "!)IMBoe*2yeLILOkExfCIybFW_Hi2HQB6AF_Q";
15+
const filter = "!E-NkAUAPp-dl_BLxWqa1LE5g5C*VNBKpydoTSQ";
1616
const key = "VP5SbX4dbH8MJUft7hjoaA((";
1717
const site = "stackoverflow";
1818
const uri = `${baseUri}search/advanced?q=${searchQuery}&page=1&pagesize=10&order=desc&sort=relevance&site=${site}&filter=${filter}&key=${key}`;
@@ -54,5 +54,5 @@
5454
{:else if !isLoading && searchData.length === 0}
5555
<SearchNoResults {searchQuery} />
5656
{:else}
57-
<SearchResultBlock {searchData} />
57+
<SearchResultBlock {searchData} on:gotoQuestion on:navigateBack />
5858
{/if}

app/src/search/SearchResultBlock.svelte

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
11
<script>
22
import { fade } from "svelte/transition";
33
import { createEventDispatcher } from "svelte";
4+
import { format, fromUnixTime } from "date-fns";
45
import SearchBottomActionButtons from "./SearchBottomActionButtons.svelte";
56
import Tag from "../common/Tag.svelte";
67
78
export let searchData;
89
10+
function setAskedValue(date) {
11+
const dateFromUnix = fromUnixTime(date);
12+
return ` ${format(dateFromUnix, "MMM dd")} '${format(
13+
dateFromUnix,
14+
"yy"
15+
)} at ${format(dateFromUnix, "HH:mm")}`;
16+
}
17+
918
const dispatch = createEventDispatcher();
1019
function navigateToQuestion(questionId) {
1120
dispatch("gotoQuestion", {
@@ -110,7 +119,7 @@
110119
{/each}
111120

112121
<div class="asked-info">
113-
by
122+
asked {setAskedValue(searchItem.creation_date)} by
114123
<i>{searchItem.owner.display_name}</i>
115124
</div>
116125
</div>

app/src/search/filters.md

Lines changed: 216 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,216 @@
1+
# API Filters
2+
3+
```
4+
current applied filter
5+
!E-NkAUAPp-dl_BLxWqa1LE5g5C*VNBKpydoTSQ
6+
```
7+
<details>
8+
<summary><strong> answer (0/27)</strong></summary>
9+
10+
- accepted
11+
- answer_id
12+
- awarded_bounty_amount
13+
- awarded_bounty_users
14+
- body
15+
- body_markdown
16+
- can_flag
17+
- comment_count
18+
- comments
19+
- community_owned_date
20+
- creation_date
21+
- down_vote_count
22+
- downvoted
23+
- is_accepted
24+
- last_activity_date
25+
- last_edit_date
26+
- last_editor (shallow_user)
27+
- link
28+
- locked_date
29+
- owner (shallow_user)
30+
- question_id
31+
- score
32+
- share_link
33+
- tags
34+
- title
35+
- up_vote_count
36+
- upvoted
37+
38+
</details>
39+
<details>
40+
<summary><strong> .wrapper (3/12)</strong></summary>
41+
42+
- backoff
43+
- error_id
44+
- error_message
45+
- error_name
46+
- has_more
47+
- **items ✓**
48+
- **page ✓**
49+
- page_size
50+
- quota_max
51+
- quota_remaining
52+
- **total✓**
53+
- type
54+
</details>
55+
56+
<details>
57+
<summary><strong> badge_count (0/3)</strong></summary>
58+
59+
- bronze
60+
- gold
61+
- silver
62+
</details>
63+
64+
<details>
65+
<summary><strong>closed_details (0/5)</strong></summary>
66+
67+
- by_users
68+
- description
69+
- on_hold
70+
- original_questions
71+
- reason
72+
</details>
73+
74+
<details>
75+
<summary><strong>comment (0/13)</strong></summary>
76+
77+
- body
78+
- body_markdown
79+
- can_flag
80+
- comment_id
81+
- creation_date
82+
- edited
83+
- link
84+
- **owner (shallow_us)
85+
- post_id
86+
- post_type
87+
- reply_to_user (shallow_user)
88+
- score
89+
- upvoted
90+
</details>
91+
92+
<details>
93+
<summary><strong>migration_info (0/3)</strong></summary>
94+
95+
- on_date
96+
- other_site (site)
97+
- question_id
98+
</details>
99+
100+
<details>
101+
<summary><strong>notice (0/3)</strong></summary>
102+
103+
- body
104+
- creation_date
105+
- owner_user_id
106+
</details>
107+
108+
<details>
109+
<summary><strong>original_question (0/4)</strong></summary>
110+
111+
- accepted_answer_id
112+
- answer_count
113+
- question_id
114+
- title
115+
</details>
116+
117+
<details>
118+
<summary><strong>question (11/43)</strong></summary>
119+
120+
- **accepted_answer_id ✓**
121+
- **answer_count ✓**
122+
- answers
123+
- body
124+
- **body_markdown✓**
125+
- bounty_amount
126+
- bounty_closes_date
127+
- bounty_user (shallow_user)
128+
- can_close
129+
- can_flag
130+
- close_vote_count
131+
- closed_date
132+
- closed_details (closed_details)
133+
- closed_reason
134+
- comment_count
135+
- comments
136+
- community_owned_date
137+
- creation_date
138+
- delete_vote_count
139+
- down_vote_count
140+
- downvoted
141+
- favorite_count
142+
- favorited
143+
- **is_answered ✓**
144+
- last_activity_date
145+
- last_edit_date
146+
- last_editor (shallow_user)
147+
- **link ✓**
148+
- locked_date
149+
- migrated_from (migration_info)
150+
- migrated_to (migration_info)
151+
- notice (notice)
152+
- owner (shallow_user)
153+
- protected_date
154+
- **question_id ✓**
155+
- reopen_vote_count
156+
- **score ✓**
157+
- share_link
158+
- **tags ✓**
159+
- **title ✓**
160+
- **up_vote_count ✓**
161+
- upvoted
162+
- view_count
163+
</details>
164+
165+
<details>
166+
<summary><strong>related_site (0/4)</strong></summary>
167+
168+
- api_site_parameter
169+
- name
170+
- relation
171+
- site_url
172+
</details>
173+
174+
<details>
175+
<summary><strong>shallow_user (1/8)</strong></summary>
176+
177+
- accept_rate
178+
- badge_counts (badge_count)
179+
- **display_name ✓**
180+
- link
181+
- profile_image
182+
- reputation
183+
- user_id
184+
- user_type
185+
</details>
186+
187+
<details>
188+
<summary><strong>site (0/18)</strong></summary>
189+
190+
- aliases
191+
- api_site_parameter
192+
- audience
193+
- closed_beta_date
194+
- favicon_url
195+
- high_resolution_icon_url
196+
- icon_url
197+
- launch_date
198+
- logo_url
199+
- markdown_extensions
200+
- name
201+
- open_beta_date
202+
- related_sites
203+
- site_state
204+
- site_type
205+
- site_url
206+
- styling (styling)
207+
- twitter_account
208+
</details>
209+
210+
<details>
211+
<summary><strong>styling (0/3)</strong></summary>
212+
213+
- link_color
214+
- tag_background_color
215+
- tag_foreground_color
216+
</details>

0 commit comments

Comments
 (0)