-
Notifications
You must be signed in to change notification settings - Fork 0
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 #173 from dotindustries/feat/gitgraph_options
feat: allow override for gitgraphjs options
- Loading branch information
Showing
11 changed files
with
212 additions
and
95 deletions.
There are no files selected for viewing
90 changes: 90 additions & 0 deletions
90
.swm/feat-allow-override-for-gitgraphjs-options.eh06czwq.sw.md
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 |
---|---|---|
@@ -0,0 +1,90 @@ | ||
--- | ||
title: 'feat: allow override for gitgraphjs options' | ||
--- | ||
📦 Published PR as canary version: ✨ Test out this PR locally via: | ||
|
||
```bash | ||
npm install @dotinc/[email protected] | ||
npm install @dotinc/[email protected] | ||
# or | ||
yarn add @dotinc/[email protected] | ||
yarn add @dotinc/[email protected] | ||
``` | ||
|
||
<SwmSnippet path="/packages/ogre-react/OgreGraph.tsx" line="12"> | ||
|
||
--- | ||
|
||
Include partial options from <SwmToken path="/packages/ogre-react/OgreGraph.tsx" pos="19:2:2" line-data="interface GitgraphOptions {">`GitgraphOptions`</SwmToken> and re-export template creation functions. | ||
|
||
This extension includes an option for the graph to override commit level options as well by providing a map of <SwmToken path="/packages/ogre-react/OgreGraph.tsx" pos="34:1:1" line-data=" commitOptions?: Map<string, CommitOptions>;">`commitOptions`</SwmToken> | ||
|
||
```tsx | ||
|
||
export { | ||
templateExtend, | ||
metroTemplate, | ||
blackArrowTemplate, | ||
} from "@gitgraph/core/lib/template"; | ||
|
||
interface GitgraphOptions { | ||
template?: TemplateName | Template; | ||
orientation?: Orientation; | ||
reverseArrow?: boolean; | ||
initCommitOffsetX?: number; | ||
initCommitOffsetY?: number; | ||
mode?: Mode; | ||
author?: string; | ||
branchLabelOnEveryCommit?: boolean; | ||
commitMessage?: string; | ||
} | ||
``` | ||
|
||
--- | ||
|
||
</SwmSnippet> | ||
|
||
<SwmSnippet path="/packages/ogre-react/OgreGraph.tsx" line="43"> | ||
|
||
--- | ||
|
||
This is where the <SwmToken path="/packages/ogre-react/OgreGraph.tsx" pos="34:1:1" line-data=" commitOptions?: Map<string, CommitOptions>;">`commitOptions`</SwmToken> are applied to the repository commits. | ||
|
||
```tsx | ||
|
||
useEffect(() => { | ||
if (!graphData) { | ||
const history = repository.getHistory(); | ||
const data = formatGit2Json(history).map((c) => { | ||
const opts = commitOptions?.get(c.hash); | ||
return { | ||
...c, | ||
...(opts ? opts : {}), | ||
}; | ||
}); | ||
setGraphData(data); | ||
} | ||
}, [repository]); | ||
``` | ||
|
||
--- | ||
|
||
</SwmSnippet> | ||
|
||
<SwmSnippet path="/packages/ogre-react/OgreGraph.tsx" line="57"> | ||
|
||
--- | ||
|
||
Passing down the global options to Gitgraph. | ||
|
||
```tsx | ||
|
||
return !graphData ? null : ( | ||
<Gitgraph options={options}> | ||
``` | ||
|
||
--- | ||
|
||
</SwmSnippet> | ||
|
||
<SwmMeta version="3.0.0" repo-id="Z2l0aHViJTNBJTNBb2dyZSUzQSUzQWRvdGluZHVzdHJpZXM="><sup>Powered by [Swimm](https://app.swimm.io/)</sup></SwmMeta> |
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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"repo_id": "Z2l0aHViJTNBJTNBb2dyZSUzQSUzQWRvdGluZHVzdHJpZXM=" | ||
} |
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 |
---|---|---|
|
@@ -79,7 +79,7 @@ const Home: NextPage = () => { | |
<LivePreview | ||
style={{ | ||
borderRadius: `${polished.rem(0)} ${polished.rem( | ||
5 | ||
5, | ||
)} ${polished.rem(5)} ${polished.rem(0)}`, | ||
position: "relative", | ||
padding: "0.5rem", | ||
|
@@ -120,11 +120,11 @@ const code = ` | |
const [repository, setRepository] = useState(undefined) | ||
useEffect(() => { | ||
if (!repository) { | ||
setupRepo() | ||
setupRepo().then(r => setRepository(r)) | ||
} | ||
return () => setRepository(undefined) | ||
}, []) | ||
const setupRepo = async () => { | ||
let author = 'author <[email protected]>' | ||
const r = new Repository({description: '', name: ''}, {}) | ||
|
@@ -147,8 +147,8 @@ const code = ` | |
r.checkout('main') | ||
r.merge('description') | ||
setRepository(r) | ||
return r | ||
} | ||
return repository ? <OgreGraph repository={repository} /> : null | ||
}`; |
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.