11import type { ReplacementSelectorSet , Site } from '.' ;
2+ import { ATTRIBUTE_PREFIX } from '../constants' ;
23
34const mainRepositoryImplementation : ReplacementSelectorSet = {
45 row : '#file-tree > div, .tree > div' ,
@@ -10,7 +11,30 @@ const mainRepositoryImplementation: ReplacementSelectorSet = {
1011 isCollapsable : ( _rowEl , _fileNameEl , _iconEl ) => false ,
1112} ;
1213
14+ const commitTreeImplementation : ReplacementSelectorSet = {
15+ row : '.diff-stat .tree-directory, .diff-stat .tree-file' ,
16+ filename : '.filename' ,
17+ icon : 'svg' ,
18+ isDirectory : ( rowEl , _fileNameEl , _iconEl ) =>
19+ rowEl . classList . contains ( 'tree-directory' ) ,
20+ isSubmodule : ( _rowEl , _fileNameEl , _iconEl ) => false , // TODO: Implement isSubmodule.
21+ isCollapsable : ( rowEl , fileNameEl , iconEl ) =>
22+ commitTreeImplementation . isDirectory ( rowEl , fileNameEl , iconEl ) ,
23+ } ;
24+ commitTreeImplementation . styles = /* css */ `
25+ /* Hide directory icons by default. */
26+ ${ commitTreeImplementation . row . split ( ',' ) . at ( 0 ) } ${ commitTreeImplementation . icon } {
27+ display: none;
28+ }
29+
30+ /* Show relevant extension directory icon depending on open/closed state. */
31+ details[open] > summary > .tree-directory svg[${ ATTRIBUTE_PREFIX } -iconname$='_open'],
32+ details:not([open]) > summary > .tree-directory svg[${ ATTRIBUTE_PREFIX } ]:not([${ ATTRIBUTE_PREFIX } -iconname$='_open']) {
33+ display: inline-block !important;
34+ }
35+ ` . trim ( ) ;
36+
1337export const tangled : Site = {
1438 domains : [ 'tangled.sh' ] ,
15- replacements : [ mainRepositoryImplementation ] ,
39+ replacements : [ mainRepositoryImplementation , commitTreeImplementation ] ,
1640} ;
0 commit comments