-
-
Notifications
You must be signed in to change notification settings - Fork 20
feat: Add support for dialogs #680
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
MoritzWeber0
wants to merge
22
commits into
main
Choose a base branch
from
feat/add-dialogs
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
22 commits
Select commit
Hold shift + click to select a range
8639720
feat: Add support for dialogs
MoritzWeber0 4dfaab2
fix: show dialog triggers as inline text
MoritzWeber0 ef23d16
feat: Also open dialog on enter key
MoritzWeber0 146546c
fix: z-index
MoritzWeber0 c0046e3
refactor: improve naming of classes
MoritzWeber0 79e1d3c
fix: rounded scrollbar corners
MoritzWeber0 0014b52
refactor: rename button classes
MoritzWeber0 c9f9a0c
feat: use dvh instead vh
MoritzWeber0 ea75e56
fix: Remove stena line dialog
MoritzWeber0 6e968d3
feat: Improve accessibility on dialog-trigger
MoritzWeber0 7fcbbc1
fix: Improve accessibility on dialog close button
MoritzWeber0 930dc73
feat: Make dialog header sticky
MoritzWeber0 46069eb
feat: Make icon margin in links more generic
MoritzWeber0 aea2d39
fix: Descrease margin top/bottom for dialog header
MoritzWeber0 9234929
fix: Increase headings in dialog
MoritzWeber0 c04e69e
fix: Move dialog close button to the right
MoritzWeber0 52ece10
refactor: Merge button and button-internal partial
MoritzWeber0 6a19bf9
fix: Remove event listener on dialog close
MoritzWeber0 1cda054
fix: Add additional checks for overlay close on resize
MoritzWeber0 5ce60dd
Merge branch 'main' into feat/add-dialogs
therobrob b22fc71
feat: Use modal dialog
MoritzWeber0 80df44c
fix: Disable scrolling when dialog is open
MoritzWeber0 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
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,44 @@ | ||
| function getCloseButton(dialog) { | ||
| return dialog.querySelector(".o-dialog__header > .a-button"); | ||
| } | ||
|
|
||
| function openDialog(dialogId) { | ||
| const dialog = document.getElementById(dialogId); | ||
| if (!dialog) return; | ||
|
|
||
| dialog.showModal(); | ||
| } | ||
|
|
||
| function initDialogs() { | ||
| document.querySelectorAll("dialog").forEach((dialog) => { | ||
| dialog.addEventListener("click", (e) => { | ||
| if (e.target === dialog) { | ||
| dialog.close(); | ||
| } | ||
| }); | ||
|
|
||
| const closeButton = getCloseButton(dialog); | ||
| if (closeButton) { | ||
| closeButton.addEventListener("click", () => dialog.close()); | ||
| } | ||
| }); | ||
|
|
||
| document.querySelectorAll("[data-dialog-trigger]").forEach((trigger) => { | ||
| const handler = (e) => { | ||
| if (e.type === "click" || (e.type === "keydown" && e.key === "Enter")) { | ||
| e.preventDefault(); | ||
| const dialogId = trigger.getAttribute("data-dialog-trigger"); | ||
| openDialog(dialogId); | ||
| } | ||
| }; | ||
|
|
||
| trigger.addEventListener("click", handler); | ||
| trigger.addEventListener("keydown", handler); | ||
| }); | ||
| } | ||
|
|
||
| if (document.readyState === "loading") { | ||
| document.addEventListener("DOMContentLoaded", initDialogs); | ||
| } else { | ||
| initDialogs(); | ||
| } |
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
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
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
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,69 @@ | ||
| .o-dialog { | ||
| max-height: calc(100dvh - 14rem); | ||
| overflow: auto; | ||
| display: flex; | ||
| flex-direction: column; | ||
|
|
||
| .a-anchorlink { | ||
| margin-bottom: 0; | ||
|
|
||
| &__link { | ||
| display: none; | ||
| } | ||
|
|
||
| > h2 { | ||
| margin-bottom: 1rem; | ||
| } | ||
| } | ||
|
|
||
| .o-divider { | ||
| display: none; | ||
| } | ||
|
|
||
| &__wrapper { | ||
| width: fit-content; | ||
| border: none; | ||
| padding: 0; | ||
| background-color: var(--bg-default); | ||
| color: var(--color-body); | ||
| border-radius: var(--border-radius-m); | ||
| border: var(--border); | ||
| overflow: hidden; | ||
|
|
||
| &::backdrop { | ||
| background-color: rgba(0, 0, 0, 0.6); | ||
| backdrop-filter: blur(4px); | ||
| } | ||
| } | ||
|
|
||
| &__header { | ||
| position: sticky; | ||
| top: 0; | ||
| background-color: var(--bg-default); | ||
| display: flex; | ||
| column-gap: 1rem; | ||
| align-items: center; | ||
| justify-content: space-between; | ||
| padding: 1rem 1rem 1rem 2rem; | ||
| border-bottom: var(--border); | ||
| border-color: var(--color-table-border); | ||
|
|
||
| .o-divider { | ||
| display: none; | ||
| } | ||
|
|
||
| > h1 { | ||
| margin: 0; | ||
| font-size: 2.2rem; | ||
| } | ||
| } | ||
|
|
||
| &__body { | ||
| padding: 2rem; | ||
| overflow: auto; | ||
|
|
||
| > *:last-child { | ||
| margin-bottom: 0; | ||
| } | ||
| } | ||
| } | ||
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
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 |
|---|---|---|
|
|
@@ -23,3 +23,4 @@ | |
| @import "tag.scss"; | ||
| @import "floatImage.scss"; | ||
| @import "teamMember.scss"; | ||
| @import "dialog.scss"; | ||
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
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
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
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
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
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
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
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,8 +1,17 @@ | ||
| <a | ||
| href="{{ .Destination }}" | ||
| target="_blank" | ||
| rel="noopener noreferrer" | ||
| class="a-button o-link__external" | ||
| > | ||
| {{- .Text -}}{{- partial "icon" "arrow_outward" -}} | ||
| </a> | ||
| {{ if .Destination }} | ||
| <a | ||
| href="{{ .Destination }}" | ||
| target="_blank" | ||
| rel="noopener noreferrer" | ||
| class="a-button a-button__external o-link__external" | ||
| > | ||
| {{- .Text -}}{{- partial "icon" "arrow_outward" -}} | ||
| </a> | ||
| {{ else }} | ||
| <button | ||
| class="a-button a-button__internal" | ||
| {{- with .Title }}title="{{ . }}"{{- end -}} | ||
| > | ||
| {{- .Text -}} | ||
| </button> | ||
| {{ end }} |
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,15 @@ | ||
| <dialog | ||
MoritzWeber0 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| id="{{ .ID }}" | ||
| class="o-dialog__wrapper" | ||
| aria-labelledby="{{ .ID }}-title" | ||
| > | ||
| <div class="o-dialog o-container"> | ||
| <header class="o-dialog__header"> | ||
| <h1 id="{{ .ID }}-title" class="o-dialog__title">{{ .Title }}</h1> | ||
| {{- partial "button" (dict "Text" (partial "icon" "close") "Title" (i18n "dialog.close")) -}} | ||
| </header> | ||
| <div class="o-dialog__body"> | ||
| {{- partial "increase-headings" (dict "content" .Content) | safeHTML -}} | ||
| </div> | ||
| </div> | ||
| </dialog> | ||
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
This file was deleted.
Oops, something went wrong.
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,6 @@ | ||
| {{ partial "dialog" (dict | ||
| "ID" (.Get "id") | ||
| "Title" (.Get "title") | ||
| "Content" (.Inner | $.Page.RenderString) | ||
| ) | ||
| }} |
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.