-
-
Notifications
You must be signed in to change notification settings - Fork 201
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 #28 from caitlinchan23/hover-render
Added Hover Feature to Component Details
- Loading branch information
Showing
7 changed files
with
56 additions
and
31 deletions.
There are no files selected for viewing
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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,38 +1,63 @@ | ||
|
||
import React from 'react'; | ||
|
||
import { onHover, onHoverExit } from '../actions/actions'; | ||
import { useStoreContext } from '../store' | ||
|
||
const RenderingFrequency = (props) => { | ||
const perfData = props.data | ||
|
||
const perfData = props.data | ||
return ( | ||
<div> | ||
{ | ||
Object.keys(perfData).map( componentName => { | ||
const currentComponent = perfData[componentName] | ||
return ( | ||
<div className="StyledGridElement"> | ||
<div className="RenderLeft"> | ||
<h3>{componentName} </h3> | ||
<h4>{currentComponent.stateType}</h4> | ||
<h4> | ||
average time:{' '} | ||
{( | ||
currentComponent.totalRenderTime / | ||
currentComponent.renderFrequency | ||
).toFixed(3)}{' '} | ||
ms | ||
</h4> | ||
</div> | ||
<div className="RenderRight"> | ||
<p>{currentComponent.renderFrequency}</p> | ||
</div> | ||
</div> | ||
); | ||
}) | ||
} | ||
</div> | ||
) | ||
<div> | ||
{Object.keys(perfData).map(componentName => { | ||
const currentComponent = perfData[componentName]; | ||
return ( | ||
<ComponentCard | ||
componentName={componentName} | ||
stateType={currentComponent.stateType} | ||
averageRenderTime={( | ||
currentComponent.totalRenderTime / | ||
currentComponent.renderFrequency | ||
).toFixed(3)} | ||
renderFrequency={currentComponent.renderFrequency} | ||
rtid={currentComponent.rtid} | ||
/> | ||
)} | ||
) | ||
} | ||
</div> | ||
) | ||
} | ||
|
||
const ComponentCard = props => { | ||
const { componentName, stateType, averageRenderTime, renderFrequency, rtid} = props; | ||
const [{ tabs, currentTab }, dispatch] = useStoreContext(); | ||
|
||
const onMouseMove = () => { | ||
dispatch(onHover(rtid)) | ||
} | ||
const onMouseLeave = () => { | ||
dispatch(onHoverExit(rtid)) | ||
} | ||
|
||
return ( | ||
<div | ||
onMouseLeave={onMouseLeave} | ||
onMouseMove={onMouseMove} | ||
className="StyledGridElement"> | ||
<div className="RenderLeft"> | ||
<h3>{componentName} </h3> | ||
<h4>{stateType}</h4> | ||
<h4> | ||
average time:{' '} | ||
{averageRenderTime}{' '} | ||
ms | ||
</h4> | ||
</div> | ||
<div className="RenderRight"> | ||
<p>{renderFrequency}</p> | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
||
|
||
export default RenderingFrequency; |
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