Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
L
leximpact-legi-ui
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
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
leximpact
Exploration
leximpact-legi-ui
Commits
86167028
Commit
86167028
authored
2 months ago
by
David Smadja
Browse files
Options
Downloads
Patches
Plain Diff
Add summary for bill
parent
c81b6894
No related branches found
No related tags found
1 merge request
!1
Temp
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
src/lib/components/Bill.svelte
+6
-2
6 additions, 2 deletions
src/lib/components/Bill.svelte
src/lib/components/BillSummary.svelte
+68
-0
68 additions, 0 deletions
src/lib/components/BillSummary.svelte
src/routes/bill/[bill]/+page.svelte
+0
-1
0 additions, 1 deletion
src/routes/bill/[bill]/+page.svelte
with
74 additions
and
3 deletions
src/lib/components/Bill.svelte
+
6
−
2
View file @
86167028
<script
lang=
"ts"
>
import
BillSummary
from
"
./BillSummary.svelte
"
interface
Props
{
billHTML
:
string
|
undefined
}
let
container
:
HTMLDivElement
let
container
:
HTMLDivElement
|
undefined
=
$state
()
let
{
billHTML
}:
Props
=
$props
()
let
resizeObserver
:
ResizeObserver
...
...
@@ -117,4 +118,7 @@
})
</script>
<div
bind:this=
{
container
}
class=
"block h-full w-full"
></div>
<div
class=
"flex h-full w-full flex-col"
>
<BillSummary
{
billHTML
}
{
container
}
/>
<div
bind:this=
{
container
}
class=
"flex-1 overflow-auto"
></div>
</div>
This diff is collapsed.
Click to expand it.
src/lib/components/BillSummary.svelte
0 → 100644
+
68
−
0
View file @
86167028
<script
lang=
"ts"
>
interface
Props
{
billHTML
:
string
|
undefined
container
:
HTMLDivElement
|
undefined
}
let
{
billHTML
,
container
}:
Props
=
$props
()
let
summaryItems
=
$state
<
{
id
:
string
;
text
:
string
}[]
>
([])
let
summaryIsOpen
=
$state
(
false
)
function
extractAnchors
(
html
:
string
)
{
const
parser
=
new
DOMParser
()
const
doc
=
parser
.
parseFromString
(
html
,
"
text/html
"
)
const
links
=
Array
.
from
(
doc
.
querySelectorAll
(
'
a[href^="#_"]
'
))
return
links
.
map
((
link
)
=>
{
return
{
id
:
link
.
getAttribute
(
"
href
"
)?.
slice
(
1
)
||
""
,
text
:
link
.
textContent
?.
trim
()
||
""
,
}
})
.
filter
((
item
)
=>
item
.
id
&&
item
.
text
)
}
$effect
(()
=>
{
if
(
!
billHTML
)
return
summaryItems
=
extractAnchors
(
billHTML
)
})
</script>
<div
class=
"sticky top-0 z-10 bg-white p-4 shadow-md"
>
<button
class=
"w-full bg-gray-100 px-4 py-2 text-left font-medium hover:bg-gray-200"
onclick=
{
()
=>
(
summaryIsOpen
=
!
summaryIsOpen
)
}
>
Sommaire
<span
class=
"float-right transform transition-transform"
class:rotate-180=
{
summaryIsOpen
}
>
▼
</span>
</button>
<ul
class=
"overflow-y-auto transition-all duration-300 ease-in-out"
class:max-h-0=
{
!
summaryIsOpen
}
class:max-h-[60vh]=
{
summaryIsOpen
}
>
{
#each
summaryItems
as
item
}
<li>
<a
href=
{
`#${item.id}`
}
class=
"block py-1 text-blue-600 hover:underline"
onclick=
{
()
=>
{
if
(
container
!==
undefined
)
{
const
target
=
container
.
shadowRoot
?.
getElementById
(
item
.
id
)
target
?.
scrollIntoView
({
behavior
:
"
smooth
"
})
}
}}
>
{
item
.
text
}
</a>
</li>
{
/each
}
</ul>
</div>
This diff is collapsed.
Click to expand it.
src/routes/bill/[bill]/+page.svelte
+
0
−
1
View file @
86167028
...
...
@@ -11,7 +11,6 @@
</script>
<svelte:window
bind:innerWidth=
{
screenWidth
}
/>
<p>
{
screenWidth
}
</p>
<div
class=
"fixed flex min-h-full w-full flex-row overflow-hidden"
>
<div
class=
"h-screen w-1/2 overflow-y-auto"
><Bill
{
billHTML
}
>
</Bill></div>
<div
class=
"h-screen w-1/2 overflow-y-auto bg-amber-200"
>
...
...
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