Skip to content

Commit c78e2f0

Browse files
authored
Merge pull request #1226 from thunderstore-io/10-08-_communities_second_qa_fixes
/communities second QA fixes
2 parents a14c9e2 + 554441b commit c78e2f0

File tree

27 files changed

+650
-298
lines changed

27 files changed

+650
-298
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
.idea
22
/node_modules/
33
**/yarn-error.log
4+
.npmrc

apps/cyberstorm-remix/Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ RUN apk add --no-cache libc6-compat
44

55
WORKDIR /app
66

7-
COPY package.json yarn.lock babel.config.js .eslintrc.json .eslintignore .yarnrc .prettierrc .prettierignore .stylelintrc ./
7+
COPY package.json yarn.lock babel.config.js eslint.config.mjs .eslintignore .yarnrc .prettierrc .prettierignore .stylelintrc ./
88
COPY .yarn ./.yarn
99
COPY packages ./packages
1010
COPY apps/cyberstorm-remix ./apps/cyberstorm-remix

apps/cyberstorm-remix/app/communities/SearchAndOrder.module.css

+5-7
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,9 @@
77

88
.searchTextInput {
99
display: flex;
10+
flex: 1;
1011
flex-direction: column;
1112
gap: var(--space--8);
12-
width: 50%;
13-
}
14-
15-
.searchInput {
16-
max-width: 26.25rem;
1713
}
1814

1915
.searchFilters {
@@ -43,8 +39,10 @@
4339
.searchFilters > span {
4440
display: none;
4541
}
42+
}
4643

