-
Notifications
You must be signed in to change notification settings - Fork 16
new-log-viewer: Add tabbed Sidebar with resizable panel; Rearrange open and settings buttons. #74
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
Merged
Merged
Changes from all commits
Commits
Show all changes
89 commits
Select commit
Hold shift + click to select a range
96de362
Remove redundant div wrapper in Layout component to simplify the DOM …
junhaoliao c6ab307
Add SidebarContainer with resizable tabs.
junhaoliao a0a618a
Add newline to EOF.
junhaoliao 3c35843
Add newline to EOF.
junhaoliao b0948b6
Add borders to StatusBar and MenuBar
junhaoliao 2666f95
Set resize handle z-index with global CSS variable.
junhaoliao 3605209
Introduce 8px padding to .menu-bar for better spacing. Add .menu-bar-…
junhaoliao db82737
Add newline to EOF.
junhaoliao b9ebe1d
Extract <CustomTabPanel/>.
junhaoliao 3ac708c
Remove redundant line.
junhaoliao 1474245
Rename 'File Info' field to 'Name' in FileInfoTab.
junhaoliao ef55b61
Replace FileOpenIcon with FolderOpenIcon in PanelTabs.
junhaoliao 0418f1f
Move open file functionality to MenuBar.
junhaoliao f87fc9f
Set default messages for no file open.
junhaoliao 1707ccf
Refactor tab panel close behaviour.
junhaoliao 1ed3de9
Add TAB_DISPLAY_NAMES and use it for tab titles.
junhaoliao 25af90b
Refactor panel resize behaviour.
junhaoliao 6efc0e4
Merge remote-tracking branch 'yscope/main' into sidebar
junhaoliao 85d112d
Increase the min-width before the sidebar snaps closed.
junhaoliao c032ce4
Decrease the padding in the sidebar by 25%.
junhaoliao 7b00600
Make the buttons square rather than rectangles.
junhaoliao 5f43d9a
Add YScope logo component and ABeeZee font.
junhaoliao 9bbfc0b
Add YScopeLogo and replace IconButton with Button.
junhaoliao 54bb3c8
Update sidebar tab button dimensions.
junhaoliao ea6b38e
Adjust default Sidebar panel width to 360px.
junhaoliao 98b55f5
Reformat CSS file.
junhaoliao 128ab5f
Remove redundant line in StateContextProvider.tsx
junhaoliao 8a3e9b6
Disable custom-property-pattern check for joyui custom properties in …
junhaoliao f535eeb
Rename 'File Info' tab display name to 'File info'.
junhaoliao bd3c94c
Remove YScopeLogo component and update icon styles.
junhaoliao fd1431f
Move active tab button indicator placement to the left.
junhaoliao 8e1e54e
Change default fileName back to an empty string.
junhaoliao d5c9fa4
Show no-file-open message in FileInfoTab.
junhaoliao f4baacd
Refactor tab buttons to use TooltipTab component which moves indicato…
junhaoliao 4e046fe
Add arrow to "Open file" tooltip.
junhaoliao 74328ca
Support clicking on an active tab button to close the tab.
junhaoliao 0b1b33f
Remove unnecessary type assertion on tabName value.
junhaoliao 832763d
Add set status bar z-index so that the border of it can be shown over…
junhaoliao 203f4f2
Change fileName empty string check.
junhaoliao 748a159
Add padding between sidebar tab panel title and content.
junhaoliao 6784f3b
Add Divider component to TooltipTab.
junhaoliao f5d6a6f
Add outlined variant to TooltipTab component.
junhaoliao e0f1c93
Revert "Add Divider component to TooltipTab."
junhaoliao 27cc339
Refactor CSS imports.
junhaoliao 69d0aa3
Prevent text selection in panel titles.
junhaoliao c19ae6b
Clear original file size before loading.
junhaoliao dbe858c
Add word-break style to FileInfoTab content.
junhaoliao 38a31b7
Merge branch 'main' into sidebar
junhaoliao 3aa0e0a
Move CustomListItem.tsx to PanelTabs directory.
junhaoliao ed64bcf
Remove unused ABeeZee font link from index.html.
junhaoliao 8c1d6dc
Fix typo in docs - apply sugguestions.
junhaoliao f1e1d58
Moved custom tab panel title styles from inline CSS to the stylesheet.
junhaoliao db8a443
Remove useEffect for updating panel width state and externalized widt…
junhaoliao 80b203a
Remove unnecessary fragment in ResizeHandle component.
junhaoliao 6e27725
Update variable names and docs for the resize handle behaviours.
junhaoliao 68adc0c
Update the `deactivateTabAndHideResizeHandle` function to use the `us…
junhaoliao e9ff7a9
Update dependencies for useCallback hooks in SidebarContainer.
junhaoliao 9dfdef3
Suppress 'max-statements' ESLint rule for StateContextProvider.
junhaoliao f53a2e2
Rename SidebarContainer to CentralContainer.
junhaoliao d1c40de
Refactor CentralContainer and extract Sidebar component.
junhaoliao 81bc4ae
Reorganize Sidebar component files.
junhaoliao 591a55b
Rename FileInfoTab to FileInfoTabPanel.
junhaoliao 1fbe903
Rename PanelTabs to SidebarTabs.
junhaoliao c3165a1
Add docs for Sidebar.
junhaoliao 561d7ed
Refactor SidebarTabs to use a constant for tab info.
junhaoliao 20efbb5
Add docs to explain why "sidebar-tab-list-spacing" is needed.
junhaoliao 2204868
Split the useEffect hook in ResizeHandle into two.
junhaoliao 7abfdf9
Avoid unnecessary dynamic change of the --ylv-panel-resize-handle-wid…
junhaoliao 030036e
Change the resize handle width when not hovered.
junhaoliao 03e3de1
Add visual feedback on Sidebar resize handle mouse down.
junhaoliao 6f4613e
Increase panel resize handle width.
junhaoliao 7146619
Rename `TooltipTab` to `TabButton`.
junhaoliao 9e078b4
Merge branch 'main' into sidebar
junhaoliao f7c38d7
Introduce a constant for file unloaded check in FileInfoTabPanel.
junhaoliao caf32a3
Move DropFileContainer and Editor into CentralContainer directly.
junhaoliao b3d3e03
Simplify CentralContainer component documentation - apply code review…
junhaoliao 7e1000d
Cache formattedOriginalSize with `useMemo`.
junhaoliao d36a73b
Reorder params in docs - Apply suggestions from code review
junhaoliao cae668b
Remove redundant container "central-container-children" and CSS for C…
junhaoliao 374ac14
Merge remote-tracking branch 'junhao/sidebar' into sidebar
junhaoliao 1fa0953
Merge branch 'main' into sidebar
junhaoliao 530b352
Increase eslint rule "max-lines" limit to 500.
junhaoliao 02a9eb0
Avoid leaving mouseup event listener active even when the resize hand…
junhaoliao 703cea2
Merge branch 'main' into HEAD
davemarco 6ad338e
Apply suggestions from code review
davemarco 22f97aa
rename onDiskFileSize
davemarco 0b66e00
fix pixels
davemarco efe3a3d
fix lint
davemarco 9d9901e
fix original in more places
davemarco 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions
23
new-log-viewer/src/components/CentralContainer/Sidebar/ResizeHandle.css
This file contains hidden or 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,23 @@ | ||
.resize-handle { | ||
cursor: ew-resize; | ||
|
||
z-index: var(--ylv-resize-handle-z-index); | ||
|
||
box-sizing: border-box; | ||
width: var(--ylv-panel-resize-handle-width); | ||
height: 100%; | ||
|
||
/* stylelint-disable-next-line custom-property-pattern */ | ||
background-color: var(--joy-palette-background-surface, #fbfcfe); | ||
/* stylelint-disable-next-line custom-property-pattern */ | ||
border-right: 1px solid var(--joy-palette-neutral-outlinedBorder, #cdd7e1); | ||
} | ||
|
||
.resize-handle-holding, | ||
.resize-handle:hover { | ||
box-sizing: initial; | ||
|
||
/* stylelint-disable-next-line custom-property-pattern */ | ||
background-color: var(--joy-palette-primary-solidHoverBg, #0258a8); | ||
border-right: initial; | ||
} |
81 changes: 81 additions & 0 deletions
81
new-log-viewer/src/components/CentralContainer/Sidebar/ResizeHandle.tsx
This file contains hidden or 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,81 @@ | ||
import React, { | ||
useCallback, | ||
useEffect, | ||
useState, | ||
} from "react"; | ||
|
||
import "./ResizeHandle.css"; | ||
|
||
|
||
interface ResizeHandleProps { | ||
onHandleRelease: () => void, | ||
|
||
/** | ||
* Gets triggered when a resize event occurs. | ||
* | ||
* @param resizeHandlePosition The horizontal distance, in pixels, between the mouse pointer | ||
* and the left edge of the viewport. | ||
*/ | ||
onResize: (resizeHandlePosition: number) => void, | ||
} | ||
|
||
/** | ||
* A vertical handle for resizing an object. | ||
* | ||
* @param props | ||
* @param props.onResize The method to call when a resize occurs. | ||
* @param props.onHandleRelease | ||
* @return | ||
*/ | ||
const ResizeHandle = ({ | ||
onResize, | ||
onHandleRelease, | ||
}: ResizeHandleProps) => { | ||
const [isMouseDown, setIsMouseDown] = useState<boolean>(false); | ||
|
||
const handleMouseDown = (ev: React.MouseEvent) => { | ||
ev.preventDefault(); | ||
setIsMouseDown(true); | ||
}; | ||
|
||
const handleMouseMove = useCallback((ev: MouseEvent) => { | ||
ev.preventDefault(); | ||
onResize(ev.clientX); | ||
}, [onResize]); | ||
|
||
const handleMouseUp = useCallback((ev: MouseEvent) => { | ||
ev.preventDefault(); | ||
setIsMouseDown(false); | ||
onHandleRelease(); | ||
}, [onHandleRelease]); | ||
|
||
// On `isMouseDown` change, add / remove event listeners. | ||
useEffect(() => { | ||
if (isMouseDown) { | ||
window.addEventListener("mousemove", handleMouseMove); | ||
window.addEventListener("mouseup", handleMouseUp); | ||
} | ||
|
||
return () => { | ||
// Always clean up the event listeners before the hook is re-run due to `isMouseDown` | ||
// changes / when the component is unmounted. | ||
window.removeEventListener("mousemove", handleMouseMove); | ||
window.removeEventListener("mouseup", handleMouseUp); | ||
}; | ||
}, [ | ||
handleMouseMove, | ||
handleMouseUp, | ||
isMouseDown, | ||
]); | ||
|
||
return ( | ||
<div | ||
className={`resize-handle ${isMouseDown ? | ||
"resize-handle-holding" : | ||
""}`} | ||
onMouseDown={handleMouseDown}/> | ||
); | ||
}; | ||
|
||
|
||
export default ResizeHandle; |
50 changes: 50 additions & 0 deletions
50
new-log-viewer/src/components/CentralContainer/Sidebar/SidebarTabs/CustomListItem.tsx
This file contains hidden or 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,50 @@ | ||
import React from "react"; | ||
|
||
import { | ||
ListItem, | ||
ListItemContent, | ||
ListItemDecorator, | ||
Typography, | ||
TypographyProps, | ||
} from "@mui/joy"; | ||
|
||
|
||
interface CustomListItemProps { | ||
content: string, | ||
icon: React.ReactNode, | ||
slotProps?: { | ||
content?: TypographyProps | ||
}, | ||
title: string | ||
} | ||
|
||
/** | ||
* Renders a custom list item with an icon, a title and a context text. | ||
* | ||
* @param props | ||
* @param props.content | ||
* @param props.icon | ||
* @param props.slotProps | ||
* @param props.title | ||
* @return | ||
*/ | ||
const CustomListItem = ({content, icon, slotProps, title}: CustomListItemProps) => ( | ||
<ListItem> | ||
<ListItemDecorator> | ||
{icon} | ||
</ListItemDecorator> | ||
<ListItemContent> | ||
<Typography level={"title-sm"}> | ||
{title} | ||
</Typography> | ||
<Typography | ||
{...slotProps?.content} | ||
level={"body-sm"} | ||
> | ||
{content} | ||
</Typography> | ||
</ListItemContent> | ||
</ListItem> | ||
); | ||
|
||
export default CustomListItem; |
14 changes: 14 additions & 0 deletions
14
new-log-viewer/src/components/CentralContainer/Sidebar/SidebarTabs/CustomTabPanel.css
This file contains hidden or 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,14 @@ | ||
.sidebar-tab-panel { | ||
padding: 0.75rem; | ||
} | ||
|
||
.sidebar-tab-panel-title-container { | ||
user-select: none; | ||
margin-bottom: 0.5rem !important; | ||
} | ||
|
||
.sidebar-tab-panel-title { | ||
font-size: 0.875rem !important; | ||
font-weight: 400 !important; | ||
text-transform: uppercase; | ||
} |
50 changes: 50 additions & 0 deletions
50
new-log-viewer/src/components/CentralContainer/Sidebar/SidebarTabs/CustomTabPanel.tsx
This file contains hidden or 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,50 @@ | ||
import React from "react"; | ||
|
||
import { | ||
DialogContent, | ||
DialogTitle, | ||
TabPanel, | ||
Typography, | ||
} from "@mui/joy"; | ||
|
||
import "./CustomTabPanel.css"; | ||
|
||
|
||
interface CustomTabPanelProps { | ||
children: React.ReactNode, | ||
tabName: string, | ||
title: string, | ||
} | ||
|
||
/** | ||
* Renders a customized tab panel to be extended for displaying extra information in the sidebar. | ||
* | ||
* @param props | ||
* @param props.children | ||
* @param props.tabName | ||
* @param props.title | ||
* @return | ||
*/ | ||
const CustomTabPanel = ({children, tabName, title}: CustomTabPanelProps) => { | ||
return ( | ||
<TabPanel | ||
className={"sidebar-tab-panel"} | ||
value={tabName} | ||
> | ||
<DialogTitle className={"sidebar-tab-panel-title-container"}> | ||
<Typography | ||
className={"sidebar-tab-panel-title"} | ||
level={"body-md"} | ||
> | ||
{title} | ||
</Typography> | ||
</DialogTitle> | ||
<DialogContent> | ||
{children} | ||
</DialogContent> | ||
</TabPanel> | ||
); | ||
}; | ||
|
||
|
||
export default CustomTabPanel; |
61 changes: 61 additions & 0 deletions
61
new-log-viewer/src/components/CentralContainer/Sidebar/SidebarTabs/FileInfoTabPanel.tsx
This file contains hidden or 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,61 @@ | ||
import { | ||
useContext, | ||
useMemo, | ||
} from "react"; | ||
|
||
import { | ||
Divider, | ||
List, | ||
} from "@mui/joy"; | ||
|
||
import AbcIcon from "@mui/icons-material/Abc"; | ||
import StorageIcon from "@mui/icons-material/Storage"; | ||
|
||
import {StateContext} from "../../../../contexts/StateContextProvider"; | ||
import { | ||
TAB_DISPLAY_NAMES, | ||
TAB_NAME, | ||
} from "../../../../typings/tab"; | ||
import {formatSizeInBytes} from "../../../../utils/units"; | ||
import CustomListItem from "./CustomListItem"; | ||
import CustomTabPanel from "./CustomTabPanel"; | ||
|
||
|
||
/** | ||
* Displays a panel containing the file name and on-disk size of the selected file. | ||
* | ||
* @return | ||
*/ | ||
const FileInfoTabPanel = () => { | ||
const {fileName, onDiskFileSizeInBytes} = useContext(StateContext); | ||
|
||
const isFileUnloaded = 0 === fileName.length; | ||
const formattedOnDiskSize = useMemo( | ||
() => formatSizeInBytes(onDiskFileSizeInBytes, false), | ||
[onDiskFileSizeInBytes] | ||
); | ||
|
||
return ( | ||
<CustomTabPanel | ||
tabName={TAB_NAME.FILE_INFO} | ||
title={TAB_DISPLAY_NAMES[TAB_NAME.FILE_INFO]} | ||
> | ||
{isFileUnloaded ? | ||
"No file is open." : | ||
<List> | ||
<CustomListItem | ||
content={fileName} | ||
icon={<AbcIcon/>} | ||
slotProps={{content: {sx: {wordBreak: "break-word"}}}} | ||
title={"Name"}/> | ||
<Divider/> | ||
<CustomListItem | ||
content={formattedOnDiskSize} | ||
icon={<StorageIcon/>} | ||
title={"On-disk Size"}/> | ||
</List>} | ||
</CustomTabPanel> | ||
); | ||
}; | ||
|
||
export default FileInfoTabPanel; |
10 changes: 10 additions & 0 deletions
10
new-log-viewer/src/components/CentralContainer/Sidebar/SidebarTabs/TabButton.css
This file contains hidden or 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,10 @@ | ||
.sidebar-tab-button { | ||
justify-content: center !important; | ||
width: 48px; | ||
height: 48px; | ||
padding: 0 !important; | ||
} | ||
|
||
.sidebar-tab-button-icon { | ||
font-size: 32px !important; | ||
} |
57 changes: 57 additions & 0 deletions
57
new-log-viewer/src/components/CentralContainer/Sidebar/SidebarTabs/TabButton.tsx
This file contains hidden or 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,57 @@ | ||
import { | ||
Tab, | ||
Tooltip, | ||
} from "@mui/joy"; | ||
|
||
import {SvgIconComponent} from "@mui/icons-material"; | ||
|
||
import { | ||
TAB_DISPLAY_NAMES, | ||
TAB_NAME, | ||
} from "../../../../typings/tab"; | ||
|
||
import "./TabButton.css"; | ||
|
||
|
||
interface TabButtonProps { | ||
tabName: TAB_NAME, | ||
Icon: SvgIconComponent, | ||
onTabButtonClick: (tabName: TAB_NAME) => void | ||
} | ||
|
||
/** | ||
* Renders a tooltip-wrapped tab button. | ||
* | ||
* @param props | ||
* @param props.tabName | ||
* @param props.Icon | ||
* @param props.onTabButtonClick | ||
* @return | ||
*/ | ||
const TabButton = ({tabName, Icon, onTabButtonClick}: TabButtonProps) => { | ||
const handleClick = () => { | ||
onTabButtonClick(tabName); | ||
}; | ||
davemarco marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
return ( | ||
<Tooltip | ||
arrow={true} | ||
key={tabName} | ||
placement={"right"} | ||
title={TAB_DISPLAY_NAMES[tabName]} | ||
variant={"outlined"} | ||
> | ||
<Tab | ||
className={"sidebar-tab-button"} | ||
color={"neutral"} | ||
indicatorPlacement={"left"} | ||
slotProps={{root: {onClick: handleClick}}} | ||
value={tabName} | ||
> | ||
<Icon className={"sidebar-tab-button-icon"}/> | ||
</Tab> | ||
</Tooltip> | ||
); | ||
}; | ||
|
||
export default TabButton; |
9 changes: 9 additions & 0 deletions
9
new-log-viewer/src/components/CentralContainer/Sidebar/SidebarTabs/index.css
This file contains hidden or 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,9 @@ | ||
.sidebar-tabs { | ||
flex-grow: 1; | ||
width: calc(100% - var(--ylv-panel-resize-handle-width)); | ||
height: 100%; | ||
} | ||
|
||
.sidebar-tab-list-spacing { | ||
flex-grow: 1; | ||
} |
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.