-
-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
271 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...assets/javascripts/bundle.f3bc8daa.min.js → ...assets/javascripts/bundle.d349485d.min.js
Large diffs are not rendered by default.
Oops, something went wrong.
6 changes: 3 additions & 3 deletions
6
...ts/javascripts/bundle.f3bc8daa.min.js.map → ...ts/javascripts/bundle.d349485d.min.js.map
Large diffs are not rendered by default.
Oops, something went wrong.
4 changes: 2 additions & 2 deletions
4
.../assets/stylesheets/main.793c28ab.min.css → .../assets/stylesheets/main.3149646c.min.css
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 3 additions & 3 deletions
6
...assets/javascripts/bundle.c0db31d2.min.js → ...assets/javascripts/bundle.711bd5c6.min.js
Large diffs are not rendered by default.
Oops, something went wrong.
4 changes: 2 additions & 2 deletions
4
...ts/javascripts/bundle.c0db31d2.min.js.map → ...ts/javascripts/bundle.711bd5c6.min.js.map
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/* | ||
* Copyright (c) 2016-2021 Martin Donath <martin.donath@squidfunk.com> | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to | ||
* deal in the Software without restriction, including without limitation the | ||
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or | ||
* sell copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS | ||
* IN THE SOFTWARE. | ||
*/ | ||
|
||
import { configuration } from "~/_" | ||
import { h } from "~/utilities" | ||
|
||
/* ---------------------------------------------------------------------------- | ||
* Types | ||
* ------------------------------------------------------------------------- */ | ||
|
||
/** | ||
* Version | ||
*/ | ||
export interface Version { | ||
version: string /* Version identifier */ | ||
title: string /* Version title */ | ||
aliases: string[] /* Version aliases */ | ||
} | ||
|
||
/* ---------------------------------------------------------------------------- | ||
* Functions | ||
* ------------------------------------------------------------------------- */ | ||
|
||
/** | ||
* Render a version selector | ||
* | ||
* @param versions - Versions | ||
* | ||
* @returns Element | ||
*/ | ||
export function renderVersionSelector(versions: Version[]): HTMLElement { | ||
const config = configuration() | ||
|
||
/* Determine active version */ | ||
const [, current] = config.base.match(/([^/]+)\/?$/)! | ||
const active = | ||
versions.find(({ version, aliases }) => ( | ||
version === current || aliases.includes(current) | ||
)) || versions[0] | ||
|
||
/* Render version selector */ | ||
return ( | ||
<div class="md-version"> | ||
<span class="md-version__current"> | ||
{active.version} | ||
</span> | ||
<ul class="md-version__list"> | ||
{versions.map(version => ( | ||
<li class="md-version__item"> | ||
<a | ||
class="md-version__link" | ||
href={`${new URL(version.version, config.base)}`} | ||
> | ||
{version.title} | ||
</a> | ||
</li> | ||
))} | ||
</ul> | ||
</div> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
//// | ||
/// Copyright (c) 2016-2021 Martin Donath <martin.donath@squidfunk.com> | ||
/// | ||
/// Permission is hereby granted, free of charge, to any person obtaining a | ||
/// copy of this software and associated documentation files (the "Software"), | ||
/// to deal in the Software without restriction, including without limitation | ||
/// the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
/// and/or sell copies of the Software, and to permit persons to whom the | ||
/// Software is furnished to do so, subject to the following conditions: | ||
/// | ||
/// The above copyright notice and this permission notice shall be included in | ||
/// all copies or substantial portions of the Software. | ||
/// | ||
/// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
/// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
/// FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL | ||
/// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
/// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
/// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
/// DEALINGS | ||
//// | ||
|
||
// ---------------------------------------------------------------------------- | ||
// Rules | ||
// ---------------------------------------------------------------------------- | ||
|
||
// Icon definitions | ||
:root { | ||
--md-version-icon: svg-load("fontawesome/solid/caret-down.svg"); | ||
} | ||
|
||
// ---------------------------------------------------------------------------- | ||
|
||
// Version selection | ||
.md-version { | ||
flex-shrink: 0; | ||
height: px2rem(48px); | ||
font-size: px2rem(16px); | ||
|
||
// Current selection | ||
&__current { | ||
position: relative; | ||
// Hack: in general, we would use `vertical-align` to align the version at | ||
// the bottom with the title, but since the list uses absolute positioning, | ||
// this won't work consistently. Furthermore, we would need to use inline | ||
// positioning to align the links, which looks jagged. | ||
top: px2rem(1px); | ||
margin-right: px2rem(8px); | ||
margin-left: px2rem(28px); | ||
|
||
// Adjust for right-to-left languages | ||
[dir="rtl"] & { | ||
margin-right: px2rem(28px); | ||
margin-left: px2rem(8px); | ||
} | ||
|
||
// Version selection icon | ||
&::after { | ||
display: inline-block; | ||
width: px2rem(8px); | ||
height: px2rem(12px); | ||
margin-left: px2rem(8px); | ||
background-color: currentColor; | ||
mask-image: var(--md-version-icon); | ||
mask-repeat: no-repeat; | ||
content: ""; | ||
|
||
// Adjust for right-to-left languages | ||
[dir="rtl"] & { | ||
margin-right: px2rem(8px); | ||
margin-left: initial; | ||
} | ||
} | ||
} | ||
|
||
// Version selection list | ||
&__list { | ||
position: absolute; | ||
top: px2rem(3px); | ||
z-index: 1; | ||
max-height: px2rem(36px); | ||
margin: px2rem(4px) px2rem(16px); | ||
padding: 0; | ||
overflow: auto; | ||
color: var(--md-default-fg-color); | ||
list-style-type: none; | ||
background-color: var(--md-default-bg-color); | ||
border-radius: px2rem(2px); | ||
box-shadow: | ||
0 px2rem(4px) px2rem(10px) hsla(0, 0%, 0%, 0.1), | ||
0 0 px2rem(1px) hsla(0, 0%, 0%, 0.25); | ||
opacity: 0; | ||
transition: | ||
max-height 0ms 500ms, | ||
opacity 250ms 250ms; | ||
scroll-snap-type: y mandatory; | ||
|
||
// List on focus/hover | ||
&:focus-within, | ||
&:hover { | ||
max-height: px2rem(200px); | ||
opacity: 1; | ||
transition: | ||
max-height 250ms, | ||
opacity 250ms; | ||
} | ||
} | ||
|
||
// Version selection item | ||
&__item { | ||
line-height: px2rem(36px); | ||
} | ||
|
||
// Version selection link | ||
&__link { | ||
display: block; | ||
width: 100%; | ||
padding-right: px2rem(24px); | ||
padding-left: px2rem(12px); | ||
white-space: nowrap; | ||
cursor: pointer; | ||
transition: | ||
color 250ms, | ||
background-color 250ms; | ||
scroll-snap-align: start; | ||
|
||
// Adjust for right-to-left languages | ||
[dir="rtl"] & { | ||
padding-right: px2rem(12px); | ||
padding-left: px2rem(24px); | ||
} | ||
|
||
// Link on focus/hover | ||
&:focus, | ||
&:hover { | ||
background-color: var(--md-default-fg-color--lightest); | ||
} | ||
} | ||
} |
Oops, something went wrong.