Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
Liriae Viewer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
pub
ecolab
LIRIAe
Liriae Viewer
Commits
3abfd340
Commit
3abfd340
authored
3 months ago
by
Andréas Livet
Browse files
Options
Downloads
Patches
Plain Diff
Columns are now resizable
parent
ec211c95
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/Home.tsx
+42
-8
42 additions, 8 deletions
src/Home.tsx
with
42 additions
and
8 deletions
src/Home.tsx
+
42
−
8
View file @
3abfd340
import
{
useState
,
useEffect
,
use
Context
,
act
}
from
"
react
"
;
import
{
useState
,
useEffect
,
use
Ref
}
from
"
react
"
;
import
{
useSearchParams
}
from
"
react-router-dom
"
;
import
{
fr
}
from
"
@codegouvfr/react-dsfr
"
;
import
{
cx
}
from
"
@codegouvfr/react-dsfr/tools/cx
"
;
...
...
@@ -12,6 +12,9 @@ import { useAuthContext } from "@/components/AuthProvider";
import
{
TabComponent
}
from
"
@/components/TabComponent
"
;
import
{
SimpleChat
}
from
"
./components/SimpleChat
"
;
/**
* Component that contains two columns that can be resized dynamically
*/
export
function
Home
({
onFullScreen
,
isFullScreen
,
...
...
@@ -34,6 +37,9 @@ export function Home({
const
[
searchParams
,
setSearchParams
]
=
useSearchParams
();
const
activeTab
=
searchParams
.
get
(
"
tab
"
)
||
"
documents
"
;
const
containerRef
=
useRef
<
HTMLDivElement
>
(
null
);
const
[
leftWidth
,
setLeftWidth
]
=
useState
(
30
);
useEffect
(()
=>
{
if
(
currentDocument
)
{
setCurrentDocument
(
null
);
...
...
@@ -55,6 +61,26 @@ export function Home({
setSearchParams
(
searchParams
);
};
const
handleMouseDown
=
(
e
:
React
.
MouseEvent
)
=>
{
const
startX
=
e
.
clientX
;
const
handleMouseMove
=
(
e
:
MouseEvent
)
=>
{
if
(
!
containerRef
.
current
)
return
;
const
containerWidth
=
containerRef
.
current
.
offsetWidth
;
const
newLeftWidth
=
((
e
.
clientX
-
containerRef
.
current
.
offsetLeft
)
/
containerWidth
)
*
100
;
setLeftWidth
(
Math
.
min
(
Math
.
max
(
newLeftWidth
,
5
),
95
));
// min 5%, max 95%
};
const
stopDrag
=
()
=>
{
window
.
removeEventListener
(
"
mousemove
"
,
handleMouseMove
);
window
.
removeEventListener
(
"
mouseup
"
,
stopDrag
);
};
window
.
addEventListener
(
"
mousemove
"
,
handleMouseMove
);
window
.
addEventListener
(
"
mouseup
"
,
stopDrag
);
};
if
(
!
currentCollection
)
{
return
(
<
div
className
=
{
cx
(
fr
.
cx
(
"
fr-p-32v
"
))
}
>
...
...
@@ -77,12 +103,8 @@ export function Home({
inaccessible. Veuillez nous excusez pour la gêne occasionnée.
</
Highlight
>
)
}
<
div
className
=
{
isFullScreen
?
fr
.
cx
(
"
fr-grid-row
"
,
"
fr-ml-4v
"
)
:
fr
.
cx
(
"
fr-grid-row
"
)
}
>
<
div
className
=
{
fr
.
cx
(
"
fr-col-4
"
)
}
>
<
div
ref
=
{
containerRef
}
style
=
{
{
display
:
"
flex
"
,
width
:
"
100%
"
}
}
>
<
div
style
=
{
{
width
:
`
${
leftWidth
}
%`
}
}
>
<
TabComponent
onTabChange
=
{
handleTabChange
}
tabs
=
{
[
...
...
@@ -128,7 +150,19 @@ export function Home({
]
}
/>
</
div
>
<
div
className
=
{
fr
.
cx
(
"
fr-col-8
"
)
}
>
<
div
onMouseDown
=
{
handleMouseDown
}
style
=
{
{
width
:
"
5px
"
,
cursor
:
"
col-resize
"
,
background
:
fr
.
colors
.
decisions
.
background
.
default
.
grey
.
default
,
zIndex
:
1
,
transition
:
"
background 0.2s
"
,
}
}
onMouseEnter
=
{
(
e
)
=>
(
e
.
currentTarget
.
style
.
background
=
fr
.
colors
.
decisions
.
background
.
default
.
grey
.
active
)
}
onMouseLeave
=
{
(
e
)
=>
(
e
.
currentTarget
.
style
.
background
=
fr
.
colors
.
decisions
.
background
.
default
.
grey
.
default
)
}
/>
<
div
style
=
{
{
flex
:
1
}
}
>
<
div
className
=
"PDF-viewer"
>
{
currentDocument
?
(
<
PdfViewerComponent
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment