Skip to content

Commit

Permalink
sticky subheadings
Browse files Browse the repository at this point in the history
  • Loading branch information
towerofnix committed Dec 4, 2022
1 parent 690a7b5 commit 4a1997b
Show file tree
Hide file tree
Showing 14 changed files with 272 additions and 49 deletions.
1 change: 0 additions & 1 deletion src/data/things/language.js
Expand Up @@ -296,7 +296,6 @@ export class Language extends Thing {
return this.formatString('count.fileSize.bytes', {bytes});
}
}

}

const countHelper = (stringKey, argName = stringKey) =>
Expand Down
7 changes: 7 additions & 0 deletions src/listing-spec.js
Expand Up @@ -96,6 +96,7 @@ const listingSpec = [
html.tag('dl',
data.flatMap(({dateAddedToWiki, chunk: albums}) => [
html.tag('dt',
{class: ['content-heading']},
language.$('listingPage.listAlbums.byDateAdded.date', {
date: language.formatDate(dateAddedToWiki),
})),
Expand Down Expand Up @@ -445,6 +446,7 @@ const listingSpec = [
html.tag('dl',
data.flatMap(({category, groups}) => [
html.tag('dt',
{class: ['content-heading']},
language.$('listingPage.listGroups.byCategory.category', {
category: empty(groups)
? category.name
Expand Down Expand Up @@ -594,6 +596,7 @@ const listingSpec = [
html.tag('dl',
data.flatMap(({album, tracks}) => [
html.tag('dt',
{class: ['content-heading']},
language.$('listingPage.listTracks.byAlbum.album', {
album: link.album(album),
})),
Expand Down Expand Up @@ -678,6 +681,7 @@ const listingSpec = [
html.tag('dl',
data.flatMap(({album, tracks}) => [
html.tag('dt',
{class: ['content-heading']},
language.$('listingPage.listTracks.byDurationInAlbum.album', {
album: link.album(album),
})),
Expand Down Expand Up @@ -731,6 +735,7 @@ const listingSpec = [
html.tag('dl',
data.flatMap(({album, chunk: tracks}) => [
html.tag('dt',
{class: ['content-heading']},
language.$('listingPage.listTracks.inFlashes.byAlbum.album', {
album: link.album(album),
date: language.formatDate(album.date),
Expand Down Expand Up @@ -766,6 +771,7 @@ const listingSpec = [
html.tag('dl',
data.flatMap(({flash, tracks}) => [
html.tag('dt',
{class: ['content-heading']},
language.$('listingPage.listTracks.inFlashes.byFlash.flash', {
flash: link.flash(flash),
date: language.formatDate(flash.date),
Expand Down Expand Up @@ -798,6 +804,7 @@ const listingSpec = [
html.tag('dl',
data.flatMap(({album, tracks}) => [
html.tag('dt',
{class: ['content-heading']},
language.$('listingPage.listTracks.withLyrics.album', {
album: link.album(album),
date: language.formatDate(album.date),
Expand Down
20 changes: 19 additions & 1 deletion src/misc-templates.js
Expand Up @@ -50,7 +50,10 @@ function unbound_generateAdditionalFilesList(additionalFiles, {

return html.fragment([
html.tag('p',
{id: 'additional-files'},
{
id: 'additional-files',
class: ['content-heading'],
},
language.$('releaseInfo.additionalFiles.heading', {
additionalFiles: language.countAdditionalFiles(fileCount, {
unit: true,
Expand Down Expand Up @@ -717,6 +720,19 @@ function unbound_generateNavigationLinks(current, {
return language.formatUnitList(links);
}

// Sticky heading, ooooo

function unbound_generateStickyHeadingContainer(headingContent, {
html,
}) {
return html.tag('div',
{class: 'content-sticky-heading-container'},
[
html.tag('h1', headingContent),
html.tag('h2', {class: 'content-sticky-subheading'}),
]);
}

// Footer stuff

function unbound_getFooterLocalizationLinks(pathname, {
Expand Down Expand Up @@ -794,5 +810,7 @@ export {
unbound_generateInfoGalleryLinks as generateInfoGalleryLinks,
unbound_generateNavigationLinks as generateNavigationLinks,

unbound_generateStickyHeadingContainer as generateStickyHeadingContainer,

unbound_getFooterLocalizationLinks as getFooterLocalizationLinks,
}
30 changes: 20 additions & 10 deletions src/page/album-commentary.js
Expand Up @@ -21,6 +21,7 @@ export function write(album) {
type: 'page',
path: ['albumCommentary', album.directory],
page: ({
generateStickyHeadingContainer,
getAlbumStylesheet,
getLinkThemeString,
getThemeString,
Expand All @@ -35,23 +36,32 @@ export function write(album) {

main: {
content: html.tag('div', {class: 'long-content'}, [
html.tag('h1', language.$('albumCommentaryPage.title', {
album: link.album(album),
})),
html.tag('p', language.$('albumCommentaryPage.infoLine', {
words: html.tag('b', language.formatWordCount(words, {unit: true})),
entries: html.tag('b', language.countCommentaryEntries(entries.length, {unit: true})),
})),
generateStickyHeadingContainer(
language.$('albumCommentaryPage.title', {
album: link.album(album),
})),

html.tag('p',
language.$('albumCommentaryPage.infoLine', {
words: html.tag('b', language.formatWordCount(words, {unit: true})),
entries: html.tag('b', language.countCommentaryEntries(entries.length, {unit: true})),
})),

...html.fragment(album.commentary && [
html.tag('h3', language.$('albumCommentaryPage.entry.title.albumCommentary')),
html.tag('blockquote', transformMultiline(album.commentary)),
html.tag('h3',
{class: ['content-heading']},
language.$('albumCommentaryPage.entry.title.albumCommentary')),
html.tag('blockquote',
transformMultiline(album.commentary)),
]),

...album.tracks.filter(t => t.commentary).flatMap(track => [
html.tag('h3',
{id: 'track.directory'},
{id: 'track.directory', class: ['content-heading']},
language.$('albumCommentaryPage.entry.title.trackCommentary', {
track: link.track(track),
})),

html.tag('blockquote',
{style: getLinkThemeString(track.color)},
transformMultiline(track.commentary)),
Expand Down
11 changes: 7 additions & 4 deletions src/page/album.js
Expand Up @@ -106,6 +106,7 @@ export function write(album, {wikiData}) {
generateChronologyLinks,
generateCoverLink,
generateNavigationLinks,
generateStickyHeadingContainer,
getAlbumCover,
getAlbumStylesheet,
getArtistString,
Expand Down Expand Up @@ -159,9 +160,8 @@ export function write(album, {wikiData}) {
tags: album.artTags,
}),

html.tag('h1', language.$('albumPage.title', {
album: album.name,
})),
generateStickyHeadingContainer(
language.$('albumPage.title', {album: album.name})),

html.tag('p',
{
Expand Down Expand Up @@ -254,6 +254,7 @@ export function write(album, {wikiData}) {
tracks,
}) => [
html.tag('dt',
{class: ['content-heading']},
language.$('trackList.section.withDuration', {
duration: language.formatDuration(getTotalDuration(tracks), {
approximate: tracks.length > 1,
Expand Down Expand Up @@ -300,7 +301,9 @@ export function write(album, {wikiData}) {

...html.fragment(
album.commentary && [
html.tag('p', language.$('releaseInfo.artistCommentary')),
html.tag('p',
{class: ['content-heading']},
language.$('releaseInfo.artistCommentary')),
html.tag('blockquote', transformMultiline(album.commentary)),
]),
],
Expand Down
11 changes: 6 additions & 5 deletions src/page/artist.js
Expand Up @@ -321,6 +321,7 @@ export function write(artist, {wikiData}) {
fancifyURL,
generateCoverLink,
generateInfoGalleryLinks,
generateStickyHeadingContainer,
getArtistAvatar,
getArtistString,
html,
Expand All @@ -346,7 +347,7 @@ export function write(artist, {wikiData}) {
alt: language.$('misc.alt.artistAvatar'),
}),

html.tag('h1',
generateStickyHeadingContainer(
language.$('artistPage.title', {
artist: name,
})),
Expand Down Expand Up @@ -408,7 +409,7 @@ export function write(artist, {wikiData}) {
...html.fragment(
!empty(allTracks) && [
html.tag('h2',
{id: 'tracks'},
{id: 'tracks', class: ['content-heading']},
language.$('artistPage.trackList.title')),

totalDuration > 0 &&
Expand Down Expand Up @@ -446,7 +447,7 @@ export function write(artist, {wikiData}) {
...html.fragment(
!empty(artThingsAll) && [
html.tag('h2',
{id: 'art'},
{id: 'art', class: ['content-heading']},
language.$('artistPage.artList.title')),

hasGallery &&
Expand Down Expand Up @@ -513,7 +514,7 @@ export function write(artist, {wikiData}) {
wikiInfo.enableFlashesAndGames &&
!empty(flashes) && [
html.tag('h2',
{id: 'flashes'},
{id: 'flashes', class: ['content-heading']},
language.$('artistPage.flashList.title')),

html.tag('dl',
Expand Down Expand Up @@ -555,7 +556,7 @@ export function write(artist, {wikiData}) {
...html.fragment(
!empty(commentaryThings) && [
html.tag('h2',
{id: 'commentary'},
{id: 'commentary', class: ['content-heading']},
language.$('artistPage.commentaryList.title')),

html.tag('dl',
Expand Down
5 changes: 4 additions & 1 deletion src/page/flash.js
Expand Up @@ -20,6 +20,7 @@ export function write(flash, {wikiData}) {
generateChronologyLinks,
generateCoverLink,
generateNavigationLinks,
generateStickyHeadingContainer,
getArtistString,
getFlashCover,
getThemeString,
Expand All @@ -44,7 +45,7 @@ export function write(flash, {wikiData}) {
alt: language.$('misc.alt.flashArt'),
}),

html.tag('h1',
generateStickyHeadingContainer(
language.$('flashPage.title', {
flash: flash.name,
})),
Expand All @@ -68,6 +69,7 @@ export function write(flash, {wikiData}) {
...html.fragment(
!empty(flash.featuredTracks) && [
html.tag('p',
{class: ['content-heading']},
language.$('releaseInfo.tracksFeatured', {
flash: html.tag('i', flash.name),
})),
Expand All @@ -87,6 +89,7 @@ export function write(flash, {wikiData}) {
...html.fragment(
!empty(flash.contributorContribs) && [
html.tag('p',
{class: ['content-heading']},
language.$('releaseInfo.contributors')),

html.tag('ul',
Expand Down
4 changes: 3 additions & 1 deletion src/page/group.js
Expand Up @@ -32,6 +32,7 @@ export function write(group, {wikiData}) {
fancifyURL,
generateInfoGalleryLinks,
generateNavigationLinks,
generateStickyHeadingContainer,
getLinkThemeString,
getThemeString,
html,
Expand All @@ -46,7 +47,7 @@ export function write(group, {wikiData}) {

main: {
content: [
html.tag('h1',
generateStickyHeadingContainer(
language.$('groupInfoPage.title', {
group: group.name
})),
Expand All @@ -65,6 +66,7 @@ export function write(group, {wikiData}) {
...html.fragment(
group.albums && [
html.tag('h2',
{class: ['content-heading']},
language.$('groupInfoPage.albumList.title')),

html.tag('p',
Expand Down
4 changes: 3 additions & 1 deletion src/page/listing.js
Expand Up @@ -32,6 +32,7 @@ export function write(listing, {wikiData}) {
path: ['listing', listing.directory],
page: (opts) => {
const {
generateStickyHeadingContainer,
getLinkThemeString,
html,
language,
Expand All @@ -45,7 +46,7 @@ export function write(listing, {wikiData}) {

main: {
content: [
html.tag('h1',
generateStickyHeadingContainer(
language.$(titleKey)),

...html.fragment(
Expand Down Expand Up @@ -230,6 +231,7 @@ function generateLinkIndexForListings(currentListing, forSidebar, {
: html.tag('dl',
filteredByCondition.flatMap(({title, listings}) => [
html.tag('dt',
{class: ['content-heading']},
title({language})),
html.tag('dd',
genUL(listings)),
Expand Down
6 changes: 4 additions & 2 deletions src/page/news.js
Expand Up @@ -14,6 +14,7 @@ export function write(entry, {wikiData}) {
path: ['newsEntry', entry.directory],
page: ({
generateNavigationLinks,
generateStickyHeadingContainer,
html,
language,
link,
Expand All @@ -24,7 +25,7 @@ export function write(entry, {wikiData}) {
main: {
content:
html.tag('div', {class: 'long-content'}, [
html.tag('h1',
generateStickyHeadingContainer(
language.$('newsEntryPage.title', {
entry: entry.name,
})),
Expand Down Expand Up @@ -58,6 +59,7 @@ export function writeTargetless({wikiData}) {
type: 'page',
path: ['newsIndex'],
page: ({
generateStickyHeadingContainer,
html,
language,
link,
Expand All @@ -70,7 +72,7 @@ export function writeTargetless({wikiData}) {
html.tag('div',
{class: ['long-content', 'news-index']},
[
html.tag('h1',
generateStickyHeadingContainer(
language.$('newsIndex.title')),

...newsData.map(entry =>
Expand Down

0 comments on commit 4a1997b

Please sign in to comment.