Skip to content

Commit 45cbe58

Browse files
authored
Fix types and clean up some rendering logic (#101)
* Cleaned up a lot, didn't break anything (yet) * Finish making subpages work
1 parent 12ff6c3 commit 45cbe58

File tree

11 files changed

+249
-173
lines changed

11 files changed

+249
-173
lines changed
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
<projects
22
:env="env"
33
:page_title="page_title"
4-
:config="config"
54
:header="header"
65
:is_subpage="is_subpage"
76
:not_found="not_found"
87
:found="found"
98
:sections="sections"
109
:subheader_tabs="subheader_tabs"
11-
:sidebar="sidebar">
10+
:sidebar="sidebar",
11+
:related_repos="related_repos",
12+
:info="info",
13+
:timestamps="timestamps">
1214
</projects>

frontend/src/components/Homepage/index.ts

Lines changed: 32 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -22,17 +22,27 @@ import HeaderBar from "../HeaderBar";
2222
import { pickLogoLetter, daysAgo } from "../../utils";
2323

2424
import { Util } from "../../../../shared/util";
25-
import { RepoRelease } from "../../../../shared/types";
26-
import { Config } from "../../types/config";
25+
import { RepoRelease, StoredProjectConfig } from "../../../../shared/types";
2726

2827
type Category = {
2928
title: string;
3029
platform: string;
3130
icon: string;
32-
projects: Config[];
33-
featured: Config[];
31+
projects: ProjectInfo[];
32+
featured: ProjectInfo[];
3433
};
3534

35+
type ProjectInfo = {
36+
org: string;
37+
repo: string;
38+
39+
name: string;
40+
description: string;
41+
42+
letter: string;
43+
color: string;
44+
}
45+
3646
const COLORS = [
3747
"#039BE5",
3848
"#673AB7",
@@ -155,26 +165,36 @@ export default class Homepage extends Vue {
155165

156166
snapshot.docs.forEach(
157167
(doc: firebase.firestore.QueryDocumentSnapshot, docIndex: number) => {
158-
const config = doc.data() as Config;
159-
config.letter = pickLogoLetter(config.name);
160-
config.color = COLORS[(docIndex + categoryIndex) % COLORS.length];
168+
const config = doc.data() as StoredProjectConfig;
169+
170+
const letter = pickLogoLetter(config.name);
171+
const color = COLORS[(docIndex + categoryIndex) % COLORS.length];
161172

162173
const parsedId = Util.parseProjectId(doc.id);
163-
config.org = parsedId.owner;
164-
config.repo = parsedId.repo;
174+
const org = parsedId.owner;
175+
const repo = parsedId.repo;
165176

166177
const words = config.description.split(" ");
167178
let sentence = words.slice(0, 10).join(" ");
168179
if (words.length > 10) {
169180
sentence += "...";
170181
}
171-
config.description = sentence;
182+
const description = sentence;
183+
184+
const catProj: ProjectInfo = {
185+
name: config.name,
186+
description,
187+
letter,
188+
color,
189+
org,
190+
repo
191+
}
172192

173193
if (category.featured.length < 6) {
174-
category.featured.push(config);
194+
category.featured.push(catProj);
175195
}
176196

177-
category.projects.push(config);
197+
category.projects.push(catProj);
178198
}
179199
);
180200
}

frontend/src/components/Homepage/template.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ <h1>Firebase ❤️ Open Source</h1>
6565
</a>
6666
</div>
6767
<div class="projects">
68+
<!-- TODO: This is gnarly, move more of this to JS -->
6869
<div class="project" v-for="project in ($refs.header && $refs.header.subheader_tab_selection == 'all')? category.featured : category.projects">
6970

7071
<div class="grid">

0 commit comments

Comments
 (0)