Skip to content

Commit

Permalink
Add dropdown to switch between Flutter-related sites
Browse files Browse the repository at this point in the history
  • Loading branch information
parlough committed Feb 1, 2025
1 parent 18e8ab8 commit af86935
Show file tree
Hide file tree
Showing 5 changed files with 203 additions and 20 deletions.
67 changes: 50 additions & 17 deletions src/_includes/header.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,47 @@
Skip to main content
</a>
<nav class="navbar">
<button
id="menu-toggle"
class="icon-button"
type="button"
aria-controls="sidenav"
aria-label="Toggle navigation"
title="Toggle navigation">
<span class="material-symbols" aria-hidden="true">menu</span>
</button>

<a class="navbar-brand" href="/">
<img
src='/assets/images/branding/flutter/logo+text/horizontal/default.svg'
alt='Flutter logo'
height="37"
width="129">
</a>
<div id="site-switcher" class="dropdown">
<button class="dropdown-button site-wordmark">
<img src="/assets/images/branding/flutter/logo/default.svg" alt="Flutter logo" width="28">
<span>Flutter</span>
<span class="subtype">Docs</span>
<span class="material-symbols" aria-hidden="true">unfold_more</span>
</button>
<div class="dropdown-content">
<nav class="dropdown-menu">
<ul>
<li><a href="https://flutter.dev" class="site-wordmark" title="Flutter homepage">
<img src="/assets/images/branding/flutter/logo/default.svg" alt="Flutter logo" width="28">
<span>Flutter</span>
</a></li>
<li><a href="https://docs.flutter.dev" class="site-wordmark current-site" title="Flutter docs homepage">
<img src="/assets/images/branding/flutter/logo/default.svg" alt="Flutter logo" width="28">
<span>Flutter</span>
<span class="subtype">Docs</span>
</a></li>
<li><a href="https://api.flutter.dev" class="site-wordmark" title="Flutter API reference">
<img src="/assets/images/branding/flutter/logo/default.svg" alt="Flutter logo" width="28">
<span>Flutter</span>
<span class="subtype">API</span>
</a></li>
<li aria-hidden="true" class="dropdown-divider"></li>
<li><a href="https://dart.dev" class="site-wordmark" title="Dart homepage">
<img src="/assets/images/branding/dart/logo.svg" alt="Dart logo" width="28" height="28">
<span>Dart</span>
</a></li>
<li><a href="https://dartpad.dev" class="site-wordmark" title="DartPad playground">
<img src="/assets/images/branding/dart/logo.svg" alt="Dart logo" width="28" height="28">
<span>DartPad</span>
</a></li>
<li><a href="https://pub.dev" class="site-wordmark" title="pub.dev homepage">
<img src="/assets/images/branding/dart/logo.svg" alt="Dart logo" width="28" height="28">
<span>pub.dev</span>
</a></li>
</ul>
</nav>
</div>
</div>

<div class="navbar-contents">
<ul class="navbar-nav">
Expand All @@ -48,6 +72,15 @@
<span class="material-symbols" aria-hidden="true">search</span>
</a>
<a id="call-to-action" class="filled-button" href="/get-started/install/">Get started</a>
<button
id="menu-toggle"
class="icon-button"
type="button"
aria-controls="sidenav"
aria-label="Toggle navigation"
title="Toggle navigation">
<span class="material-symbols" aria-hidden="true">menu</span>
</button>
</div>
</nav>
</header>
6 changes: 3 additions & 3 deletions src/_sass/components/_header.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
flex-wrap: wrap;
align-items: center;
justify-content: space-between;
padding: .5rem 1rem;
padding: 0.5rem 0.75rem;

min-height: $site-header-height;

#menu-toggle {
margin-right: 0.75rem;
margin-left: 0.25rem;

@media (min-width: 1024px) {
display: none;
Expand Down Expand Up @@ -72,7 +72,7 @@
padding: 0.5rem 1rem !important;
display: none;

@media (min-width: 768px) {
@media (min-width: 1024px) {
display: unset;
}
}
Expand Down
123 changes: 123 additions & 0 deletions src/_sass/components/_site-switcher.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
@use '../base/mixins';
@use '../base/variables' as *;

.dropdown {
position: relative;
display: inline-flex;
justify-content: center;
}

button.dropdown-button {
padding: 0.4rem 0.6rem;
border-radius: 0.25rem;

.material-symbols:last-child {
margin-left: 0.4rem;
color: rgba(85, 85, 85, 0.6);
font-size: 1rem;
width: 0.7rem;
}

&:hover {
.material-symbols {
color: rgba(85, 85, 85, 0.8);
}
}
}

.dropdown-content {
display: block;
position: absolute;
background-color: var(--site-switcher-bg, #ffffff);
box-shadow: 0 6px 18px 0 rgba(0, 0, 0, 0.2);
z-index: 1060;
border-radius: 0.4rem;
width: max-content;
top: 2.25rem;
transform: scale(0.9);

&.show {
display: block;
}

.dropdown-menu {
padding: 0.4rem;

ul {
display: flex;
flex-direction: column;
list-style: none;
padding: 0;
margin: 0;

li {
padding: 0.3rem;

a {
display: flex;
align-items: center;
flex-direction: row;

text-decoration: none;
}
}
}

.dropdown-divider {
background-color: #e7e8ed;
border-radius: 0.5rem;
height: 0.125rem;
margin: 0.25rem;
padding: 0;
}
}
}

.site-wordmark {
padding: 0.4rem 0.6rem;
border-radius: 0.25rem;
align-items: center;
display: flex;
flex-direction: row;
cursor: pointer;

font-variant-ligatures: none;
font-size: 1.75rem;
line-height: 1.25em;
letter-spacing: 0.015em;
font-family: 'Google Sans', sans-serif;
user-select: none;

> img {
width: 28px;
margin-right: 0.75rem;
}

&.current-site {
background-color: rgba(194, 229, 255, 0.4);
}

&:hover {
@include mixins.interaction-style(4%);
}

&:active {
@include mixins.interaction-style(6%);
}

span {
color: #4a4a4a;
}

span.subtype {
padding: 0 0.3rem;
font-size: 1.25rem;
font-weight: 500;
color: $site-color-body;
line-height: 1.3;
border-radius: 0.25rem;
background-color: rgb(194, 229, 255);
margin-left: 0.4rem;
letter-spacing: normal;
}
}
1 change: 1 addition & 0 deletions src/_sass/site.scss
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
@use 'components/next-prev-nav';
@use 'components/pill';
@use 'components/sidebar';
@use 'components/site-switcher';
@use 'components/tabs';
@use 'components/toc';

Expand Down
26 changes: 26 additions & 0 deletions src/content/assets/images/branding/dart/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit af86935

Please sign in to comment.