From 91dbbd7abb7fe526d775f4bc4958ad44938bc214 Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Thu, 15 Aug 2024 12:48:21 -0300 Subject: content, css: gRIContributionsLine: wiki edits tooltip --- .../generateReleaseInfoContributionsLine.js | 74 +++++++++++++++------- ...ateReleaseInfoContributionsLineWikiEditsPart.js | 52 +++++++++++++++ src/static/css/site.css | 22 +++++-- src/strings-default.yaml | 8 +++ 4 files changed, 126 insertions(+), 30 deletions(-) create mode 100644 src/content/dependencies/generateReleaseInfoContributionsLineWikiEditsPart.js (limited to 'src') diff --git a/src/content/dependencies/generateReleaseInfoContributionsLine.js b/src/content/dependencies/generateReleaseInfoContributionsLine.js index 3e96ed44..ee817f08 100644 --- a/src/content/dependencies/generateReleaseInfoContributionsLine.js +++ b/src/content/dependencies/generateReleaseInfoContributionsLine.js @@ -1,20 +1,37 @@ import {empty} from '#sugar'; export default { - contentDependencies: ['linkContribution'], + contentDependencies: [ + 'generateReleaseInfoContributionsLineWikiEditsPart', + 'linkContribution', + ], + extraDependencies: ['html', 'language'], - relations(relation, contributions) { - if (empty(contributions)) { - return {}; - } + query: (contributions) => ({ + normalContributions: + contributions + .filter(contrib => contrib.annotation !== 'edits for wiki'), - return { - contributionLinks: - contributions - .map(contrib => relation('linkContribution', contrib)), - }; - }, + wikiEditContributions: + contributions + .filter(contrib => contrib.annotation === 'edits for wiki'), + }), + + relations: (relation, query, _contributions) => ({ + contributionLinks: + query.normalContributions + .map(contrib => relation('linkContribution', contrib)), + + wikiEditsPart: + relation('generateReleaseInfoContributionsLineWikiEditsPart', + query.wikiEditContributions), + }), + + data: (query, _contributions) => ({ + hasWikiEdits: + !empty(query.wikiEditContributions), + }), slots: { showContribution: {type: 'boolean', default: true}, @@ -25,21 +42,32 @@ export default { chronologyKind: {type: 'string'}, }, - generate(relations, slots, {html, language}) { - if (!relations.contributionLinks) { - return html.blank(); - } + generate(data, relations, slots, {language}) { + const contributionsList = + language.formatConjunctionList( + relations.contributionLinks.map(link => + link.slots({ + showContribution: slots.showContribution, + showExternalLinks: slots.showExternalLinks, + showChronology: slots.showChronology, + chronologyKind: slots.chronologyKind, + }))); return language.$(slots.stringKey, { + [language.onlyIfOptions]: ['artists'], + artists: - language.formatConjunctionList( - relations.contributionLinks.map(link => - link.slots({ - showContribution: slots.showContribution, - showExternalLinks: slots.showExternalLinks, - showChronology: slots.showChronology, - chronologyKind: slots.chronologyKind, - }))), + (data.hasWikiEdits + ? language.encapsulate('misc.artistLink.withEditsForWiki', capsule => + language.$(capsule, { + // It's nonsense to display "+ edits" without + // having any regular contributions, also. + [language.onlyIfOptions]: ['artists'], + + artists: contributionsList, + edits: relations.wikiEditsPart, + })) + : contributionsList), }); }, }; diff --git a/src/content/dependencies/generateReleaseInfoContributionsLineWikiEditsPart.js b/src/content/dependencies/generateReleaseInfoContributionsLineWikiEditsPart.js new file mode 100644 index 00000000..37f29b1c --- /dev/null +++ b/src/content/dependencies/generateReleaseInfoContributionsLineWikiEditsPart.js @@ -0,0 +1,52 @@ +export default { + contentDependencies: [ + 'generateTextWithTooltip', + 'generateTooltip', + 'linkContribution', + ], + + extraDependencies: ['html', 'language'], + + relations: (relation, contributions) => ({ + textWithTooltip: + relation('generateTextWithTooltip'), + + tooltip: + relation('generateTooltip'), + + contributionLinks: + contributions + .map(contrib => relation('linkContribution', contrib)), + }), + + generate: (relations, {html, language}) => + language.encapsulate('misc.artistLink.withEditsForWiki', capsule => + relations.textWithTooltip.slots({ + attributes: + {class: 'wiki-edits'}, + + text: + language.$(capsule, 'edits'), + + tooltip: + relations.tooltip.slots({ + attributes: + {class: 'wiki-edits-tooltip'}, + + content: + html.tags( + relations.contributionLinks.map(link => + language.$(capsule, 'editsLine', { + artist: + link.slots({ + showContribution: false, + showExternalLinks: false, + showChronology: false, + preventTooltip: true, + }), + })), + + {[html.joinChildren]: html.tag('br')}), + }), + })), +}; diff --git a/src/static/css/site.css b/src/static/css/site.css index 92749110..c477fe8c 100644 --- a/src/static/css/site.css +++ b/src/static/css/site.css @@ -845,7 +845,8 @@ a:not([href]):hover { .text-with-tooltip.datetimestamp .text-with-tooltip-interaction-cue, .text-with-tooltip.missing-duration .text-with-tooltip-interaction-cue, -.text-with-tooltip.commentary-date .text-with-tooltip-interaction-cue { +.text-with-tooltip.commentary-date .text-with-tooltip-interaction-cue, +.text-with-tooltip.wiki-edits .text-with-tooltip-interaction-cue { cursor: default; } @@ -907,16 +908,22 @@ li:not(:first-child:last-child) .tooltip, left: -10px; } -.thing-name-tooltip { +.thing-name-tooltip, +.wiki-edits-tooltip { padding: 3px 4px 2px 2px; left: -6px !important; +} - /* Terrifying? - * https://stackoverflow.com/a/64424759/4633828 - */ - margin-right: -120px; +.wiki-edits-tooltip { + font-size: 0.85em; } +/* Terrifying? + * https://stackoverflow.com/a/64424759/4633828 + */ +.thing-name-tooltip { margin-right: -120px; } +.wiki-edits-tooltip { margin-right: -200px; } + .contribution-tooltip .tooltip-content { padding: 6px 2px 2px 2px; @@ -1056,7 +1063,8 @@ li:not(:first-child:last-child) .tooltip, font-size: 0.9em; } -.thing-name-tooltip .tooltip-content { +.thing-name-tooltip .tooltip-content, +.wiki-edits-tooltip .tooltip-content { padding: 3px 4.5px; } diff --git a/src/strings-default.yaml b/src/strings-default.yaml index f2d81f2c..144c1dd1 100644 --- a/src/strings-default.yaml +++ b/src/strings-default.yaml @@ -490,6 +490,14 @@ misc: # Contribution to a track, artwork, or other thing. withContribution: "{ARTIST} ({CONTRIB})" + # Contributions that are annotated "edits for wiki" are + # displayed differently from normal contributions, in a + # tooltip next to the rest of the credits on that line. + withEditsForWiki: + _: "{ARTISTS} ({EDITS})" + edits: "+ edits" + editsLine: "Edits for wiki by {ARTIST}" + # Displayed in an artist's tooltip, if one of their URLs # isn't a specially detected web platform. noExternalLinkPlatformName: "Other" -- cgit 1.3.0-6-gf8a5