Skip to content

Commit

Permalink
Adds the sticky header to showcase and tweaks some verbiage etc.
Browse files Browse the repository at this point in the history
  • Loading branch information
roblevintennis committed Sep 15, 2020
1 parent a237fac commit c9ee516
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 11 deletions.
16 changes: 16 additions & 0 deletions agnosticui-css/header.css
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,22 @@
flex-wrap: wrap;
}

/**
* If you make your header sticky, you should likely consider that jump links
* e.g. <h1 id="Jump-Here">... will tuck underneath the header! Here's a recommendation
* for how to circumnavigate this issue via scroll-margin-top:
h1[id],
h2[id],
h3[id],
h4[id],
h5[id],
h6[id] {
scroll-margin-top: 80px;
}
* In this case I have a 64px tall header so I've added 16px for clearance -- you'll need
* to curate your own use case, but scroll-margin-top is super useful for this use case.
*/

.header-sticky {
position: sticky;
top: 0;
Expand Down
11 changes: 11 additions & 0 deletions showcase/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,17 @@
text-transform: uppercase;
}

/* Headers with ID attributes (for jump links) */
h1[id],
h2[id],
h3[id],
h4[id],
h5[id],
h6[id] {
/* Header is 64px tall so this adds another 16px clearance */
scroll-margin-top: 80px;
}

/* We're mainly using the <pre> for code snippets */
p,
pre {
Expand Down
6 changes: 4 additions & 2 deletions showcase/src/partials/Colors.vue
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@
<pre v-highlightjs><code class="css">
/**
* You should override these by simply defining them in your top-level stylesheet.
* Please do so for primary and secondary at minimum!
* Simply use the same name you see below less the `-default`. For example, to
* override `--agnostic-default-primary` define `--agnostic-primary`.
*
* Under the hood, when AgnosticUI applies one of these it does something like:
* margin-left: var(--agnostic-primary, var(--agnostic-default-primary));
Expand All @@ -103,7 +104,8 @@
--agnostic-default-light: #ffffff;
}

/* You will override these by defining them in your top-level stylesheet: */
/* You will override these by defining them in your top-level stylesheet, using
the override naming convention of removing the `-default` part: */

:root {
--my-even-more-gaudy-primary: hotpink;
Expand Down
8 changes: 0 additions & 8 deletions showcase/src/partials/Spacing.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,6 @@
>8pt system</a> which is conveniently
relative to the base 16px (1rem) unit used on the web. Spacing is done via CSS custom property tokens.
</h3>
<div :class="$style.hotips">
<p :class="$style.tip">
<span class="quoted">Why do we use CSS custom properties you ask?</span>
</p>
<div :class="$style.tipcontent">
<p></p>
</div>
</div>
<pre v-highlightjs><code class="css">
/**
* agnostic-default- is not used here since these are, essentially, literals for
Expand Down
2 changes: 1 addition & 1 deletion showcase/src/views/AppHeader.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template>
<Header css="HeaderOverrides">
<Header css="HeaderOverrides" isSticky="{true}">
<template v-slot:logoleft>
<a class="logo" href="/">
<svg
Expand Down

0 comments on commit c9ee516

Please sign in to comment.