Skip to content

Commit

Permalink
Added header and some other stuff to Astro rework (#1127)
Browse files Browse the repository at this point in the history
This branch adds:
- a reimplementation of the page header in Tailwind (animation currently
not working)
- a more DRY footer and some layout components
- stored menu data in content folder and query it in components
- SVGs imported as proper images instead of inlining

ref #1125

---------

Co-authored-by: Rok Garbas <[email protected]>
  • Loading branch information
thilobillerbeck and garbas committed Sep 21, 2023
1 parent e30f585 commit a535747
Show file tree
Hide file tree
Showing 9 changed files with 131 additions and 55 deletions.
1 change: 1 addition & 0 deletions src/assets/image/flake-blue.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/assets/image/flake-white.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions src/components/layout/Container.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
const { class: extraClasses } = Astro.props;
---

<div class={`mx-4 md:mx-auto md:max-w-screen-md lg:max-w-screen-lg xl:max-w-screen-xl ${extraClasses}`}>
<slot />
</div>
42 changes: 42 additions & 0 deletions src/content/menus/footer.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
sections:
- name: The Project
items:
- name: Channel Status
link: https://status.nixos.org/
- name: Packages search
link: https://search.nixos.org/packages
- name: Options search
link: https://search.nixos.org/options
- name: Reproducible Builds Status
link: https://reproducible.nixos.org/
- name: Security
link: /community/teams/security
- name: Get in Touch
items:
- name: Forum
link: https://discourse.nixos.org/
- name: Matrix Chat
link: https://matrix.to/#/#community:nixos.org
- name: Commercial support
link: /community/commercial-support
- name: Contribute
items:
- name: Contributing Guide
link: https://nix.dev/contributing/how-to-contribute
- name: Donate
link: /donate
- name: Stay up to Date
items:
- name: Blog
link: /blog/
- name: Newsletter
link: https://weekly.nixos.org/
social:
- name: Mastodon
link: https://chaos.social/@nixos_org
- name: Twitter
link: https://twitter.com/nixos_org
- name: Youtube
link: https://www.youtube.com/channel/UC3vIimi9q4AT8EgxYp_dWIw
- name: GitHub
link: https://github.com/NixOS
13 changes: 13 additions & 0 deletions src/content/menus/header.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
items:
- name: Explore
link: /explore
- name: Download
link: /download
- name: Learn
link: /learn
- name: Community
link: /community
- name: Blog
link: /blog
- name: Donate
link: /donate
1 change: 1 addition & 0 deletions src/env.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/// <reference path="../.astro/types.d.ts" />
/// <reference types="astro/client" />
76 changes: 23 additions & 53 deletions src/layouts/Footer.astro
Original file line number Diff line number Diff line change
@@ -1,54 +1,31 @@
---
import { Icon } from 'astro-icon'
import { Image } from 'astro:assets';
import { getEntry } from 'astro:content';
import flakeWhite from "../assets/image/flake-white.svg";
import Container from "../components/layout/Container.astro";
const footerMenu = await getEntry('menus', 'footer');
---

<footer>
<style>
.nixlogo {
content: "";
background-image: url('data:image/svg+xml;utf8,%3Csvg%20xmlns%3D%22http%3A//www.w3.org/2000/svg%22%20xmlns%3Axlink%3D%22http%3A//www.w3.org/1999/xlink%22%20viewBox%3D%220%200%20550.416%20484.317%22%20height%3D%22516.604%22%20width%3D%22587.11%22%3E%3Cdefs%3E%3ClinearGradient%20id%3D%22a%22%3E%3Cstop%20offset%3D%220%22%20style%3D%22stop-color%3A%23fff%3Bstop-opacity%3A1%22/%3E%3Cstop%20style%3D%22stop-color%3A%23fff%3Bstop-opacity%3A1%22%20offset%3D%22.243%22/%3E%3Cstop%20offset%3D%221%22%20style%3D%22stop-color%3A%23fff%3Bstop-opacity%3A1%22/%3E%3C/linearGradient%3E%3ClinearGradient%20id%3D%22b%22%3E%3Cstop%20offset%3D%220%22%20style%3D%22stop-color%3A%23fff%3Bstop-opacity%3A1%22/%3E%3Cstop%20style%3D%22stop-color%3A%23fff%3Bstop-opacity%3A1%22%20offset%3D%22.232%22/%3E%3Cstop%20offset%3D%221%22%20style%3D%22stop-color%3A%23fff%3Bstop-opacity%3A1%22/%3E%3C/linearGradient%3E%3ClinearGradient%20y2%3D%22506.188%22%20x2%3D%22290.087%22%20y1%3D%22351.411%22%20x1%3D%22200.597%22%20gradientTransform%3D%22translate%2870.65%20-1055.151%29%22%20gradientUnits%3D%22userSpaceOnUse%22%20id%3D%22c%22%20xlink%3Ahref%3D%22%23a%22/%3E%3ClinearGradient%20y2%3D%22937.714%22%20x2%3D%22-496.297%22%20y1%3D%22782.336%22%20x1%3D%22-584.199%22%20gradientTransform%3D%22translate%28864.696%20-1491.34%29%22%20gradientUnits%3D%22userSpaceOnUse%22%20id%3D%22e%22%20xlink%3Ahref%3D%22%23b%22/%3E%3C/defs%3E%3Cg%20transform%3D%22translate%28-132.651%20958.04%29%22%20style%3D%22display%3Ainline%3Bopacity%3A1%22%3E%3Cpath%20style%3D%22opacity%3A1%3Bfill%3Aurl%28%23c%29%3Bfill-opacity%3A1%3Bfill-rule%3Aevenodd%3Bstroke%3Anone%3Bstroke-width%3A3%3Bstroke-linecap%3Abutt%3Bstroke-linejoin%3Around%3Bstroke-miterlimit%3A4%3Bstroke-dasharray%3Anone%3Bstroke-opacity%3A1%22%20d%3D%22m309.549-710.388%20122.197%20211.675-56.157.527-32.624-56.87-32.856%2056.566-27.903-.011-14.29-24.69%2046.81-80.49-33.23-57.826z%22%20id%3D%22d%22/%3E%3Cuse%20xlink%3Ahref%3D%22%23d%22%20transform%3D%22rotate%2860%20407.112%20-715.787%29%22%20width%3D%22100%25%22%20height%3D%22100%25%22/%3E%3Cuse%20xlink%3Ahref%3D%22%23d%22%20transform%3D%22rotate%28-60%20407.312%20-715.7%29%22%20width%3D%22100%25%22%20height%3D%22100%25%22/%3E%3Cuse%20xlink%3Ahref%3D%22%23d%22%20transform%3D%22rotate%28180%20407.419%20-715.756%29%22%20width%3D%22100%25%22%20height%3D%22100%25%22/%3E%3Cpath%20id%3D%22f%22%20d%3D%22m309.549-710.388%20122.197%20211.675-56.157.527-32.624-56.87-32.856%2056.566-27.903-.011-14.29-24.69%2046.81-80.49-33.23-57.826z%22%20style%3D%22color%3A%23fff%3Bclip-rule%3Anonzero%3Bdisplay%3Ainline%3Boverflow%3Avisible%3Bvisibility%3Avisible%3Bopacity%3A1%3Bisolation%3Aauto%3Bmix-blend-mode%3Anormal%3Bcolor-interpolation%3AsRGB%3Bcolor-interpolation-filters%3AlinearRGB%3Bsolid-color%3A%23fff%3Bsolid-opacity%3A1%3Bfill%3Aurl%28%23e%29%3Bfill-opacity%3A1%3Bfill-rule%3Aevenodd%3Bstroke%3Anone%3Bstroke-width%3A3%3Bstroke-linecap%3Abutt%3Bstroke-linejoin%3Around%3Bstroke-miterlimit%3A4%3Bstroke-dasharray%3Anone%3Bstroke-dashoffset%3A0%3Bstroke-opacity%3A1%3Bcolor-rendering%3Aauto%3Bimage-rendering%3Aauto%3Bshape-rendering%3Aauto%3Btext-rendering%3Aauto%3Benable-background%3Aaccumulate%22/%3E%3Cuse%20style%3D%22display%3Ainline%22%20xlink%3Ahref%3D%22%23f%22%20transform%3D%22rotate%28120%20407.34%20-716.084%29%22%20width%3D%22100%25%22%20height%3D%22100%25%22/%3E%3Cuse%20style%3D%22display%3Ainline%22%20xlink%3Ahref%3D%22%23f%22%20transform%3D%22rotate%28-120%20407.288%20-715.87%29%22%20width%3D%22100%25%22%20height%3D%22100%25%22/%3E%3C/g%3E%3C/svg%3E');
}
</style>
<div class="bg-nixdarkerblue text-white font-light">
<div class="mx-4 md:mx-auto md:max-w-screen-md lg:max-w-screen-lg xl:max-w-screen-xl">
<Container>
<div class="flex flex-col sm:flex-row flex-wrap py-8 gap-y-8">
<div class="basis-1/2 lg:basis-1/4">
<h4 class="text-xl font-bold text-nixdarkblue mb-4">The Project</h4>
<ul class="space-y-2">
<li><a href="https://status.nixos.org/">Channel Status</a></li>
<li><a href="https://search.nixos.org/packages">Packages search</a></li>
<li><a href="https://search.nixos.org/options">Options search</a></li>
<li><a href="https://reproducible.nixos.org/">Reproducible Builds Status</a></li>
<li><a href="/community/teams/security">Security</a></li>
</ul>
</div>
<div class="basis-1/2 lg:basis-1/4">
<h4 class="text-xl font-bold text-nixdarkblue mb-4">Get in Touch</h4>
<ul class="space-y-2">
<li><a href="https://discourse.nixos.org/">Forum</a></li>
<li><a href="https://matrix.to/#/#community:nixos.org">Matrix Chat</a></li>
<li><a href="/community/commercial-support">Commercial support</a></li>
</ul>
</div>
<div class="basis-1/2 lg:basis-1/4">
<h4 class="text-xl font-bold text-nixdarkblue mb-4">Contribute</h4>
<ul class="space-y-2">
<li><a href="https://nix.dev/contributing/how-to-contribute">Contributing Guide</a></li>
<li><a href="/donate">Donate</a></li>
</ul>
</div>
<div class="basis-1/2 lg:basis-1/4">
<h4 class="text-xl font-bold text-nixdarkblue mb-4">Stay up to Date</h4>
<ul class="space-y-2">
<li><a href="/blog/">Blog</a></li>
<li><a href="https://weekly.nixos.org/">Newsletter</a></li>
</ul>
</div>
{footerMenu.data.sections.map((menu) =>(
<div class="basis-1/2 lg:basis-1/4">
<h4 class="text-xl font-bold text-nixdarkblue mb-4">{menu.name}</h4>
<ul class="space-y-2">
{menu.items.map((item) => (
<li><a href={item.link}>{item.name}</a></li>
))}
</ul>
</div>
))}
</div>
<hr class="border-nixlightblue">
<div class="flex flex-col lg:flex-row flex-wrap py-8 gap-8 lg:gap-0">
<div class="basis-1/2 flex flex-row flex flex-row gap-2">
<h4 class="nixlogo w-16 h-16 inline-block bg-contain bg-no-repeat bg-center -indent-96">NixOS</h4>
<Image src={flakeWhite} alt="Nix Logo White" class="inline-block w-16 h-16" />
<div class="flex flex-col justify-center">
<div>Copyright © 2023 NixOS contributors</div>
<a href="https://github.com/NixOS/nixos-homepage/blob/master/LICENSES/CC-BY-SA-4.0.txt">
Expand All @@ -62,21 +39,14 @@ import { Icon } from 'astro-icon'
<div class="basis-1/2 flex flex-row justify-between lg:justify-end gap-4">
<h4 class="my-auto">Connect with us:</h4>
<div class="my-auto flex flex-row gap-2">
<a href="https://chaos.social/@nixos_org">
<Icon alt="Mastodon" class="w-8" pack="mdi" name="mastodon" />
</a>
<a href="https://twitter.com/nixos_org">
<Icon alt="Twitter" class="w-8" pack="mdi" name="twitter" />
</a>
<a href="https://www.youtube.com/channel/UC3vIimi9q4AT8EgxYp_dWIw">
<Icon alt="Youtube" class="w-8" pack="mdi" name="youtube" />
</a>
<a href="https://github.com/NixOS">
<Icon alt="GitHub" class="w-8" pack="mdi" name="github" />
</a>
{footerMenu.data.social.map((item) =>(
<a href={item.link}>
<Icon alt={item.name} class="w-8" pack="mdi" name={item.name.toLowerCase()} />
</a>
))}
</div>
</div>
</div>
</div>
</Container>
</div>
</footer>
43 changes: 41 additions & 2 deletions src/layouts/Header.astro
Original file line number Diff line number Diff line change
@@ -1,6 +1,45 @@
---
import {Icon} from "astro-icon";
import { Image } from 'astro:assets';
import flakeBlue from "../assets/image/flake-blue.svg";
import { getEntry } from 'astro:content';
import Container from "../components/layout/Container.astro";
const headerMenu = await getEntry('menus', 'header');
const navbarItemStyle = "text-center text-nixsemidarkblue md:text-black border-b-transparent hover:border-b-nixlightblue border-b-4 bg-nixlighterblue md:bg-transparent";
---

<header>
Header
<header class="bg-white text-black font-light shadow-lg">
<Container class="flex flex-col md:flex-row justify-between md:items-center">
<div class="text-4xl font-normal gap-2 flex justify-between md:justify-start items-center my-2">
<div class="gap-2 flex justify-between md:justify-start items-center">
<Image class="h-16 w-16" src={flakeBlue} alt="Nix Logo" />
<span class="visible md:invisible xl:visible">Nix</span>
</div>
<div class="bg-nixlightblue block md:hidden p-4 rounded-lg" id="navigation-toggle">
<span class="bg-white block w-8 h-1 mb-1.5"></span>
<span class="bg-white block w-8 h-1 mb-1.5"></span>
<span class="bg-white block w-8 h-1"></span>
</div>
</div>
<div class="pb-4 md:pb-0 flex-col md:flex-row gap-0.5 md:gap-5 hidden md:flex" id="navbar-menu">
{headerMenu.data.items.map((item) => (
<a class={`pt-8 pb-6 ${navbarItemStyle}`} href={item.link}>{item.name}</a>
))}
<a target="_blank" rel="noreferrer noopener" class={`pt-8 md:pt-7 pb-6 ${navbarItemStyle}`} href="https://search.nixos.org">
<Icon alt="Search" class="h-8 text-nixdarkblue hidden md:block" pack="mdi" name="search" />
<span class="inline-block md:hidden">Search</span>
</a>
</div>
</Container>
</header>

<script lang="ts">
const navigationToggle= document.getElementById("navigation-toggle");
const navbarMenu = document.getElementById("navbar-menu");

navigationToggle.addEventListener("click", () => {
navbarMenu.classList.toggle("hidden");
navbarMenu.classList.toggle("flex")
});
</script>
2 changes: 2 additions & 0 deletions tailwind.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ module.exports = {
theme: {
extend: {
colors: {
"nixlighterblue": "#f2f8fd",
"nixlightblue": "#7ebae4",
"nixdarkblue": "#5277c3",
"nixsemidarkblue": "#405D99",
"nixdarkerblue": "#27385d",
},
fontFamily: {
Expand Down

0 comments on commit a535747

Please sign in to comment.