47-
.searchInput {
48-
max-width: 100%;
44+
@media (width > 40rem) {
45+
.searchTextInput {
46+
max-width: 26.25rem;
4947
}
5048
}

apps/cyberstorm-remix/app/communities/communities.tsx

+19-37
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,11 @@ import { faGhost, faFire } from "@fortawesome/free-solid-svg-icons";
2525
import { useDebounce } from "use-debounce";
2626
import {
2727
useLoaderData,
28-
useNavigation,
28+
useNavigationType,
29+
// useNavigation,
2930
useSearchParams,
3031
} from "@remix-run/react";
31-
import { Communities, Community } from "@thunderstore/dapper/types";
32+
import { Communities } from "@thunderstore/dapper/types";
3233
import { getDapper } from "cyberstorm/dapper/sessionUtils";
3334

3435
export const meta: MetaFunction = () => {
@@ -90,8 +91,11 @@ export async function clientLoader({ request }: LoaderFunctionArgs) {
9091

9192
export default function CommunitiesPage() {
9293
const communitiesData = useLoaderData<typeof loader | typeof clientLoader>();
94+
const navigationType = useNavigationType();
95+
9396
const [searchParams, setSearchParams] = useSearchParams();
94-
const navigation = useNavigation();
97+
// TODO: Disabled until we can figure out how a proper way to display skeletons
98+
// const navigation = useNavigation();
9599

96100
const changeOrder = (v: SortOptions) => {
97101
searchParams.set("order", v);
@@ -101,17 +105,24 @@ export default function CommunitiesPage() {
101105
const [searchValue, setSearchValue] = useState(
102106
searchParams.getAll("search").join(" ")
103107
);
108+
109+
useEffect(() => {
110+
if (navigationType === "POP") {
111+
setSearchValue(searchParams.getAll("search").join(" "));
112+
}
113+
}, [searchParams]);
114+
104115
const [debouncedSearchValue] = useDebounce(searchValue, 300, {
105116
maxWait: 300,
106117
});
107118

108119
useEffect(() => {
109120
if (debouncedSearchValue === "") {
110121
searchParams.delete("search");
111-
setSearchParams(searchParams);
122+
setSearchParams(searchParams, { replace: true });
112123
} else {
113124
searchParams.set("search", debouncedSearchValue);
114-
setSearchParams(searchParams);
125+
setSearchParams(searchParams, { replace: true });
115126
}
116127
}, [debouncedSearchValue]);
117128

@@ -145,7 +156,6 @@ export default function CommunitiesPage() {
145156
clearValue={() => setSearchValue("")}
146157
leftIcon={<FontAwesomeIcon icon={faSearch} />}
147158
csColor="cyber-green"
148-
rootClasses={searchAndOrderStyles.searchInput}
149159
id="communitiesSearchInput"
150160
/>
151161
</div>
@@ -161,48 +171,20 @@ export default function CommunitiesPage() {
161171
</div>
162172
</Container>
163173

164-
{navigation.state === "loading" ? (
174+
<CommunitiesList communitiesData={communitiesData} />
175+
{/* {navigation.state === "loading" ? (
165176
<CommunitiesListSkeleton />
166177
) : (
167178
<CommunitiesList communitiesData={communitiesData} />
168-
)}
179+
)} */}
169180
</main>
170181
</>
171182
);
172183
}
173184

174-
function comparePackageCount(a: Community, b: Community) {
175-
if (a.total_package_count < b.total_package_count) {
176-
return 1;
177-
}
178-
if (a.total_package_count > b.total_package_count) {
179-
return -1;
180-
}
181-
return 0;
182-
}
183-
184185
function CommunitiesList(props: { communitiesData: Communities }) {
185186
const { communitiesData } = props;
186187

187-
const topDogs: Community[] = [];
188-
communitiesData.results.reduce((prevCommunity, currentCommunity) => {
189-
if (topDogs.length > 4) {
190-
topDogs.sort(comparePackageCount);
191-
const lastDog = topDogs.at(-1);
192-
if (
193-
(lastDog ? lastDog.total_package_count : 0) <
194-
currentCommunity.total_package_count
195-
) {
196-
topDogs.pop();
197-
topDogs.push(currentCommunity);
198-
}
199-
} else {
200-
topDogs.push(currentCommunity);
201-
}
202-
return topDogs;
203-
}, topDogs);
204-
const flatDogs = topDogs.map((community) => community.identifier);
205-
206188
if (communitiesData.results.length > 0) {
207189
return (
208190
<div className={communitiesListStyles.root}>

apps/cyberstorm-remix/cyberstorm/navigation/DesktopLoginPopover.tsx

-6
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,6 @@ import { classnames } from "@thunderstore/cyberstorm/src/utils/utils";
1414
import { buildAuthLoginUrl } from "cyberstorm/utils/ThunderstoreAuth";
1515
import { faDiscord, faGithub } from "@fortawesome/free-brands-svg-icons";
1616

17-
import styles from "./Navigation.module.css";
18-
import { Modal, NewButton, NewIcon } from "@thunderstore/cyberstorm";
19-
import { LoginList } from "./LoginList";
20-
import { faArrowRightToBracket } from "@fortawesome/free-solid-svg-icons";
21-
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
22-
2317
export function DesktopLoginPopover() {
2418
return (
2519
<Modal

apps/cyberstorm-remix/cyberstorm/navigation/DevelopersDropDown.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export function DevelopersDropDown() {
2424
</NewButton>
2525
}
2626
csVariant="default"
27-
csColor="surface-alpha"
27+
csColor="surface"
2828
rootClasses={styles.root}
2929
>
3030
<NewDropDownItem>

apps/cyberstorm-remix/cyberstorm/navigation/MobileUserPopoverContent.tsx

+8-7
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import styles from "./Navigation.module.css";
55
import {
66
Avatar,
77
Menu,
8+
NewButton,
89
NewIcon,
910
NewLink,
1011
NewText,
@@ -36,17 +37,17 @@ export function MobileUserPopoverContent(props: { user: CurrentUser }) {
3637
</div>
3738
}
3839
controls={
39-
<button
40+
<NewButton
4041
{...{
4142
popovertarget: "mobileNavAccount",
4243
popovertargetaction: "close",
4344
}}
44-
className={styles.popoverCloseButton}
45-
>
46-
<NewIcon csMode="inline" csVariant="tertiary" noWrapper>
47-
<FontAwesomeIcon icon={faLongArrowLeft} />
48-
</NewIcon>
49-
</button>
45+
aria-label="Back"
46+
mode="iconButton"
47+
csSize="m"
48+
csVariant="tertiaryDimmed"
49+
icon={faLongArrowLeft}
50+
/>
5051
}
5152
>
5253
{user.username ? (

apps/cyberstorm-remix/cyberstorm/navigation/Navigation.module.css

+30-12
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,9 @@
6868

6969
.mobileNavMenuDevelopersButton {
7070
display: flex;
71-
gap: 1rem;
7271
align-items: center;
7372
align-self: stretch;
7473
justify-content: space-between;
75-
padding: 1rem;
7674
color: var(--color-primary);
7775
background: transparent;
7876
}
@@ -96,6 +94,14 @@ button.mobileNavItem {
9694
background: transparent;
9795
}
9896

97+
.mobileNavItem:active {
98+
color: var(--color-cyber-green--5);
99+
}
100+
101+
.mobileNavItem:hover {
102+
color: var(--color-secondary);
103+
}
104+
99105
.mobileNavItemIcon {
100106
height: 1.375rem;
101107
}
@@ -123,14 +129,6 @@ button.mobileNavItem {
123129
width: 100%;
124130
}
125131

126-
.mobileNavPopoverListLink {
127-
display: flex;
128-
gap: 1rem;
129-
align-items: center;
130-
align-self: stretch;
131-
padding: 1rem;
132-
}
133-
134132
.popoverCloseButton {
135133
width: 2.75rem;
136134
height: 2.875rem;
@@ -244,11 +242,31 @@ button.mobileNavItem {
244242
}
245243

246244
.loginButton {
247-
height: 2.25rem;
248-
padding: 0.75rem;
245+
height: 2.25rem !important;
246+
padding: 0.75rem !important;
249247
}
250248

251249
.headerRightSide {
252250
display: flex;
253251
gap: 1rem;
254252
}
253+
254+
.divider {
255+
align-self: stretch;
256+
height: 1px;
257+
margin: var(--space--16) var(--space--8);
258+
background: var(--color-surface--7);
259+
}
260+
261+
.navMenuItem {
262+
display: flex;
263+
gap: var(--gap--16);
264+
align-items: center;
265+
align-self: stretch;
266+
padding: var(--space--16);
267+
border-radius: var(--border-radius--8);
268+
}
269+
270+
.navMenuItem:hover {
271+
background: var(--color-surface--9);
272+
}

0 commit comments

Comments
 (0)