-
Notifications
You must be signed in to change notification settings - Fork 2
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 #39 from Strexas/MDE/PKFE-22
MDE/PKFE-22
- Loading branch information
Showing
10 changed files
with
224 additions
and
21 deletions.
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 was deleted.
Oops, something went wrong.
31 changes: 31 additions & 0 deletions
31
app/front-end/src/features/editor/components/filebarView/filebarGroup.tsx
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,31 @@ | ||
import { List } from '@mui/material'; | ||
|
||
export interface FilebarGroupProps { | ||
children: React.ReactNode; | ||
} | ||
|
||
/** | ||
* `FilebarGroup` is a functional component that arranges its children in a horizontal list layout. | ||
* | ||
* @description This component is designed to group its child components in a horizontal row using Material-UI's `List` component. | ||
* It applies styles to ensure that the child elements are displayed in a flexible, row-wise layout that allows horizontal scrolling. | ||
* | ||
* @component | ||
* | ||
* @example | ||
* // Example usage of the FilebarGroup component | ||
* <FilebarGroup> | ||
* <FilebarItem /> | ||
* <FilebarItem /> | ||
* </FilebarGroup> | ||
* | ||
* @param {FilebarGroupProps} props - The props object for the FilebarGroup component. | ||
* @param {React.ReactNode} props.children - The child elements to be displayed inside the FilebarGroup. | ||
* | ||
* @returns {JSX.Element} The `List` component containing the grouped child elements. | ||
*/ | ||
export const FilebarGroup: React.FC<FilebarGroupProps> = ({ children }) => { | ||
return ( | ||
<List sx={{ display: 'flex', flexDirection: 'row', height: '100%', p: '0', overflowX: 'auto' }}>{children}</List> | ||
); | ||
}; |
86 changes: 86 additions & 0 deletions
86
app/front-end/src/features/editor/components/filebarView/filebarGroupItem.tsx
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,86 @@ | ||
import { useWorkspaceContext } from '@/features/editor/hooks'; | ||
import { FileTypes } from '@/types'; | ||
import { Close as CloseIcon } from '@mui/icons-material'; | ||
import { Box, IconButton, Typography, useTheme } from '@mui/material'; | ||
|
||
export interface FilebarGroupItemProps { | ||
fileId: string; | ||
fileLabel: string; | ||
fileType: FileTypes; | ||
} | ||
|
||
/** | ||
* `FilebarGroupItem` is a functional component that represents an individual item in the file bar group. | ||
* | ||
* @description This component displays the label of a file or folder within the file bar, allowing the user to select it and switch | ||
* to its corresponding workspace. It also includes a close button to remove the item from the workspace. | ||
* | ||
* @component | ||
* | ||
* @example | ||
* // Example usage of the FilebarGroupItem component | ||
* <FilebarGroupItem fileId="1" fileLabel="Document.txt" fileType={FileTypes.TXT} /> | ||
* | ||
* @param {FilebarGroupItemProps} props - The props object for the FilebarGroupItem component. | ||
* @param {string} props.fileId - The unique identifier of the file or folder. | ||
* @param {string} props.fileLabel - The label (name) of the file or folder to be displayed. | ||
* @param {FileTypes} props.fileType - The type of the file (e.g., txt, csv, folder). | ||
* | ||
* @returns {JSX.Element} A `Box` component representing an item in the file bar with a clickable label and a close button. | ||
*/ | ||
export const FilebarGroupItem: React.FC<FilebarGroupItemProps> = ({ fileId, fileLabel, fileType }) => { | ||
const Theme = useTheme(); | ||
const Workspace = useWorkspaceContext(); | ||
|
||
return ( | ||
<Box | ||
id={fileId} | ||
sx={{ | ||
height: '100%', | ||
pl: '1rem', | ||
pr: '0.5rem', | ||
bgcolor: Workspace.fileId === fileId ? Theme.palette.background.default : Theme.palette.action.selected, | ||
borderRadius: '0rem 0rem 0.625rem 0.625rem', | ||
':hover': { | ||
backgroundColor: Theme.palette.background.paper, | ||
}, | ||
cursor: 'pointer', | ||
display: 'flex', | ||
flexDirection: 'row', | ||
alignItems: 'center', | ||
gap: '0.5rem', | ||
}} | ||
onClick={() => { | ||
// Update the workspace to the selected file | ||
Workspace.update(fileId, fileLabel, fileType); | ||
}} | ||
> | ||
<Typography | ||
sx={{ | ||
fontSize: 12, | ||
fontWeight: 'bold', | ||
textTransform: 'none', | ||
maxWidth: '10rem', | ||
overflow: 'hidden', | ||
textOverflow: 'ellipsis', | ||
whiteSpace: 'nowrap', | ||
}} | ||
> | ||
{fileLabel} | ||
</Typography> | ||
<IconButton | ||
size='small' | ||
onClick={(event) => { | ||
event.stopPropagation(); | ||
}} | ||
onMouseDown={(event) => { | ||
event.stopPropagation(); | ||
// Remove the file from the workspace | ||
Workspace.remove(fileId); | ||
}} | ||
> | ||
<CloseIcon sx={{ fontSize: 12, color: Theme.palette.text.primary }} /> | ||
</IconButton> | ||
</Box> | ||
); | ||
}; |
29 changes: 29 additions & 0 deletions
29
app/front-end/src/features/editor/components/filebarView/filebarView.tsx
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,29 @@ | ||
import { FilebarGroup, FilebarGroupItem } from '@/features/editor/components/filebarView'; | ||
import { useWorkspaceContext } from '@/features/editor/hooks'; | ||
|
||
/** | ||
* `FilebarView` is a functional component that renders a group of file items currently open in the workspace. | ||
* | ||
* @description This component utilizes the `FilebarGroup` and `FilebarGroupItem` components to display the files | ||
* that have been recently opened in the workspace. It maps over the `fileHistory` from the workspace context to generate | ||
* individual `FilebarGroupItem` components for each file. | ||
* | ||
* @component | ||
* | ||
* @example | ||
* // Example usage of the FilebarView component | ||
* <FilebarView /> | ||
* | ||
* @returns {JSX.Element} A `FilebarGroup` component containing a list of `FilebarGroupItem` components. | ||
*/ | ||
export const FilebarView: React.FC = () => { | ||
const Workspace = useWorkspaceContext(); | ||
|
||
return ( | ||
<FilebarGroup> | ||
{Workspace.fileHistory.map((item, index) => ( | ||
<FilebarGroupItem key={index} {...item} /> | ||
))} | ||
</FilebarGroup> | ||
); | ||
}; |
5 changes: 5 additions & 0 deletions
5
app/front-end/src/features/editor/components/filebarView/index.ts
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,5 @@ | ||
export { FilebarGroup } from './filebarGroup'; | ||
export type { FilebarGroupProps } from './filebarGroup'; | ||
export { FilebarGroupItem } from './filebarGroupItem'; | ||
export type { FilebarGroupItemProps } from './filebarGroupItem'; | ||
export { FilebarView } from './filebarView'; |
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,5 +1,5 @@ | ||
export { Console } from './console'; | ||
export { EditorView } from './editorView'; | ||
export { Filebar } from './filebar'; | ||
export { FilebarView } from './filebarView'; | ||
export { FileTreeView } from './fileTreeView/fileTreeView'; | ||
export { ToolbarView } from './toolbarView'; |
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