Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 17 additions & 12 deletions website/apps/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,19 @@ downloading the actual webxdc file from the server.
*/
const Dialog = ({app, modal, toggleModal}) => {
const [subtitle, description] = [app.description.split('\n').shift(), app.description.split('\n').slice(1).join(' ')];
const ref = /** @type {import("react").RefObject<HTMLDialogElement>} */(useRef())

// Change the title when a dialog is open
if(modal === app.app_id) {
document.title = `webxdc apps: ${app.name}`;
}
useEffect(() => {
// Only show the modal that matches the app ID that was clicked.
if(modal === app.app_id) {
ref.current.showModal();
// Change the title when a dialog is open
document.title = `webxdc apps: ${app.name}`;
return () => {
ref.current.close();
}
}
}, [modal, app.app_id])

// Display the size of the webxdc apps in a more human readable format
let size = `${(app.size/1000).toLocaleString(undefined, {maximumFractionDigits: 1})} kb`;
Expand All @@ -60,8 +68,7 @@ const Dialog = ({app, modal, toggleModal}) => {
}

return html`
<!-- Only show the modal that matches the app ID that was clicked -->
<div id=${app.app_id} role="dialog" aria-labelledby="${app.app_id}_label" aria-describedby="${app.app_id}_desc" aria-modal="true" class="${modal === app.app_id ? 'active' : 'hidden'}">
<dialog ref=${ref} id=${app.app_id} onClose=${() => toggleModal(false)} aria-labelledby="${app.app_id}_label" aria-describedby="${app.app_id}_desc">
<div class="app-container">
<img src="${xdcget_export + "/" + app.icon_relname}" loading="lazy" alt="Icon of ${app.name} app" />
<div class="metadata">
Expand Down Expand Up @@ -92,7 +99,7 @@ const Dialog = ({app, modal, toggleModal}) => {
</a>
<button class="ghost" onClick=${() => toggleModal(false)}>Close</button>
</div>
</div>
</dialog>
`;
}

Expand Down Expand Up @@ -237,11 +244,9 @@ const MainScreen = () => {
${searchResults &&
searchResults.map((result) => html`<${App} app=${result.item} toggleModal=${toggleModal} />`)}
</div>
<div id="dialog_layer" class="dialogs">
<div class="dialog-backdrop ${modal ? 'active' : 'hidden'}">
${searchResults &&
searchResults.map((result) => html`<${Dialog} app=${result.item} modal=${modal} toggleModal=${toggleModal} />`)}
</div>
<div>
${searchResults &&
searchResults.map((result) => html`<${Dialog} app=${result.item} modal=${modal} toggleModal=${toggleModal} />`)}
</div>
<div id="footer">
<a href="https://support.delta.chat/c/webxdc/20">support forum</a>
Expand Down
47 changes: 13 additions & 34 deletions website/apps/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -156,54 +156,40 @@ button.ghost, .button.ghost {
-------
*/

.dialog-backdrop {
background: rgb(0 0 0 / 30%);
display: none;
position: fixed;
overflow-y: auto;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: 1;
}

.dialog-backdrop.active {
display: block;
}

[role=dialog] {
dialog {
font-size: 1rem;
display: none;
color: var(--text);
padding: 2rem;
background: var(--bg);
min-height: 100vh;
margin: 0;
border: none;
gap: 1rem;
}

[role=dialog] .app-container {
dialog .app-container {
display: flex;
gap: var(--padding);
}

[role=dialog] .button-container {
dialog .button-container {
display: flex;
gap: var(--padding);
width: 100%;
flex-direction: column;
}

[role=dialog].active {
dialog[open] {
display: flex;
flex-direction: column;
}

[role=dialog] .metadata {
dialog .metadata {
display: flex;
flex-direction: column;
}

[role=dialog] .additional-info {
dialog .additional-info {
display: flex;
flex-direction: column;
}
Expand Down Expand Up @@ -269,20 +255,17 @@ button.ghost, .button.ghost {
margin: .5rem;
}

[role=dialog] {
display: none;
position: absolute;
top: 2rem;
left: 50vw;
transform: translateX( -50% );
dialog {
margin: auto;
margin-top: 2rem;
min-width: calc(640px - (15px * 2));
max-width: calc(640px - (15px * 2));
min-height: auto;
box-shadow: 0 19px 38px rgb(0 0 0 / 12%);
border-radius: var(--padding);
}

[role=dialog] .button-container {
dialog .button-container {
display: flex;
gap: var(--padding);
width: fit-content;
Expand All @@ -295,10 +278,6 @@ button.ghost, .button.ghost {
border-color: #FFFFFF20;
}

.dialog-backdrop {
background: rgb(255 255 255 / 30%);
}

.search {
background: #00000095;
border-bottom: 1px solid #00000020;
Expand Down