Skip to content

Commit f0e9171

Browse files
authored
Merge pull request #19 from pierreyoda/website-changelog
✨ Website: changelog page
2 parents 9eb044f + 044c189 commit f0e9171

11 files changed

Lines changed: 146 additions & 16 deletions

File tree

‎src/app.rs‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ impl<'a> AppContext<'a> {
5757
self.history
5858
}
5959

60+
pub fn get_history_mut(&mut self) -> &mut AppHistory {
61+
self.history
62+
}
63+
6064
pub fn get_inputs(&self) -> &InputsController {
6165
self.inputs
6266
}

‎src/ui/components/resume_list.rs‎

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use crate::{
1515
api::{HnClient, types::HnItemIdScalar},
1616
app::{
1717
AppContext,
18-
history::{ResumeItemHistoryData, SynchronizedHistoryItem},
18+
history::{HistoryPersistCommand, ResumeItemHistoryData, SynchronizedHistoryItem},
1919
},
2020
errors::Result,
2121
ui::{
@@ -39,7 +39,7 @@ impl ItemWithId<HnItemIdScalar> for ResumeItemHistoryData {
3939

4040
#[derive(Debug)]
4141
pub struct ResumeList {
42-
initialized: bool,
42+
loaded: bool,
4343
list_cutoff: usize,
4444
/// The Item selected in the list, waiting to be fetched.
4545
///
@@ -52,7 +52,7 @@ pub struct ResumeList {
5252
impl Default for ResumeList {
5353
fn default() -> Self {
5454
Self {
55-
initialized: false,
55+
loaded: false,
5656
list_cutoff: RESUME_SCREEN_MAX_DISPLAYED_ITEMS,
5757
pending_selected_item_id: None,
5858
list_state: CustomListState::with_items(vec![]),
@@ -69,7 +69,7 @@ impl UiComponent for ResumeList {
6969
}
7070

7171
fn before_unmount(&mut self) {
72-
self.initialized = false;
72+
self.loaded = false;
7373
self.pending_selected_item_id = None;
7474
}
7575

@@ -78,11 +78,11 @@ impl UiComponent for ResumeList {
7878
_elapsed_ticks: UiTickScalar,
7979
_ctx: &AppContext,
8080
) -> Result<bool> {
81-
Ok(!self.initialized || self.pending_selected_item_id.is_some())
81+
Ok(!self.loaded || self.pending_selected_item_id.is_some())
8282
}
8383

8484
async fn update(&mut self, client: &mut HnClient, ctx: &mut AppContext) -> Result<()> {
85-
if !self.initialized {
85+
if !self.loaded {
8686
let resume_items: Vec<_> = ctx
8787
.get_history()
8888
.restored_resume_items()
@@ -94,7 +94,7 @@ impl UiComponent for ResumeList {
9494
if !self.list_state.is_empty() && self.list_state.selected().is_none() {
9595
self.list_state.select(Some(0));
9696
}
97-
self.initialized = true;
97+
self.loaded = true;
9898
}
9999

100100
if let Some(item_id) = self.pending_selected_item_id.take() {
@@ -143,7 +143,14 @@ impl UiComponent for ResumeList {
143143
true
144144
} else if let Some(selected_index) = selected {
145145
let selected_item_id = self.list_state.get_items()[selected_index].get_id();
146-
if inputs.is_active(&ApplicationAction::OpenHackerNewsLink)
146+
if inputs.is_active(&ApplicationAction::ResumeClearEntry) {
147+
ctx.get_history_mut()
148+
.persist(&[HistoryPersistCommand::ResumeRemove {
149+
item_id: selected_item_id,
150+
}]);
151+
self.loaded = false;
152+
true
153+
} else if inputs.is_active(&ApplicationAction::OpenHackerNewsLink)
147154
// the external URL of a stored Item, if any, is unknown until it is
148155
// fetched: both link actions can only open its Hacker News page here
149156
|| inputs.is_active(&ApplicationAction::OpenExternalOrHackerNewsLink)

‎src/ui/handlers.rs‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,8 @@ pub enum ApplicationAction {
117117
ToggleFocusResults,
118118
// settings screen
119119
SettingsToggleControl,
120+
// resume screen
121+
ResumeClearEntry,
120122
}
121123

122124
impl ApplicationAction {
@@ -169,6 +171,8 @@ impl ApplicationAction {
169171
ToggleFocusResults => inputs.key == Key::Enter,
170172
// settings screen
171173
SettingsToggleControl => inputs.key == Key::Tab,
174+
// resume screen
175+
ResumeClearEntry => inputs.key == Key::Char('c'),
172176
}
173177
}
174178

‎src/ui/helper.rs‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -189,8 +189,8 @@ impl ContextualHelper {
189189

190190
fn render_resume_page_help(&self, f: &mut RenderFrame, inside: Rect) {
191191
let widgets = vec![
192-
HelpWidget::Text("⬆️ / i or ⬇️ / k to navigate".into()),
193-
HelpWidget::KeyReminder('⬅', "go back".into(), Key::Escape),
192+
HelpWidget::KeyReminder('c', "delete entry".into(), Key::Char('c')),
193+
HelpWidget::KeyReminder('🎯', "go to item".into(), Key::Enter),
194194
];
195195
Self::render_widgets(f, inside, &widgets);
196196
}

‎src/ui/screens/home.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ impl HomeScreen {
4343
section,
4444
breakpoints: Breakpoints::new("home_screen", &[20, 65, 15])
4545
.breakpoint(25, &[10, 80, 10])
46-
.breakpoint(45, &[5, 88, 7]),
46+
.breakpoint(45, &[8, 85, 7]),
4747
}
4848
}
4949
}

‎src/ui/screens/resume.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ impl ResumeScreen {
3636
Self {
3737
breakpoints: Breakpoints::new("resume_screen", &[20, 80])
3838
.breakpoint(25, &[10, 90])
39-
.breakpoint(45, &[5, 95]),
39+
.breakpoint(45, &[8, 92]),
4040
}
4141
}
4242
}

‎website/src/lib/Header.svelte‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,16 @@
1414
<h1 class="hidden">hncli</h1>
1515
</a>
1616
</nav>
17-
<div class="flex items-center sm:pr-12 sm:justify-around pt-4 sm:pt-0">
17+
<div class="flex flex-col sm:flex-row items-center sm:pr-12 sm:justify-around pt-4 sm:pt-0 gap-6 md:gap-12">
18+
<a href={resolve("/changelog")} class="text-4xl sm:text-3xl font-medium text-white"> Changelog </a>
1819
<ExternalLink
1920
href="https://www.newstackwhodis.com/blog/?tag=Rust"
2021
underline={false}
2122
red={false}
22-
extraClass="mr-6 no-underline text-4xl sm:text-3xl font-medium">Blog</ExternalLink
23+
extraClass="no-underline text-4xl sm:text-3xl font-medium">Blog</ExternalLink
2324
>
2425
<ExternalLink href="https://github.com/pierreyoda/hncli" red={false} extraClass="cursor-pointer">
25-
<img alt="GitHub logo" src={GitHubLogo} class="w-10 h-10 ml-3 md:ml-6 hover:opacity-80" />
26+
<img alt="GitHub logo" src={GitHubLogo} class="w-10 h-10 hover:opacity-80" />
2627
</ExternalLink>
2728
</div>
2829
</header>
585 KB
Loading
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
<script module lang="ts">
2+
export type ChangelogEntryProps = {
3+
/** Format: "0.5.0" */
4+
tag: string;
5+
subtitle?: string;
6+
changes?: readonly string[];
7+
} & ({
8+
media: "image";
9+
imageSrc: string;
10+
imageAlt: string;
11+
} | {
12+
media: "video";
13+
videoSrc: string;
14+
});
15+
</script>
16+
17+
<script lang="ts">
18+
import { resolve } from "$app/paths";
19+
20+
const { tag, subtitle, changes, ...props }: ChangelogEntryProps = $props();
21+
</script>
22+
23+
<article class="entry">
24+
<div class="title">
25+
<a href={resolve(`/changelog#${tag}`)} class="link">
26+
#
27+
</a>
28+
<h2 class="tag" id={tag}>v{tag}</h2>
29+
</div>
30+
{#if subtitle}
31+
<h3 class="subtitle">{subtitle}</h3>
32+
{/if}
33+
{#if props.media === "image"}
34+
<img class="media" alt={props.imageAlt} src={props.imageSrc} />
35+
{:else}
36+
<video class="media" src={props.videoSrc} autoplay muted playsinline loop></video>
37+
{/if}
38+
{#if (changes?.length ?? 0) > 0}
39+
<ul class="list-disc text-left">
40+
{#each changes as change (change)}
41+
<li>{change}</li>
42+
{/each}
43+
</ul>
44+
{/if}
45+
</article>
46+
47+
<style lang="postcss">
48+
@reference "tailwindcss";
49+
50+
.entry {
51+
@apply flex flex-col items-center gap-2 py-6 text-center text-white;
52+
53+
.title {
54+
@apply flex items-center gap-2;
55+
@apply font-mono text-2xl font-semibold tracking-tight;
56+
.link {
57+
@apply text-gray-300 hover:text-gray-500 transition-colors duration-500;
58+
}
59+
}
60+
.media {
61+
@apply h-auto w-180;
62+
}
63+
}
64+
</style>

‎website/src/lib/content/HeroTitle.svelte‎

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
<script lang="ts">
2+
import { resolve } from "$app/paths";
3+
24
import ExternalLink from "$lib/ExternalLink.svelte";
35
</script>
46

@@ -11,13 +13,19 @@
1113
<p class="mt-6 text-lg text-gray-600 font-medium">
1214
Convenient, fast, and will run well on most computers, even old ones.
1315
</p>
14-
<p class="text-xl font-medium tracking-tight text-gray-700 mt-4">
16+
<p class="flex flex-col text-xl font-medium tracking-tight text-gray-700 mt-4 gap-4">
1517
<ExternalLink
1618
extraClass="no-underline mt-4"
1719
href="https://www.newstackwhodis.com/blog/hncli-1-concept#an-hacker-news-terminal-ui-concept-and-road-to-release"
1820
>
1921
Concept, vision and UX</ExternalLink
2022
>
23+
<a
24+
href={resolve("/changelog")}
25+
class="font-semibold transition-colors duration-400 ease-in-out text-hncli-dark-red hover:text-hncli-dark-red/60 underline"
26+
>
27+
Changelog
28+
</a>
2129
</p>
2230
</section>
2331

0 commit comments

Comments
 (0)