MCPcopy Index your code
hub / github.com/refined-github/refined-github / createElement

Function createElement

source/features/show-names.tsx:24–59  ·  view source on GitHub ↗
(element: HTMLAnchorElement, fullName: string)

Source from the content-addressed store, hash-verified

22}
23
24function createElement(element: HTMLAnchorElement, fullName: string): JSX.Element {
25 const nameElement = (
26 <span className="color-fg-muted css-truncate d-inline-block rgh-show-names no-wrap">
27 {/* .css-truncate-target sets display: inline-block and confines bidi overrides #8191 */}
28 (<span className="css-truncate-target" style={{maxWidth: '200px'}}>{fullName}</span>)
29 </span>
30 );
31
32 if (
33 element.matches([
34 '.feed-item-content *',
35 // PR event:
36 // - https://github.com/refined-github/refined-github/pull/8970#event-22710755292
37 // - https://github.com/refined-github/refined-github/pull/8970#event-22710646301
38 // `readable-title-change-events` adds gap to rename events
39 '.TimelineItem-body:not(:has(> del.markdown-title)) > *',
40 // Reference event: https://github.com/refined-github/refined-github/pull/9041#ref-issue-4028015976
41 '.TimelineItem-body > div > *',
42 ])
43 ) {
44 nameElement.classList.add('ml-1');
45 } else if (
46 element.matches(
47 // Issue event:
48 // - https://github.com/refined-github/sandbox/issues/3#event-5474574930
49 // - https://github.com/refined-github/sandbox/issues/3#event-10265481248
50 // Username in issue events already has left margin
51 // Rename events use `gap` for spacing
52 '[class*="timelineBodyContent"]:not(:has(> [class*="RenamedTitleEvent"])) *',
53 )
54 ) {
55 nameElement.classList.add('mr-1');
56 }
57
58 return nameElement;
59}
60
61function appendName(element: HTMLAnchorElement, fullName: string): void {
62 // If it's a regular comment author, add it outside <strong> otherwise it's something like "User added some commits"

Callers 1

appendNameFunction · 0.85

Calls 1

matchesMethod · 0.80

Tested by

no test coverage detected