Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Distinguish the current node from other nodes #173

Merged
merged 1 commit into from
Jun 16, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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