Skip to content

Commit

Permalink
Merge pull request #243 from newrelic/jerel/dev-champ-banner
Browse files Browse the repository at this point in the history
Developer champion banner
  • Loading branch information
zstix authored Jun 25, 2020
2 parents ede835b + c5a2f2f commit ad2541a
Show file tree
Hide file tree
Showing 5 changed files with 83 additions and 18 deletions.
6 changes: 6 additions & 0 deletions src/components/FeatherIcon.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ const ICONS = {
<polyline points="16 16 12 12 8 16" />
</>
),
award: (
<>
<circle cx="12" cy="8" r="7" />
<polyline points="8.21 13.89 7 23 12 20 17 23 15.79 13.88" />
</>
),
};

FeatherIcon.propTypes = {
Expand Down
54 changes: 41 additions & 13 deletions src/components/NavigationItems.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,17 @@ import { BreadcrumbContext } from './BreadcrumbContext';
import styles from './NavigationItems.module.scss';
import { link } from '../types';

const iconLibrary = {
'Collect data': 'collectData',
'Build apps': 'buildApps',
'Automate workflows': 'automation',
'Explore docs': 'developerDocs',
};

const featherIconLibrary = {
'Developer champions': 'award',
};

const getHighlightedText = (text, highlight) => {
const parts = text.split(new RegExp(`(${highlight})`, 'gi'));
return (
Expand Down Expand Up @@ -59,6 +70,28 @@ const NavigationItems = ({
});
};

const NavIcon = ({ page }) => {
if (featherIconLibrary[page.displayName]) {
return (
<FeatherIcon
className={styles.headerIcon}
name={featherIconLibrary[page.displayName]}
/>
);
}

if (iconLibrary[page.displayName]) {
return (
<NewRelicIcon
className={styles.headerIcon}
name={iconLibrary[page.displayName]}
/>
);
}

return null;
};

const NavItem = ({ page, depthLevel, searchTerm, filteredPageNames }) => {
const crumbs = useContext(BreadcrumbContext).flatMap((x) => x.displayName);
const isHomePage = crumbs.length === 0 && depthLevel === 0;
Expand All @@ -67,19 +100,8 @@ const NavItem = ({ page, depthLevel, searchTerm, filteredPageNames }) => {
isHomePage || crumbs.includes(page.displayName)
);

const iconLibrary = {
'Collect data': 'collectData',
'Build apps': 'buildApps',
'Automate workflows': 'automation',
'Explore docs': 'developerDocs',
};
const isCurrentPage = crumbs[crumbs.length - 1] === page.displayName;
const headerIcon = depthLevel === 0 && (
<NewRelicIcon
className={styles.headerIcon}
name={iconLibrary[page.displayName]}
/>
);
const headerIcon = depthLevel === 0 && <NavIcon page={page} />;
const display = filteredPageNames
? getHighlightedText(page.displayName, searchTerm)
: page.displayName;
Expand All @@ -104,7 +126,7 @@ const NavItem = ({ page, depthLevel, searchTerm, filteredPageNames }) => {
)}
to={page.url}
>
<span>
<span className={styles.navLinkText}>
{headerIcon}
{display}
</span>
Expand Down Expand Up @@ -154,6 +176,12 @@ const NavItem = ({ page, depthLevel, searchTerm, filteredPageNames }) => {
);
};

NavIcon.propTypes = {
page: PropTypes.shape({
displayName: PropTypes.string.isRequired,
}),
};

NavigationItems.propTypes = {
pages: PropTypes.array.isRequired,
filteredPageNames: PropTypes.array,
Expand Down
5 changes: 5 additions & 0 deletions src/components/NavigationItems.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ button.navLink {
}
}

.navLinkText {
display: flex;
align-items: center;
}

.currentPageIndicator {
stroke-width: 4;
}
Expand Down
25 changes: 21 additions & 4 deletions src/pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import SEO from '../components/Seo';
import GuideListing from '../components/GuideListing/GuideListing';
import GuideTile from '../components/GuideTile';
import PageTitle from '../components/PageTitle';
import Section from '../components/Section';
import Video from '../components/Video';
import FeatherIcon from '../components/FeatherIcon';
import ExternalLink from '../components/ExternalLink';
Expand Down Expand Up @@ -95,7 +94,7 @@ const IndexPage = ({ data, pageContext }) => {
/>
</section>

<Section backgroundBanner>
<section className={cx(styles.section, styles.stripedSection)}>
<GuideListing className={styles.guideListing}>
<header className={styles.guideListingHeader}>
<GuideListing.Heading className={cx(styles.guideListingHeading)}>
Expand All @@ -111,9 +110,9 @@ const IndexPage = ({ data, pageContext }) => {
))}
</GuideListing.List>
</GuideListing>
</Section>
</section>

<GuideListing className={styles.guideListing}>
<GuideListing className={styles.section}>
<GuideListing.Heading className={styles.guideListingHeading}>
Get inspired
</GuideListing.Heading>
Expand Down Expand Up @@ -146,6 +145,24 @@ const IndexPage = ({ data, pageContext }) => {
</ExternalLink>{' '}
built by the New Relic community.
</p>

<section className={cx(styles.section, styles.stripedSection)}>
<h1>New Relic developer champions</h1>
<p>
New Relic Champions are solving big problems using New Relic as
their linchpin and are recognized as experts and leaders in the New
Relic technical community.
</p>
<ExternalLink href="https://forms.gle/Zkdub5e1x4MNqSKW9">
<button type="button">
Nominate a Developer Champion
<FeatherIcon
className={styles.externalLinkIcon}
name="external-link"
/>
</button>
</ExternalLink>
</section>
</Layout>
</PageContext.Provider>
);
Expand Down
11 changes: 10 additions & 1 deletion src/pages/index.module.scss
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
}

.guideListing {
margin-top: 6rem;
margin-top: 0;
}

.guideListingHeader {
Expand Down Expand Up @@ -69,3 +69,12 @@
.externalLinkIcon {
margin-left: 0.25rem;
}

.section {
margin-top: 4rem;
}

.stripedSection {
padding: 2rem;
background: var(--color-neutrals-100);
}

0 comments on commit ad2541a

Please sign in to comment.