11import { GitLogCoreProps } from './types'
22import { Children , isValidElement , PropsWithChildren , ReactElement , useCallback , useMemo , useState } from 'react'
33import { GitContext , GitContextBag } from 'context/GitContext'
4- import { neonAuroraDarkColours , neonAuroraLightColours , useTheme } from 'hooks/useTheme'
5- import { generateRainbowGradient } from 'hooks/useTheme/createRainbowTheme'
64import { computeNodePositions , computeRelationships , GraphData , temporalTopologicalSort } from 'data'
75import { Tags } from 'modules/Tags'
86import { Graph , GraphOrientation } from 'modules/Graph'
97import { Table } from 'modules/Table'
108import { Layout } from 'components/Layout'
119import { Commit } from 'types/Commit'
1210import { DEFAULT_NODE_SIZE , NODE_BORDER_WIDTH } from 'constants/constants'
11+ import { ThemeContextProvider } from 'context/ThemeContext'
1312
1413export const GitLogCore = ( {
1514 children,
@@ -89,33 +88,6 @@ export const GitLogCore = ({
8988 // TODO: Are we using graphWidth here or just ditching enableResize?
9089 const [ , setGraphWidth ] = useState ( defaultGraphWidth ?? smallestAvailableGraphWidth )
9190
92- const { shiftAlphaChannel } = useTheme ( )
93-
94- const themeColours = useMemo < string [ ] > ( ( ) => {
95- switch ( colours ) {
96- case 'rainbow-light' : {
97- return generateRainbowGradient ( graphData . graphWidth + 1 )
98- }
99- case 'rainbow-dark' : {
100- return generateRainbowGradient ( graphData . graphWidth + 1 )
101- . map ( colour => shiftAlphaChannel ( colour , 0.6 ) )
102- }
103- case 'neon-aurora-dark' : {
104- return neonAuroraDarkColours
105- }
106- case 'neon-aurora-light' : {
107- return neonAuroraLightColours
108- }
109- default : {
110- if ( theme === 'light' ) {
111- return colours
112- }
113-
114- return colours . map ( colour => shiftAlphaChannel ( colour , 0.6 ) )
115- }
116- }
117- } , [ colours , graphData . graphWidth , shiftAlphaChannel , theme ] )
118-
11991 const handleSelectCommit = useCallback ( ( commit ?: Commit ) => {
12092 setSelectedCommit ( commit )
12193 onSelectCommit ?.( commit )
@@ -183,11 +155,9 @@ export const GitLogCore = ({
183155 } , [ defaultGraphWidth , smallestAvailableGraphWidth ] )
184156
185157 const value = useMemo < GitContextBag > ( ( ) => ( {
186- colours : themeColours ,
187158 showTable : Boolean ( table ) ,
188159 showBranchesTags : Boolean ( tags ) ,
189160 classes,
190- theme,
191161 selectedCommit,
192162 setSelectedCommit : handleSelectCommit ,
193163 previewedCommit,
@@ -211,9 +181,7 @@ export const GitLogCore = ({
211181 setGraphOrientation,
212182 indexStatus
213183 } ) , [
214- themeColours ,
215184 classes ,
216- theme ,
217185 selectedCommit ,
218186 previewedCommit ,
219187 handleSelectCommit ,
@@ -239,7 +207,9 @@ export const GitLogCore = ({
239207
240208 return (
241209 < GitContext . Provider value = { value } >
242- < Layout tags = { tags } graph = { graph } table = { table } />
210+ < ThemeContextProvider theme = { theme } colours = { colours } graphWidth = { graphData . graphWidth } >
211+ < Layout tags = { tags } graph = { graph } table = { table } />
212+ </ ThemeContextProvider >
243213 </ GitContext . Provider >
244214 )
245215}
0 commit comments