Skip to content

Commit fd1307f

Browse files
committed
v2.0.1
* `new` support lower resolutions by switching to single letters * `chg` control panel lower-cased to better fit the design
1 parent df95270 commit fd1307f

File tree

5 files changed

+39
-15
lines changed

5 files changed

+39
-15
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,10 @@
11
# Changelog
22

3+
## v2.0.1
4+
5+
* `new` support lower resolutions by switching to single letters
6+
* `chg` control panel lower-cased to better fit the design
7+
38
## v2.0.0
49

510
* `new` the project is rewritten with TypeScript and [Plasmo framework](https://docs.plasmo.com)

app/components/ControlPanel.tsx

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ const ControlPanel = (): ReactElement => {
1212
const [activeSort, setActiveSort] = useState<SortVariant>(lastActiveSort);
1313
const { parsedRows, footerRows } = useParsedRows();
1414
const sortButtonProps = { activeSort, setActiveSort };
15-
const sortOptions: { sortBy: SortVariant; text: string }[] = [
16-
{ sortBy: 'points', text: 'Points' },
17-
{ sortBy: 'time', text: 'Time' },
18-
{ sortBy: 'comments', text: 'Comments' },
19-
{ sortBy: 'default', text: 'Original' },
15+
const sortOptions: { sortBy: SortVariant; text: string; shortcut: string }[] = [
16+
{ sortBy: 'points', text: 'points', shortcut: 'P' },
17+
{ sortBy: 'time', text: 'pime', shortcut: 'T' },
18+
{ sortBy: 'comments', text: 'pomments', shortcut: 'C' },
19+
{ sortBy: 'default', text: 'peset', shortcut: 'R' },
2020
];
2121

2222
useEffect(() => {
@@ -25,13 +25,11 @@ const ControlPanel = (): ReactElement => {
2525

2626
return (
2727
<>
28-
<span className="hns-sort-by-label">Sort By:</span>
28+
<span className="hns-sort-by-label">sort by:</span>
2929

3030
{sortOptions.map((option, index) => (
3131
<Fragment key={option.sortBy}>
32-
<SortButton sortBy={option.sortBy} {...sortButtonProps}>
33-
{option.text}
34-
</SortButton>
32+
<SortButton {...sortButtonProps} {...option} />
3533
{index < sortOptions.length - 1 && ' · '}
3634
</Fragment>
3735
))}

app/components/SortButton.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import clsx from 'clsx';
2-
import { useCallback, type ReactElement, type ReactNode } from 'react';
2+
import { useCallback, type ReactElement } from 'react';
33

44
import type { SortVariant } from '~app/types';
55
import { setLastActiveSort } from '~app/utils/storage';
@@ -8,10 +8,11 @@ type ControlPanelButtonProps = {
88
sortBy: SortVariant;
99
activeSort: SortVariant;
1010
setActiveSort: (sortBy: SortVariant) => void;
11-
children: ReactNode;
11+
text: string;
12+
shortcut: string;
1213
};
1314

14-
const SortButton = ({ sortBy, activeSort, setActiveSort, children }: ControlPanelButtonProps): ReactElement => {
15+
const SortButton = ({ sortBy, activeSort, setActiveSort, text, shortcut }: ControlPanelButtonProps): ReactElement => {
1516
const isActive = activeSort === sortBy;
1617
const defaultSort = sortBy === 'default';
1718

@@ -26,7 +27,8 @@ const SortButton = ({ sortBy, activeSort, setActiveSort, children }: ControlPane
2627
onClick={updateActiveSort}
2728
className={clsx('hns-btn', isActive && 'hns-active')}
2829
title={defaultSort ? 'Original sort order' : `Sort by ${sortBy}`}>
29-
{children}
30+
<span className="hns-btn-text">{text}</span>
31+
<span className="hns-btn-shortcut">{shortcut}</span>
3032
</span>
3133
);
3234
};

content.css

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,14 @@
1515
margin: 0 5px;
1616
}
1717

18+
.hns-btn-text {
19+
display: none;
20+
}
21+
22+
.hns-btn-shortcut {
23+
display: inline;
24+
}
25+
1826
.hns-active {
1927
color: #fff;
2028
}
@@ -27,3 +35,13 @@
2735
display: inline-block;
2836
margin: 0 10px;
2937
}
38+
39+
@media screen and (min-width: 1280px) {
40+
.hns-btn-text {
41+
display: inline;
42+
}
43+
44+
.hns-btn-shortcut {
45+
display: none;
46+
}
47+
}

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
{
22
"name": "hacked_news_sorted",
33
"displayName": "Hacker News Sorted",
4-
"version": "2.0.0",
4+
"version": "2.0.1",
55
"description": "Gives the ability to sort posts on the news.ycombinator.com site by the number of points, time, or comments.",
66
"author": "Leonid Svyatov <leonid@svyatov.com>",
77
"scripts": {
88
"dev": "plasmo dev",
99
"build": "plasmo build",
10-
"package": "plasmo package"
10+
"package": "plasmo package",
11+
"release": "pnpm run build && pnpm run package"
1112
},
1213
"dependencies": {
1314
"clsx": "^2.1.0",

0 commit comments

Comments
 (0)