@tomplum/react-git-log
Version:
A flexible, themable, React component for visualising Git commit history, branch and tag metadata.
115 lines (114 loc) • 4 kB
TypeScript
import { Commit } from '../../types/Commit';
export interface ThemeFunctions {
/**
* The current active theme mode.
* @example light, dark
*/
theme: ThemeMode;
/**
* An rgb() colour string for
* text that is being hovered over
* relative to the currently active
* {@link theme}.
*/
hoverColour: string;
/**
* An rgb() colour string for
* text relative to the currently
* active {@link theme}.
*/
textColour: string;
/**
* An rgb() colour string for
* background of a tooltip relative
* to the currently active {@link theme}.
*/
getTooltipBackground: (commit: Commit) => string;
/**
* The duration, in milliseconds, of
* the animation for hover transition
* effects.
*/
hoverTransitionDuration: number;
/**
* Blends an RGB color with a background color to simulate an alpha effect.
*
* This function adjusts the given RGB color as if it were semi-transparent over a background,
* without actually using an alpha channel. The result is a new solid RGB color that appears
* visually similar to an `rgba()` color with transparency.
*
* @param rgb - The colour to shift in `rgb(r, g, b)` format.
* @param opacity - The simulated alpha channel (range: `0` to `1`).
* @returns The blended color in `rgb(r, g, b)` format.
*
* @example
* ```ts
* blendColorWithBackground('rgb(100, 200, 255)', 0.5) // "rgb(50, 100, 128)" (darker blue)
* blendColorWithBackground('rgb(100, 200, 255)', 0.5) // "rgb(178, 228, 255)" (lighter blue)
* ```
*/
shiftAlphaChannel: (rgb: string, opacity: number) => string;
/**
* Reduces the opacity of the given RGB colour string.
*
* @param rbg The colour to reduce the opacity of. Must be in rgb(x, y, z) format.
* @param opacity The desired opacity value from 0 to 1.
*/
reduceOpacity: (rbg: string, opacity: number) => string;
/**
* Gets an rgb() colour string for the
* given {@link Commit} relative to the
* given colours of the git log.
*
* @param commit The commit to get the colour for.
*/
getCommitColour: (commit: Commit) => string;
/**
* Gets an rgb() colour string for the
* given column index relative to the
* given colours of the git log.
*
* @param columnIndex The index to get the colour for.
*/
getGraphColumnColour: (columnIndex: number) => string;
/**
* Gets rgb() colour strings for styling a commit node
* from the given base column colour.
*
* @param args Args to get the colour.
*/
getCommitNodeColours: (args: GetCommitNodeColoursArgs) => CommitNodeColours;
/**
* Gets an rgb() colour string for the background
* colour of a graph column when its row is selected.
*
* @param columnIndex The index of the column where the node is.
*/
getGraphColumnSelectedBackgroundColour: (columnIndex: number) => string;
}
export interface GetCommitNodeColoursArgs {
columnColour: string;
}
export interface CommitNodeColours {
backgroundColour: string;
borderColour: string;
}
export type ThemeMode = 'light' | 'dark';
/**
* The default theme renders merge nodes
* with a different theme to make them
* more distinct from regular commits.
*
* The plain theme renders all nodes
* (except the index pseudo-node) the same.
*/
export type NodeTheme = 'default' | 'plain';
/**
* Determines how the breakpoints (the styling of
* the node edges in the graph if a filter is active
* and is causing breaks in the graph) are rendered.
*/
export type BreakPointTheme = 'slash' | 'dot' | 'ring' | 'zig-zag' | 'line' | 'double-line' | 'arrow';
export type ThemeColours = 'rainbow-dark' | 'rainbow-light' | 'neon-aurora-dark' | 'neon-aurora-light';
export declare const neonAuroraDarkColours: string[];
export declare const neonAuroraLightColours: string[];