-
Notifications
You must be signed in to change notification settings - Fork 162
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
tree: Add toggle to focus on selected #1373
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
0a1e821
Add filters to tree props
victorlin cb65841
Add optional experimental icon to toggle component
victorlin 8a65633
Add toggle to focus on selected
trvrb a7b4057
Add timing functions to setDisplayOrder
victorlin b7f8bc9
Update changelog
victorlin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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 |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import React from "react"; | ||
import { connect } from "react-redux"; | ||
import { FaInfoCircle } from "react-icons/fa"; | ||
import { Dispatch } from "@reduxjs/toolkit"; | ||
import Toggle from "./toggle"; | ||
import { SidebarIconContainer, StyledTooltip } from "./styles"; | ||
import { TOGGLE_FOCUS } from "../../actions/types"; | ||
import { RootState } from "../../store"; | ||
|
||
|
||
function ToggleFocus({ tooltip, focus, layout, dispatch, mobileDisplay }: { | ||
tooltip: React.ReactElement; | ||
focus: boolean; | ||
layout: "rect" | "radial" | "unrooted" | "clock" | "scatter"; | ||
dispatch: Dispatch; | ||
mobileDisplay: boolean; | ||
}) { | ||
// Focus functionality is only available to layouts that have the concept of a unitless y-axis | ||
const validLayouts = new Set(["rect", "radial"]); | ||
if (!validLayouts.has(layout)) return <></>; | ||
victorlin marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
const label = ( | ||
<div style={{ display: "flex", alignItems: "center" }}> | ||
<span style={{ marginRight: "5px" }}>Focus on Selected</span> | ||
{tooltip && !mobileDisplay && ( | ||
<> | ||
<SidebarIconContainer style={{ display: "inline-flex" }} data-tip data-for="toggle-focus"> | ||
<FaInfoCircle /> | ||
</SidebarIconContainer> | ||
<StyledTooltip place="bottom" type="dark" effect="solid" id="toggle-focus"> | ||
{tooltip} | ||
</StyledTooltip> | ||
</> | ||
)} | ||
</div> | ||
); | ||
|
||
return ( | ||
<Toggle | ||
display | ||
isExperimental={true} | ||
on={focus} | ||
callback={() => dispatch({ type: TOGGLE_FOCUS })} | ||
label={label} | ||
style={{ paddingBottom: "10px" }} | ||
/> | ||
); | ||
} | ||
|
||
export default connect((state: RootState) => ({ | ||
focus: state.controls.focus, | ||
layout: state.controls.layout, | ||
mobileDisplay: state.general.mobileDisplay, | ||
}))(ToggleFocus); |
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
victorlin marked this conversation as resolved.
Show resolved
Hide resolved
|
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
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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[commenting on this line to enable a thread, it's not related to the info content]
Animation + focus gets a little crazy. I don't think it's worth resolving this at the moment - it's labelled "experimental" after all - but wanted to note it here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good note. Focus can be toggled on/off while animation is in progress, so I think fine to leave it as-is.