mirror of
https://github.com/catppuccin/web-file-explorer-icons.git
synced 2026-01-09 05:50:49 +08:00
feat(sites): release asset/artifact icons (#204)
This commit is contained in:
parent
1fd9c213e4
commit
2efd154449
@ -116,12 +116,15 @@ export async function replaceIconInRow(
|
||||
selectors.filename as string,
|
||||
) as HTMLElement);
|
||||
if (!fileNameEl) return;
|
||||
const fileName = fileNameEl.textContent
|
||||
?.split('/')
|
||||
.at(-1)
|
||||
.trim()
|
||||
/* Remove [Unicode LEFT-TO-RIGHT MARK](https://en.wikipedia.org/wiki/Left-to-right_mark) used on GitLab's merge request diff file tree. */
|
||||
.replace(/\u200E/g, '');
|
||||
const fileName =
|
||||
'getFilename' in selectors
|
||||
? selectors.getFilename(rowEl, fileNameEl, iconEl)
|
||||
: fileNameEl.textContent
|
||||
?.split('/')
|
||||
.at(-1)
|
||||
.trim()
|
||||
/* Remove [Unicode LEFT-TO-RIGHT MARK](https://en.wikipedia.org/wiki/Left-to-right_mark) used on GitLab's merge request diff file tree. */
|
||||
.replace(/\u200E/g, '');
|
||||
|
||||
const fileExtensions: Array<string> = [];
|
||||
// Avoid doing an explosive combination of extensions for very long filenames
|
||||
|
||||
@ -37,7 +37,22 @@ ${diffTreeImplementation.row} {
|
||||
}
|
||||
`.trim();
|
||||
|
||||
const releaseAssetsImplementation: ReplacementSelectorSet = {
|
||||
row: '#release-list .download li',
|
||||
filename: 'a',
|
||||
icon: 'a > svg',
|
||||
isDirectory: (_rowEl, _fileNameEl, _iconEl) => false,
|
||||
isSubmodule: (_rowEl, _fileNameEl, _iconEl) => false,
|
||||
isCollapsable: (_rowEl, _fileNameEl, _iconEl) => false,
|
||||
getFilename: (_rowEl, fileNameEl, _iconEl) =>
|
||||
(fileNameEl as HTMLAnchorElement).href,
|
||||
};
|
||||
|
||||
export const forgejo: Site = {
|
||||
domains: ['codeberg.org'],
|
||||
replacements: [mainRepositoryImplementation, diffTreeImplementation],
|
||||
replacements: [
|
||||
mainRepositoryImplementation,
|
||||
diffTreeImplementation,
|
||||
releaseAssetsImplementation,
|
||||
],
|
||||
};
|
||||
|
||||
@ -70,6 +70,17 @@ ${diffTreeImplementation.row} {
|
||||
}
|
||||
`.trim();
|
||||
|
||||
const releaseAssetsImplementation: ReplacementSelectorSet = {
|
||||
row: '#release-list .download li',
|
||||
filename: 'a',
|
||||
icon: 'a svg',
|
||||
isDirectory: (_rowEl, _fileNameEl, _iconEl) => false,
|
||||
isSubmodule: (_rowEl, _fileNameEl, _iconEl) => false,
|
||||
isCollapsable: (_rowEl, _fileNameEl, _iconEl) => false,
|
||||
getFilename: (_rowEl, fileNameEl, _iconEl) =>
|
||||
(fileNameEl as HTMLAnchorElement).href,
|
||||
};
|
||||
|
||||
export const gitea: Site = {
|
||||
domains: ['gitea.com'],
|
||||
replacements: [
|
||||
@ -77,5 +88,6 @@ export const gitea: Site = {
|
||||
mainRepositoryParentLinkImplementation,
|
||||
repositorySideTreeImplementation,
|
||||
diffTreeImplementation,
|
||||
releaseAssetsImplementation,
|
||||
],
|
||||
};
|
||||
|
||||
@ -76,6 +76,24 @@ ${pullRequestTreeImplementation.row} {
|
||||
}
|
||||
`.trim();
|
||||
|
||||
const releaseAssetsImplementation: ReplacementSelectorSet = {
|
||||
row: '#release_page_title + div > section ul li',
|
||||
filename: 'a.Truncate',
|
||||
icon: 'svg.octicon',
|
||||
isDirectory: (_rowEl, _fileNameEl, _iconEl) => false,
|
||||
isSubmodule: (_rowEl, _fileNameEl, _iconEl) => false,
|
||||
isCollapsable: (_rowEl, _fileNameEl, _iconEl) => false,
|
||||
getFilename: (_rowEl, fileNameEl, _iconEl) =>
|
||||
(fileNameEl as HTMLAnchorElement).href,
|
||||
};
|
||||
releaseAssetsImplementation.styles = /* css */ `
|
||||
${releaseAssetsImplementation.row} {
|
||||
svg[${ATTRIBUTE_PREFIX}] {
|
||||
margin-right: 4px;
|
||||
}
|
||||
}
|
||||
`.trim();
|
||||
|
||||
export const github: Site = {
|
||||
domains: ['github.com'],
|
||||
replacements: [
|
||||
@ -83,5 +101,6 @@ export const github: Site = {
|
||||
repositoryMainImplementation,
|
||||
pullRequestTreeImplementation,
|
||||
repositoryMainParentDirectoryImplementation,
|
||||
releaseAssetsImplementation,
|
||||
],
|
||||
};
|
||||
|
||||
@ -18,6 +18,7 @@ export type ReplacementSelectorSet = {
|
||||
isDirectory: FnWithContext<boolean>;
|
||||
isSubmodule: FnWithContext<boolean>;
|
||||
isCollapsable: FnWithContext<boolean>;
|
||||
getFilename?: FnWithContext<string>;
|
||||
styles?: string;
|
||||
};
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user