Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exercise 5: Add Sitewide Banner #8

Open
wants to merge 6 commits into
base: 04-add-link-to-tickets
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 20 additions & 8 deletions site/src/components/banner.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,24 @@
import React from "react"
import React from "react";
import { useStaticQuery, graphql, Link } from "gatsby";

export default function Banner() {
const data = useStaticQuery(graphql`
query BannerQuery {
site {
siteMetadata {
title
}
}
}
`);

return (
<div className="bg-blue-500 text-white p-4 text-center">
<blockquote>

Tickets are on sale now for X Conf!

</blockquote>
</div>
<Link to="/tickets">
<div className="bg-blue-500 text-white p-4 text-center">
<blockquote>
Tickets are on sale now for {data.site.siteMetadata.title}!
</blockquote>
</div>
</Link>
);
}
3 changes: 2 additions & 1 deletion site/src/components/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Link } from "gatsby";
import PropTypes from "prop-types";
import React, { useState } from "react";
import Logo from "../images/pencil-icon.png";

import Banner from "../components/banner";
function Header({ siteTitle }) {
const [isExpanded, toggleExpansion] = useState(false);
const NavLinks = [
Expand All @@ -12,6 +12,7 @@ function Header({ siteTitle }) {

return (
<nav className="bg-white">
<Banner />
<div className="flex flex-wrap items-center justify-between max-w-4xl mx-auto p-4 md:p-8">
<Link to="/" className="flex items-center no-underline text-black">
<img src={Logo} alt="Logo" className="w-8" />
Expand Down