Skip to content

Commit

Permalink
feat: add initial 404
Browse files Browse the repository at this point in the history
  • Loading branch information
vpicone committed May 22, 2019
1 parent 20af82f commit cffa06a
Show file tree
Hide file tree
Showing 8 changed files with 153 additions and 1 deletion.
12 changes: 12 additions & 0 deletions packages/example/src/pages/404.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from 'react';
import { FourOhFour } from 'gatsby-theme-carbon';

const links = [
{ href: '/components/markdown', text: 'Markdown' },
{ href: '/components/aside', text: 'Aside' },
{ href: '/components/demo', text: 'Demo' },
];

const Custom404 = () => <FourOhFour links={links} />;

export default Custom404;
12 changes: 12 additions & 0 deletions packages/example/src/pages/whoops.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from 'react';
import { FourOhFour } from 'gatsby-theme-carbon';

const links = [
{ href: '/components/markdown', text: 'Markdown' },
{ href: '/components/aside', text: 'Aside' },
{ href: '/components/demo', text: 'Demo' },
];

const Custom404 = () => <FourOhFour links={links} />;

export default Custom404;
2 changes: 1 addition & 1 deletion packages/gatsby-theme-carbon/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ export { default as ResourceCard } from './src/components/ResourceCard';
export { default as ArticleCard } from './src/components/ArticleCard';
export { default as Aside } from './src/components/Aside';
export { default as FeatureCard } from './src/components/FeatureCard';

export { default as FourOhFour } from './src/components/FourOhFour';
// Homepage Template Components
export { HomepageCallout, HomepageBanner } from './src/components/Homepage';
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
import React from 'react';
import { Link } from 'gatsby';
import Layout from '../Layout';
import styles, {
container,
fourOhFour,
paragraph,
heading,
link,
list,
} from './FourOhFour.module.scss';

console.log(styles);
const whoops = ({ links }) => {
const getLinks = () => (
<>
<br />
Maybe some of these most visited links will help you?
<ul className={list}>
{links.map(({ href, text }, i) => (
<li key={i}>
<Link className={link} to={href}>
{text}
</Link>
</li>
))}
</ul>
</>
);

return (
<Layout homepage>
<div className={container}>
<span className={fourOhFour}>404</span>
<h2 className={heading}>Something's gone wrong...</h2>
<p className={paragraph}>
Sorry, we can't find the page you are looking for.
{links && getLinks()}
</p>
</div>
</Layout>
);
};

export default whoops;
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
@import '~carbon-components/scss/globals/scss/vars';
@import '~@carbon/elements/scss/type/type';

.four-oh-four {
@include carbon--type-style('display-02');
font-size: 20vw;
background: linear-gradient(35deg, #92eeee, #a66efa);
display: inline-block;
background-size: 200% 200%;
-webkit-text-fill-color: transparent;
-webkit-background-clip: text;
margin-bottom: 6rem;
@include carbon--breakpoint('lg') {
font-size: 300px;
}
animation: gradient 2s ease infinite;
}

.paragraph {
@include carbon--type-style('body-long-01');
font-size: 1.25rem;
line-height: 1.5;
}

.heading {
@include carbon--type-style('expressive-heading-04', true);
margin-bottom: 1rem;
}

.list {
margin-top: 2rem;
}

.link {
@include carbon--type-style('body-short-01');
display: inline-block;
font-size: 1.25rem;
margin-bottom: 1rem;
}

.container {
margin: 0;
margin-top: 4rem;
max-width: 100%;
min-height: calc(100vh - 500px);

@include carbon--breakpoint('lg') {
padding-left: calc(
25% + 2rem
); //2rem to account for 2rem left padding default on grid
}

@include carbon--breakpoint('max') {
padding-left: 400px;
}
}

@keyframes gradient {
0% {
background-position: 0% 50%;
}
50% {
background-position: 100% 50%;
}
100% {
background-position: 0% 50%;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import FourOhFour from './FourOhFour';

export default FourOhFour;
11 changes: 11 additions & 0 deletions packages/gatsby-theme-carbon/src/styles/animations.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
@keyframes gradient {
0% {
background-position: 0% 50%;
}
50% {
background-position: 100% 50%;
}
100% {
background-position: 0% 50%;
}
}
1 change: 1 addition & 0 deletions packages/gatsby-theme-carbon/src/styles/index.scss
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ $prefix: 'bx';
//---------------------------------------

@import 'page';
@import './animations.css';

@import '../components/markdown/markdown.scss';
@import '../components/Homepage/homepage.scss';
Expand Down

0 comments on commit cffa06a

Please sign in to comment.