Skip to content
This repository was archived by the owner on Apr 7, 2025. It is now read-only.

Commit 52afb68

Browse files
author
Joel Worrall
committed
fix: merge changes and arrange homepage and landing page content
2 parents 2890dcb + 6be1486 commit 52afb68

8 files changed

+102
-97
lines changed

src/components/HomepageCollection.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,12 @@ import SimpleProjectModule from './SimpleProjectModule';
88

99
const HomepageCollection = ({ projects }) => {
1010
const [projectsHovered, setProjectsHovered] = useState(false);
11-
1211
return (
1312
<div className={styles.homepageCollection}>
1413
<h4 className={styles.title}>Instrumentation projects</h4>
1514
<p className={styles.description}>
16-
Instrument everything with our open source agents, tools, and sdk's.{' '}
17-
<a href="/collections">Other highlighted collection</a>
15+
Instrument everything with our open source agents, tools, and sdk's or{' '}
16+
<a href="/collections">see other highlighted collections.</a>
1817
</p>
1918

2019
<div
@@ -43,9 +42,10 @@ const HomepageCollection = ({ projects }) => {
4342
}
4443
`}
4544
>
46-
<span className={styles.subProjectCallToActionLabel}>View all</span>
45+
<span className={styles.subProjectCallToActionLabel}>
46+
Explore open source instrumentation
47+
</span>
4748
</Button>
48-
4949
{projects.map(project => {
5050
const link = project.permalink.replace(
5151
'https://opensource.newrelic.com',

src/components/HomepageCollection.module.scss

+2-15
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141

4242
.projects-container {
4343
display: flex;
44+
justify-content: center;
4445
height: 150px;
4546
overflow: hidden;
4647
position: relative;
@@ -71,15 +72,11 @@
7172
height: 105px;
7273
flex-shrink: 0;
7374
margin-right: 20px;
74-
animation-duration: 60s;
75-
animation-name: project-slide;
76-
animation-iteration-count: infinite;
77-
animation-direction: alternate;
78-
animation-timing-function: linear;
7975
position: relative;
8076
z-index: 100;
8177
box-shadow: 0px 0.913195px 0.802504px rgba(4, 22, 22, 0.00562291), 0px 2.19453px 1.92853px rgba(4, 22, 22, 0.00807786), 0px 4.13211px 3.63125px rgba(4, 22, 22, 0.01), 0px 7.37098px 6.47753px rgba(4, 22, 22, 0.0119221), 0px 13.7866px 12.1155px rgba(4, 22, 22, 0.0143771), 0px 33px 29px rgba(4, 22, 22, 0.02);
8278
pointer-events: none;
79+
transform: translateX(-150px);
8380

8481
&:last-child {
8582
margin-right: 0;
@@ -92,16 +89,6 @@
9289
}
9390
}
9491

95-
@keyframes project-slide {
96-
from {
97-
transform: translateX(0);
98-
}
99-
100-
to {
101-
transform: translateX(-1000px);
102-
}
103-
}
104-
10592
.cta-button {
10693
z-index: 1000;
10794
position: absolute;

src/data/navigation.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
"order": 1
77
},
88
{
9-
"label": "New Relic Projects",
10-
"link": "/explore-projects",
9+
"label": "Highlighted Projects",
10+
"link": "/collections",
1111
"order": 2
1212
},
1313
{
14-
"label": "Highlighted Projects",
15-
"link": "/collections",
14+
"label": "New Relic Projects",
15+
"link": "/explore-projects",
1616
"order": 3
1717
}
1818
]
161 Bytes
Loading

src/pages/collection.module.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
}
2424

2525
.collection-listing-container {
26+
margin-top: 100px;
2627
&:before {
2728
position: absolute;
2829
left: 0;
@@ -109,7 +110,6 @@
109110
}
110111
}
111112

112-
113113
.page-heading {
114114
margin-bottom: 100px;
115115
}

src/pages/collections.js

+67-52
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,27 @@ import styles from './collection.module.scss';
1212

1313
export const query = graphql`
1414
query allCollections($path: String) {
15+
instrumentation: allProjects(
16+
filter: {
17+
projectType: { eq: "newrelic" }
18+
projectTags: {
19+
elemMatch: {
20+
slug: { in: ["exporter", "nri", "agent", "sdk", "cli"] }
21+
}
22+
}
23+
}
24+
) {
25+
edges {
26+
node {
27+
...exploreProjectsFields
28+
}
29+
}
30+
}
31+
1532
nerdpacks: allProjects(
1633
filter: {
1734
projectType: { eq: "newrelic" }
18-
projectTags: { elemMatch: { slug: { eq: "nr1-app" } } }
35+
projectTags: { elemMatch: { slug: { eq: "nr1-app" } } }
1936
} # sort: { fields: stats___lastSixMonthsCommitTotal, order: DESC }
2037
) {
2138
edges {
@@ -26,16 +43,15 @@ export const query = graphql`
2643
}
2744
2845
layouts: allProjects(
29-
filter: {
30-
name: { regex: "/layout/" }
31-
} # sort: { fields: stats___lastSixMonthsCommitTotal, order: DESC }
46+
filter: { name: { regex: "/layout/" } } # sort: { fields: stats___lastSixMonthsCommitTotal, order: DESC }
3247
) {
3348
edges {
3449
node {
3550
...exploreProjectsFields
3651
}
3752
}
3853
}
54+
3955
sitePage: allSitePage(filter: { path: { eq: $path } }) {
4056
nodes {
4157
fields {
@@ -55,21 +71,23 @@ function generateDescription(name) {
5571
case 'layouts':
5672
return 'Build a better application beginning with a better starting point.';
5773
case 'instrumentation':
58-
return 'Instrument everything with our open source agents, tools, and sdk\'s.'
74+
return "Instrument everything with our open source agents, tools, and sdk's.";
5975
}
6076
}
6177

6278
const CollectionPage = ({ data }) => {
6379
const allData = Object.entries(data);
64-
const allCollections = allData.filter(c => c[0] !== 'sitePage').map(c => {
65-
return {
66-
name: c[0],
67-
size: c[1].edges.length,
68-
projects: c[1].edges.filter((e, i) => i < 4).map(e => e.node),
69-
description: generateDescription(c[0])
70-
}
71-
});
72-
console.debug(allCollections);
80+
const allCollections = allData
81+
.filter(c => c[0] !== 'sitePage')
82+
.map(c => {
83+
return {
84+
name: c[0],
85+
size: c[1].edges.length,
86+
projects: c[1].edges.filter((e, i) => i < 4).map(e => e.node),
87+
description: generateDescription(c[0])
88+
};
89+
});
90+
7391
return (
7492
<Layout
7593
fullWidth
@@ -83,47 +101,44 @@ const CollectionPage = ({ data }) => {
83101
/>
84102

85103
{allCollections.map(collection => {
86-
return (
87-
<>
88-
<div className={styles.collectionListingContainer}>
89-
<header className={styles.collectionListingHeaderSection}>
90-
<div>
91-
<h4
92-
className={styles.collectionListingHeaderSectionHeading}
93-
>
94-
{startCase(collection.name)}
95-
</h4>
96-
<p
97-
className={
98-
styles.collectionListingHeaderSectionDescription
99-
}
100-
>
101-
{collection.description}
102-
</p>
103-
</div>
104-
<a
105-
href={`/${collection.name}`}
106-
className={styles.collectionsPageCollectionLink}
104+
return (
105+
<>
106+
<div className={styles.collectionListingContainer}>
107+
<header className={styles.collectionListingHeaderSection}>
108+
<div>
109+
<h4 className={styles.collectionListingHeaderSectionHeading}>
110+
{startCase(collection.name)}
111+
</h4>
112+
<p
113+
className={styles.collectionListingHeaderSectionDescription}
107114
>
108-
View all{' '}
109-
<span className={styles.collectionProjectCount}>
110-
{collection.size}
111-
</span>{' '}
112-
projects
113-
<ChevronRight />
114-
</a>
115-
</header>
116-
<div className={styles.collectionListing}>
117-
{collection.projects.map(project => <SimpleProjectModule
118-
key={project.id}
119-
data={project}
120-
className={styles.project}
121-
/>
122-
)}
115+
{collection.description}
116+
</p>
123117
</div>
118+
<a
119+
href={`/${collection.name}`}
120+
className={styles.collectionsPageCollectionLink}
121+
>
122+
View all{' '}
123+
<span className={styles.collectionProjectCount}>
124+
{collection.size}
125+
</span>{' '}
126+
projects
127+
<ChevronRight />
128+
</a>
129+
</header>
130+
<div className={styles.collectionListing}>
131+
{collection.projects.map(project => (
132+
<SimpleProjectModule
133+
key={project.id}
134+
data={project}
135+
className={styles.project}
136+
/>
137+
))}
124138
</div>
125-
</>
126-
);
139+
</div>
140+
</>
141+
);
127142
})}
128143
</Layout>
129144
);

src/pages/index.js

+22-19
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,7 @@ import closeIcon from '../images/icon-close.svg';
1717

1818
export const query = graphql`
1919
query HomePageQuery($path: String) {
20-
topProjects: allProjects(
21-
filter: { projectType: { eq: "newrelic" } } # sort: { fields: stats___lastSixMonthsCommitTotal, order: DESC } # limit: 8
22-
) {
20+
topProjects: allProjects(filter: { projectType: { eq: "newrelic" } }) {
2321
edges {
2422
node {
2523
...projectFields
@@ -34,7 +32,7 @@ export const query = graphql`
3432
slug: { in: ["exporter", "nri", "agent", "sdk", "cli"] }
3533
}
3634
}
37-
} # sort: { fields: stats___lastSixMonthsCommitTotal, order: DESC } # limit: 8
35+
}
3836
) {
3937
edges {
4038
node {
@@ -84,10 +82,27 @@ export const query = graphql`
8482
}
8583
`;
8684

85+
function sortByStats(a, b) {
86+
if (a.stats === null && b.stats === null) {
87+
return 0;
88+
} else if (a.stats === null) {
89+
return 1;
90+
} else if (b.stats === null) {
91+
return -1;
92+
}
93+
94+
return a.stats.lastSixMonthsCommitTotal < b.stats.lastSixMonthsCommitTotal
95+
? 1
96+
: -1;
97+
}
98+
8799
const HomePage = ({ data }) => {
88100
const [heroVideoActive, setHeroVideoActive] = useState(false);
89101

90-
const instrumentationProjects = get(data, 'instrumentation.edges');
102+
const instrumentationProjects = get(data, 'instrumentation.edges', [])
103+
.map(i => i.node)
104+
.sort(sortByStats)
105+
.slice(0, 5);
91106

92107
const externalProjects = [
93108
get(data, 'openTelemetry.nodes[0]'),
@@ -98,19 +113,7 @@ const HomePage = ({ data }) => {
98113
// temp workaround until the query above is fixed to pull back the correct top 8
99114
const internalProjects = get(data, 'topProjects.edges', [])
100115
.map(i => i.node)
101-
.sort((a, b) => {
102-
if (a.stats === null && b.stats === null) {
103-
return 0;
104-
} else if (a.stats === null) {
105-
return 1;
106-
} else if (b.stats === null) {
107-
return -1;
108-
}
109-
110-
return a.stats.lastSixMonthsCommitTotal < b.stats.lastSixMonthsCommitTotal
111-
? 1
112-
: -1;
113-
})
116+
.sort(sortByStats)
114117
.slice(0, 8);
115118

116119
const renderHeroVideo = () => {
@@ -215,7 +218,7 @@ const HomePage = ({ data }) => {
215218
}}
216219
/>
217220

218-
<HomepageCollection projects={instrumentationProjects.map(i => i.node)} />
221+
<HomepageCollection projects={instrumentationProjects} />
219222

220223
<HomePageHighlights data={externalProjects} />
221224

src/pages/instrumentation.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export const query = graphql`
2323
) {
2424
edges {
2525
node {
26-
...exploreProjectsFields
26+
...projectFields
2727
}
2828
}
2929
}

0 commit comments

Comments
 (0)