diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2024-08-15 12:48:21 -0300 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2024-08-15 12:48:33 -0300 |
commit | 91dbbd7abb7fe526d775f4bc4958ad44938bc214 (patch) | |
tree | f667a421c0765adeb4a09164efb0339e5533132d /src/content | |
parent | a2bf9ff61de1dcdc5406dc3c400aa4abc2dc0425 (diff) |
content, css: gRIContributionsLine: wiki edits tooltip
Diffstat (limited to 'src/content')
-rw-r--r-- | src/content/dependencies/generateReleaseInfoContributionsLine.js | 74 | ||||
-rw-r--r-- | src/content/dependencies/generateReleaseInfoContributionsLineWikiEditsPart.js | 52 |
2 files changed, 103 insertions, 23 deletions
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')}), + }), + })), +}; |