Skip to content

Commit

Permalink
feat: Distinguish the current node from other nodes (#173)
Browse files Browse the repository at this point in the history
Signed-off-by: LinHaiming <lhming23@outlook.com>
  • Loading branch information
heming6666 authored Jun 16, 2021
1 parent bc9b36f commit 43ffbb5
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 15 deletions.
11 changes: 9 additions & 2 deletions src/components/Graph/Graph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ interface GraphProps {
* callback function when click node
*/
readonly onNodeClick?: NodeClickFunc;
/**
* will assign a distinguishable color to the focused node if specified
*/
readonly focusedNodeID?: string;
}

const Graph: React.FC<GraphProps> = ({
Expand All @@ -34,10 +38,13 @@ const Graph: React.FC<GraphProps> = ({
const url = 'https://github.com/' + node.id;
window.location.href = url;
},
focusedNodeID,
}) => {
const NODE_SIZE = [10, 30];
const NODE_COLOR = GITHUB_THEME === 'light' ? ['#9EB9A8', '#40C463', '#30A14E', '#216E39'] : ['#0E4429', '#006D32', '#26A641', '#39D353'];
const THRESHOLD = [10, 100, 1000];
const FOCUSED_NODE_COLOR = GITHUB_THEME === 'light' ? ['#D73A49'] : ['#DA3633'];

const [inited, setInited] = useState(false);
const [settings, setSettings] = useState(new Settings());

Expand Down Expand Up @@ -72,7 +79,7 @@ const Graph: React.FC<GraphProps> = ({
value: n.value,
symbolSize: linearMap(n.value, minMax, NODE_SIZE),
itemStyle: {
color: getColorMap(n.value)
color: focusedNodeID && focusedNodeID === n.name ? FOCUSED_NODE_COLOR : getColorMap(n.value)
}
}
})
Expand All @@ -96,7 +103,7 @@ const Graph: React.FC<GraphProps> = ({
const generateNodes = (nodes: any[]): any => {
const minMax = getMinMax(nodes);
return nodes.map((n: any) => {
const color = getColorMap(n.value);
const color = focusedNodeID && focusedNodeID === n.name ? FOCUSED_NODE_COLOR : getColorMap(n.value);
return {
id: n.name,
value: n.value,
Expand Down
1 change: 1 addition & 0 deletions src/pages/Content/DeveloperNetwork.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ const DeveloperNetworkView: React.FC<DeveloperNetworkViewProps> = ({ currentDeve
graphType={graphType}
data={developerCollabrationData!}
style={graphStyle}
focusedNodeID={currentDeveloper}
/>
</div>
</div>
Expand Down
1 change: 1 addition & 0 deletions src/pages/Content/ProjectNetwork.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ const ProjectNetworkView: React.FC<ProjectNetworkViewProps> = ({ currentRepo, gr
graphType={graphType}
data={repoCorrelationData!}
style={graphStyle}
focusedNodeID={currentRepo}
/>
</div>
</div>
Expand Down
13 changes: 0 additions & 13 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,19 +137,6 @@ var options = {
copyUnmodified: true,
}
),
new CopyWebpackPlugin(
[
{
from: 'src/_locales',
to: path.join(__dirname, 'build','_locales'),
force: true,
},
],
{
logLevel: 'info',
copyUnmodified: true,
}
),
new HtmlWebpackPlugin({
template: path.join(__dirname, 'src', 'pages', 'Options', 'index.html'),
filename: 'options.html',
Expand Down

0 comments on commit 43ffbb5

Please sign in to comment.