-
Notifications
You must be signed in to change notification settings - Fork 282
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #514 from JHWelch/add-dark-mode
Add Dark & Auto color schemes
- Loading branch information
Showing
18 changed files
with
1,289 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,52 @@ | ||
import * as renderUtils from './render-utils'; | ||
import HoganJsUtils from './hoganjs-utils'; | ||
import { DiffFile } from './types'; | ||
import { ColorSchemeType, DiffFile } from './types'; | ||
|
||
const baseTemplatesPath = 'file-summary'; | ||
const iconsBaseTemplatesPath = 'icon'; | ||
|
||
export function render(diffFiles: DiffFile[], hoganUtils: HoganJsUtils): string { | ||
const files = diffFiles | ||
.map(file => | ||
hoganUtils.render( | ||
baseTemplatesPath, | ||
'line', | ||
{ | ||
fileHtmlId: renderUtils.getHtmlId(file), | ||
oldName: file.oldName, | ||
newName: file.newName, | ||
fileName: renderUtils.filenameDiff(file), | ||
deletedLines: '-' + file.deletedLines, | ||
addedLines: '+' + file.addedLines, | ||
}, | ||
{ | ||
fileIcon: hoganUtils.template(iconsBaseTemplatesPath, renderUtils.getFileIcon(file)), | ||
}, | ||
), | ||
) | ||
.join('\n'); | ||
export interface FileListRendererConfig { | ||
colorScheme?: ColorSchemeType; | ||
} | ||
|
||
export const defaultFileListRendererConfig = { | ||
colorScheme: renderUtils.defaultRenderConfig.colorScheme, | ||
}; | ||
|
||
export class FileListRenderer { | ||
private readonly hoganUtils: HoganJsUtils; | ||
private readonly config: typeof defaultFileListRendererConfig; | ||
|
||
constructor(hoganUtils: HoganJsUtils, config: FileListRendererConfig = {}) { | ||
this.hoganUtils = hoganUtils; | ||
this.config = { ...defaultFileListRendererConfig, ...config }; | ||
} | ||
|
||
render(diffFiles: DiffFile[]): string { | ||
const files = diffFiles | ||
.map(file => | ||
this.hoganUtils.render( | ||
baseTemplatesPath, | ||
'line', | ||
{ | ||
fileHtmlId: renderUtils.getHtmlId(file), | ||
oldName: file.oldName, | ||
newName: file.newName, | ||
fileName: renderUtils.filenameDiff(file), | ||
deletedLines: '-' + file.deletedLines, | ||
addedLines: '+' + file.addedLines, | ||
}, | ||
{ | ||
fileIcon: this.hoganUtils.template(iconsBaseTemplatesPath, renderUtils.getFileIcon(file)), | ||
}, | ||
), | ||
) | ||
.join('\n'); | ||
|
||
return hoganUtils.render(baseTemplatesPath, 'wrapper', { | ||
filesNumber: diffFiles.length, | ||
files: files, | ||
}); | ||
return this.hoganUtils.render(baseTemplatesPath, 'wrapper', { | ||
colorScheme: renderUtils.colorSchemeToCss(this.config.colorScheme), | ||
filesNumber: diffFiles.length, | ||
files: files, | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.