Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
bae6609
feat(graph): started adding graph rendering strategy prop
TomPlum Apr 8, 2025
aeabcc9
chore(graph): renamed string union type values for the graph render s…
TomPlum Apr 8, 2025
d8208ad
feat(graph): started drawing commits nodes on canvas 2d graph variant
TomPlum Apr 8, 2025
1322051
feat(graph): integrated nodeSize prop with canvas commit nodes
TomPlum Apr 8, 2025
3aadde8
feat(graph): added edges between nodes to canvas graph
TomPlum Apr 8, 2025
f84f1bc
feat(graph): added commit node fill and border colours to canvas nodes
TomPlum Apr 8, 2025
0d67521
chore(graph): added missing tsdoc to useTheme typings
TomPlum Apr 8, 2025
1c57acb
feat(graph): added git index pseudo-node to canvas graph
TomPlum Apr 8, 2025
fb42bff
chore(graph): moved grid render strategy specific hooks and utility f…
TomPlum Apr 8, 2025
b25c442
feat(graph): refactored public api to expose two graph sub-component …
TomPlum Apr 8, 2025
041183d
feat(demo): added custom renderStrategy prop to stories
TomPlum Apr 8, 2025
0849c0b
feat(graph): fixed graph canvas height issue and made it support the …
TomPlum Apr 8, 2025
9866068
chore(graph): refactored canvas graph draw file into a canvas rendere…
TomPlum Apr 9, 2025
1cedb57
feat(graph): canvas graph now supports node theming
TomPlum Apr 9, 2025
737a889
feat(graph): canvas graph now supports flipped orientation
TomPlum Apr 9, 2025
646da34
feat(graph): started adding column background colours to the canvas g…
TomPlum Apr 9, 2025
5f1b617
feat(graph): fixed NPE in canvas mouseover listener
TomPlum Apr 10, 2025
f1e1152
feat(graph): added onClick select commit listener to canvas graph
TomPlum Apr 10, 2025
eaae08c
feat(graph): fixed unnecessary re-renders in canvas during commit pre…
TomPlum Apr 10, 2025
978cbd8
feat(graph): fixed tsc errors in Canvas2DGraph.tsx
TomPlum Apr 10, 2025
21986f8
feat(graph): canvas graph no supports no table background rendering b…
TomPlum Apr 10, 2025
02bf90a
test(graph): added test suite for getColumnBackgroundSize.spec.ts
TomPlum Apr 11, 2025
9abb854
feat(graph): reduce unnecessary re-renders and canvas re-drawing in t…
TomPlum Apr 11, 2025
c79993b
feat(graph): performance improvements with commit selections and canv…
TomPlum Apr 11, 2025
be0da96
feat(graph): fixed bug with preview commits overwriting selected comm…
TomPlum Apr 11, 2025
6d564e4
feat(graph): canvas and html-grid graph variants both share the same …
TomPlum Apr 11, 2025
3c58737
feat(graph): canvas graph now supports preview/select of index pseudo…
TomPlum Apr 11, 2025
9a6a9c8
chore(docs): updated readme with graph rendering strategies
TomPlum Apr 11, 2025
2b24e46
test(graph): fixed failing graph column unit test and clean up stubbing
TomPlum Apr 11, 2025
d483c31
feat(graph): reduced re-renders in canvas graph by using commit hashe…
TomPlum Apr 11, 2025
f98e088
feat(graph): moved showCommitNodeTooltips prop from common to HTML gr…
TomPlum Apr 12, 2025
3099aa3
chore(docs): updated props in docs for graph variants
TomPlum Apr 12, 2025
2128d5a
chore(docs): updated bad code refs in docs
TomPlum Apr 15, 2025
76608cc
Merge branch 'main' into develop
TomPlum May 3, 2025
39286a6
Merge branch 'refs/heads/main' into develop
TomPlum May 17, 2025
d5ffbb7
Merge branch 'refs/heads/main' into develop
TomPlum May 19, 2025
75932eb
chore(deps): react 19 overrides to fix failing tests
TomPlum May 19, 2025
d9b5b8e
chore(deps): set library node engine to >=22.0.0
TomPlum May 19, 2025
c7373b8
chore(config): bumped library version to 3.0.0 for 2d canvas release
TomPlum May 19, 2025
be33e3e
Merge branch 'main' into develop
TomPlum May 31, 2025
af8fb85
fix(test): skipped integration tests
TomPlum Jun 10, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 48 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,10 +53,14 @@ const { entries, currentBranch } = useYourPaginatedDataSource()
/>
```

## Grid System
## Graph Rendering Strategies

The implementation of the graph was designed with testing in mind.
The traditional way to draw such an image would with a HTML `canvas` element. Which, while efficient (and probably easier to implement), is hard to programmatically assert its correctness.
The commit history graph visual can be rendered in different ways depending on your needs.

### HTML Grid

This implementation of the graph was designed with testing in mind.
The traditional way to draw such an image would with a HTML `canvas` element. Which, while efficient (and easier to implement), is hard to programmatically assert its correctness.

This graph uses a grid system. Each row has N number of columns rendered in it, where N is equal to the maximum number of concurrent active branches in the given git log entry data.
This means that each column is aware of its state and what needs to be drawn (A commit node, vertical line, curved merge line etc.).
Expand All @@ -65,6 +69,26 @@ Each column is responsive as its row is stretched vertically or horizontally.

![grid-system.gif](docs/images/grid-system.gif)

This strategy can be used by rendering the `<GitLog.GraphHTMLGrid />` subcomponent under the `<GitLog />`.

```typescript jsx
<GitLog entries={[]} branchName='main'>
<GitLog.GraphHTMLGrid />
</GitLog>
```

### Canvas 2D

This implementation uses a standard HTML `canvas` element with a `2d` rendering context.

This strategy can be used by rendering the `<GitLog.GraphCanvas2D />` subcomponent under the `<GitLog />`.

```typescript jsx
<GitLog entries={[]} branchName='main'>
<GitLog.GraphCanvas2D />
</GitLog>
```

# Using the component

1. Install the package using your preferred package manager.
Expand Down Expand Up @@ -107,7 +131,7 @@ Each column is responsive as its row is stretched vertically or horizontally.
return (
<GitLog entries={entries} currentBranch={currentBranch}>
<GitLog.Tags />
<GitLog.Graph />
<GitLog.GraphCanvas2D />
<GitLog.Table />
</GitLog>
)
Expand All @@ -127,7 +151,7 @@ Each column is responsive as its row is stretched vertically or horizontally.
<GitLog entries={entries} currentBranch={currentBranch}>
<GitLog.Tags />

<GitLog.Graph
<GitLog.GraphHTMLGrid
enableResize
nodeTheme='plain'
showCommitNodeTooltips
Expand Down Expand Up @@ -261,7 +285,7 @@ Returns an object of type `GitLogUrls` with the following fields.
| `commit` | `string` | A resolved URL to a particular commit hash on the external Git providers remote website. |
| `branch` | `string` | A resolved URL to a branch on the external Git providers remote website. |

### Graph
### GraphHTMLGrid

| Property | Type | Description |
|--------------------------|---------------------|----------------------------------------------------------------------------------------------------------------|
Expand All @@ -272,6 +296,15 @@ Returns an object of type `GitLogUrls` with the following fields.
| `orientation` | `normal \| flipped` | The orientation of the graph. Normal renders the checked-out branch on the left, flipped on the right. |
| `enableResize` | `boolean` | Enables horizontal resizing of the graph. Default: `false`. |

### GraphCanvas2D

| Property | Type | Description |
|--------------------------|---------------------|----------------------------------------------------------------------------------------------------------------|
| `nodeTheme` | `NodeTheme` | Theme applied to commit node elements in the graph. |
| `nodeSize` | `number` | The diameter, in pixels, of the commits nodes. Should be divisible by 2 and between 8 and 30 to render nicely. |
| `orientation` | `normal \| flipped` | The orientation of the graph. Normal renders the checked-out branch on the left, flipped on the right. |
| `enableResize` | `boolean` | Enables horizontal resizing of the graph. Default: `false`. |

#### NodeTheme

| Prop | Type | Description |
Expand Down Expand Up @@ -336,11 +369,16 @@ Returns an object of type `GitLogUrls` with the following fields.
- Straight line prop to turn curves into right angles?
- Line curve radius prop?
- Fix React docgen in Storybook controls as its not showing the JSDoc from the interface props
- Extract ThemeContext
- Mobile responsiveness for the demo site
- Add graph render strategy with a second option to use 2d rendering context (html canvas)
- Add eslint to pipeline
- Tags should be independent. Add a new optional field to the log entry / commit objects.
- Branch / Tags column is fixed. Dynamically floor it to match the max tag size currently being rendered?
- Is the SS paginated log gonna accept data from multiple branches? Because then we need the HEAD commits of each branch
- Make repository URL a function that generates the URL

Canvas2D
- Paginated variant needs to add in lines off-screen in the virtual columns
- Fade out of line at bottom
- Tooltips?
- Row spacing support
- First col background cut off by canvas
- Branch/tag lines to lining up with nodes.
- Selected node BG colour still isn't right...
Loading