Skip to content
Merged
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
2 changes: 2 additions & 0 deletions astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ export default defineConfig({
tableOfContents: { minHeadingLevel: 2, maxHeadingLevel: 4 },
components: {
Footer: './src/components/overrides/Footer.astro',
Header: './src/components/overrides/Header.astro',
MobileMenuFooter: './src/components/overrides/MobileMenuFooter.astro',
Sidebar: './src/components/overrides/Sidebar.astro',
SocialIcons: './src/components/overrides/SocialIcons.astro'
}
Expand Down
38 changes: 38 additions & 0 deletions cypress/e2e/release-badge.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
const releaseUrl =
'https://github.com/archivesspace/archivesspace/releases/latest'
const title = 'Go to the latest ArchivesSpace release'
const badgeSrc = `https://img.shields.io/github/v/release/archivesspace/archivesspace?label=ArchivesSpace&color=007595`
const altText = 'The latest ArchivesSpace release version'

describe('Release Badge', () => {
it('displays the release badge with the correct data in the header on desktop', () => {
cy.visit('/')
cy.get(
'.page > header:first-child > div:first-child > div:nth-child(3) > a:first-child'
)
.should('have.attr', 'href', releaseUrl)
.should('have.attr', 'title', title)
.within(() => {
cy.get('img')
.should('have.attr', 'src', badgeSrc)
.should('have.attr', 'alt', altText)
})
})

it(
'displays the release badge with the correct data in the mobile menu footer',
{ viewportWidth: 400 },
() => {
cy.visit('/')
cy.get('button[aria-label="Menu"]').click()
cy.get('#starlight__sidebar .mobile-preferences > a:first-child')
.should('have.attr', 'href', releaseUrl)
.should('have.attr', 'title', title)
.within(() => {
cy.get('img')
.should('have.attr', 'src', badgeSrc)
.should('have.attr', 'alt', altText)
})
}
)
})
28 changes: 28 additions & 0 deletions src/components/ReleaseBadge.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
const releaseUrl =
'https://github.com/archivesspace/archivesspace/releases/latest'
const label = 'ArchivesSpace'
const color = '007595' // dark `--sl-color-accent` via custom.css
const badgeSrc = `https://img.shields.io/github/v/release/archivesspace/archivesspace?label=${label}&color=${color}`
const altText = 'The latest ArchivesSpace release version'
const title = 'Go to the latest ArchivesSpace release'
---

<a href={releaseUrl} title={title}>
<img alt={altText} src={badgeSrc} />
</a>

<style>
a {
display: flex;
align-items: center;
gap: 1rem;
}
@media (min-width: 800px) {
a::after {
content: '';
height: 2rem;
border-inline-end: 1px solid var(--as-color-hairline);
}
}
</style>
105 changes: 105 additions & 0 deletions src/components/overrides/Header.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
---
// Via https://github.com/withastro/starlight/blob/23bf960aed36445600b6ccecb2138a5b461e2929/packages/starlight/components/Header.astro

import config from 'virtual:starlight/user-config'
import type { Props } from '@astrojs/starlight/props'

import LanguageSelect from '@astrojs/starlight/components/LanguageSelect.astro'
import Search from '@astrojs/starlight/components/Search.astro'
import SiteTitle from '@astrojs/starlight/components/SiteTitle.astro'
import ReleaseBadge from '../ReleaseBadge.astro'
import SocialIcons from './SocialIcons.astro'
import ThemeSelect from '@astrojs/starlight/components/ThemeSelect.astro'

/**
* Render the `Search` component if Pagefind is enabled or the default search component has been overridden.
*/
const shouldRenderSearch =
config.pagefind ||
config.components.Search !== '@astrojs/starlight/components/Search.astro'
---

<div class="header sl-flex">
<div class="title-wrapper sl-flex">
<SiteTitle {...Astro.props} />
</div>
<div class="sl-flex print:hidden">
{shouldRenderSearch && <Search {...Astro.props} />}
</div>
<div class="sl-hidden md:sl-flex print:hidden right-group">
<ReleaseBadge />
<div class="sl-flex social-icons">
<SocialIcons {...Astro.props} />
</div>
<ThemeSelect {...Astro.props} />
<LanguageSelect {...Astro.props} />
</div>
</div>

<style>
.header {
gap: var(--sl-nav-gap);
justify-content: space-between;
align-items: center;
height: 100%;
}

.title-wrapper {
/* Prevent long titles overflowing and covering the search and menu buttons on narrow viewports. */
overflow: clip;
/* Avoid clipping focus ring around link inside title wrapper. */
padding: 0.25rem;
margin: -0.25rem;
min-width: 0;
}

.right-group,
.social-icons {
gap: 1rem;
align-items: center;
}
.social-icons::after {
content: '';
height: 2rem;
border-inline-end: 1px solid var(--sl-color-gray-5);
}

@media (min-width: 50rem) {
:global(:root[data-has-sidebar]) {
--__sidebar-pad: calc(2 * var(--sl-nav-pad-x));
}
:global(:root:not([data-has-toc])) {
--__toc-width: 0rem;
}
.header {
--__sidebar-width: max(
0rem,
var(--sl-content-inline-start, 0rem) - var(--sl-nav-pad-x)
);
--__main-column-fr: calc(
(
100% + var(--__sidebar-pad, 0rem) -
var(--__toc-width, var(--sl-sidebar-width)) -
(2 * var(--__toc-width, var(--sl-nav-pad-x))) -
var(--sl-content-inline-start, 0rem) - var(--sl-content-width)
) /
2
);
display: grid;
grid-template-columns:
/* 1 (site title): runs up until the main content column’s left edge or the width of the title, whichever is the largest */
minmax(
calc(
var(--__sidebar-width) +
max(0rem, var(--__main-column-fr) - var(--sl-nav-gap))
),
auto
)
/* 2 (search box): all free space that is available. */
1fr
/* 3 (right items): use the space that these need. */
auto;
align-content: center;
}
}
</style>
37 changes: 37 additions & 0 deletions src/components/overrides/MobileMenuFooter.astro
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
---
// Via https://github.com/withastro/starlight/blob/490c6eff34ab408c4f55777b7b0caa16787dd3d4/packages/starlight/components/MobileMenuFooter.astro

import type { Props } from '@astrojs/starlight/props'
import LanguageSelect from '@astrojs/starlight/components/LanguageSelect.astro'
import ReleaseBadge from '../ReleaseBadge.astro'
import SocialIcons from './SocialIcons.astro'
import ThemeSelect from '@astrojs/starlight/components/ThemeSelect.astro'
---

<div class="mobile-preferences sl-flex">
<ReleaseBadge />
<div class="sl-flex social-icons">
<SocialIcons {...Astro.props} />
</div>
<ThemeSelect {...Astro.props} />
<LanguageSelect {...Astro.props} />
</div>

<style>
.social-icons {
margin-inline-end: auto;
gap: 1rem;
align-items: center;
padding-block: 1rem;
}
.social-icons:empty {
display: none;
}
.mobile-preferences {
justify-content: space-between;
flex-wrap: wrap;
border-top: 1px solid var(--sl-color-gray-6);
column-gap: 1rem;
padding: 0.5rem 0;
}
</style>
4 changes: 2 additions & 2 deletions src/utils/gitMetadata.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { exec } from 'child_process'
import { promisify } from 'util'
import { exec } from 'node:child_process'
import { promisify } from 'node:util'

const execPromise = promisify(exec)

Expand Down
Loading