generated from json-schema-org/repo-template
-
-
Notifications
You must be signed in to change notification settings - Fork 42
[FEAT] : Added Adjustable Vertical Seperator between Editor and ContentViewer #173
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
Open
Yashwanth1906
wants to merge
6
commits into
json-schema-org:main
Choose a base branch
from
Yashwanth1906:Dynamic-Vertical-Split
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
240ca79
[FEAT] : Added Adjustable Vertical Seperated for ContentViewer and Ed…
Yashwanth1906 a6404b8
Merge branch 'json-schema-org:main' into Dynamic-Vertical-Split
Yashwanth1906 68ffd14
Update app/components/ResizableContent.tsx
Yashwanth1906 81b68f6
[fix] : Fixed the unintentional copying problem and adjusted the height
Yashwanth1906 44a131b
Merge branch 'Dynamic-Vertical-Split' of https://github.com/Yashwanth…
Yashwanth1906 8f4819c
[fix]: Pulled and pushing again
Yashwanth1906 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 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 |
---|---|---|
@@ -1,20 +1,18 @@ | ||
.content { | ||
display: flex; | ||
flex-direction: column; | ||
|
||
overflow-y: auto; | ||
flex: 1; | ||
padding-right: 14px; | ||
padding-bottom: 12px; | ||
padding-left: 14px; | ||
padding: 14px; | ||
height: 100%; | ||
width: 100%; | ||
} | ||
|
||
.contentWrapper { | ||
border-right: 1px solid hsl(var(--border-color)); | ||
|
||
display: flex; | ||
flex-direction: column; | ||
|
||
height: 100%; | ||
flex: 1; | ||
height: 100%; | ||
width: 100%; | ||
overflow: hidden; | ||
} |
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
82 changes: 82 additions & 0 deletions
82
app/components/ResizableContent/ResizableContent.module.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,82 @@ | ||
.mainArea { | ||
display: flex; | ||
flex-direction: row; | ||
height: 100vh; | ||
width: 100%; | ||
overflow: hidden; | ||
position: relative; | ||
} | ||
|
||
.leftPane { | ||
height: 100%; | ||
overflow: hidden; | ||
min-width: 300px; | ||
max-width: 70%; | ||
display: flex; | ||
} | ||
|
||
.rightPane { | ||
flex: 1; | ||
height: 100%; | ||
min-width: 300px; | ||
overflow: hidden; | ||
display: flex; | ||
} | ||
|
||
.divider { | ||
width: 4px; | ||
height: 100%; | ||
background-color: hsl(var(--border-color) / 0.5); | ||
cursor: col-resize; | ||
transition: all 0.2s ease; | ||
flex-shrink: 0; | ||
user-select: none; | ||
-webkit-user-select: none; | ||
position: relative; | ||
border-left: 1px solid hsl(var(--border-color)); | ||
border-right: 1px solid hsl(var(--border-color)); | ||
} | ||
|
||
.divider::after { | ||
content: ''; | ||
position: absolute; | ||
top: 0; | ||
left: 50%; | ||
transform: translateX(-50%); | ||
width: 2px; | ||
height: 100%; | ||
background-color: hsl(var(--primary) / 0.3); | ||
opacity: 0; | ||
transition: opacity 0.2s ease; | ||
} | ||
|
||
.divider:hover::after, | ||
.divider:active::after { | ||
opacity: 1; | ||
background-color: hsl(var(--primary) / 0.5); | ||
} | ||
|
||
.divider:hover, | ||
.divider:active { | ||
background-color: hsl(var(--primary) / 0.2); | ||
border-left: 1px solid hsl(var(--primary) / 0.4); | ||
border-right: 1px solid hsl(var(--primary) / 0.4); | ||
} | ||
|
||
.mainArea ::-webkit-scrollbar { | ||
width: 8px; | ||
height: 8px; | ||
} | ||
|
||
.mainArea ::-webkit-scrollbar-track { | ||
background: hsl(var(--background)); | ||
} | ||
|
||
.mainArea ::-webkit-scrollbar-thumb { | ||
background: hsl(var(--border-color)); | ||
border-radius: 4px; | ||
} | ||
|
||
.mainArea ::-webkit-scrollbar-thumb:hover { | ||
background: hsl(var(--primary) / 0.5); | ||
} |
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,88 @@ | ||
"use client"; | ||
|
||
import React, { useState, useRef, useEffect } from "react"; | ||
import styles from "./ResizableContent.module.css"; | ||
import ContentViewer from "../ContentViewer"; | ||
import EditorNOutput from "../EditorNOutput"; | ||
import { CodeFile } from "@/lib/types"; | ||
|
||
interface ResizableContentProps { | ||
content: React.ReactNode; | ||
codeFile: CodeFile; | ||
nextStepPath: string | undefined; | ||
stepIndex: number; | ||
chapterIndex: number; | ||
} | ||
|
||
export default function ResizableContent({ | ||
content, | ||
codeFile, | ||
nextStepPath, | ||
stepIndex, | ||
chapterIndex, | ||
}: ResizableContentProps) { | ||
const [leftWidth, setLeftWidth] = useState(600); | ||
const containerRef = useRef<HTMLDivElement>(null); | ||
const isDraggingRef = useRef<boolean>(false); | ||
|
||
const handleMouseDown = () => { | ||
isDraggingRef.current = true; | ||
}; | ||
|
||
const handleMouseUp = () => { | ||
isDraggingRef.current = false; | ||
}; | ||
|
||
const handleMouseMove = ( | ||
e: React.MouseEvent<HTMLDivElement, MouseEvent> | MouseEvent, | ||
) => { | ||
if (!isDraggingRef.current) return; | ||
|
||
const containerRect = containerRef.current!.getBoundingClientRect(); | ||
const newLeftWidth = e.clientX - containerRect.left; | ||
|
||
const minWidth = 300; | ||
const maxWidth = containerRect.width * 0.7; | ||
|
||
if (newLeftWidth >= minWidth && newLeftWidth <= maxWidth) { | ||
setLeftWidth(newLeftWidth); | ||
localStorage.setItem("horizontalLeftWidth", String(newLeftWidth)); | ||
} | ||
}; | ||
|
||
useEffect(() => { | ||
const savedWidth = localStorage.getItem("horizontalLeftWidth"); | ||
if (savedWidth) { | ||
setLeftWidth(Number(savedWidth)); | ||
} | ||
}, []); | ||
|
||
return ( | ||
<div | ||
className={styles.mainArea} | ||
ref={containerRef} | ||
onMouseMove={handleMouseMove} | ||
onMouseUp={handleMouseUp} | ||
onMouseLeave={handleMouseUp} | ||
> | ||
<div className={styles.leftPane} style={{ width: `${leftWidth}px` }}> | ||
<ContentViewer>{content}</ContentViewer> | ||
</div> | ||
<div | ||
className={styles.divider} | ||
onMouseDown={handleMouseDown} | ||
role="separator" | ||
aria-orientation="vertical" | ||
aria-label="Resize content" | ||
/> | ||
<div className={styles.rightPane}> | ||
<EditorNOutput | ||
codeFile={codeFile} | ||
nextStepPath={nextStepPath} | ||
stepIndex={stepIndex} | ||
chapterIndex={chapterIndex} | ||
/> | ||
</div> | ||
</div> | ||
); | ||
} |
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 |
---|---|---|
@@ -1,7 +1,41 @@ | ||
.mainArea { | ||
display: flex; | ||
flex-direction: row; | ||
flex: 12; | ||
height: calc(100vh - 60px); | ||
width: 100%; | ||
overflow: hidden; | ||
position: relative; | ||
} | ||
|
||
.leftPane { | ||
height: 100%; | ||
overflow-y: auto; | ||
overflow: hidden; | ||
min-width: 300px; | ||
max-width: 70%; | ||
display: flex; | ||
} | ||
|
||
.rightPane { | ||
flex: 1; | ||
height: 100%; | ||
min-width: 300px; | ||
overflow: hidden; | ||
display: flex; | ||
} | ||
|
||
.divider { | ||
width: 4px; | ||
height: 100%; | ||
background-color: hsl(var(--border-color)); | ||
cursor: col-resize; | ||
transition: background-color 0.2s ease; | ||
flex-shrink: 0; | ||
} | ||
|
||
.divider:hover { | ||
background-color: hsl(var(--primary) / 0.75); | ||
} | ||
|
||
.divider:active { | ||
background-color: hsl(var(--primary) / 0.75); | ||
} |
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
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.
are these changes relevant to the issue? Please remove these changes,