Skip to content
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

WIP added options to newappinstance to use a solidui button if wanted #478

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
28 changes: 21 additions & 7 deletions src/login/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { Signup } from '../signup/signup.js'
import { buttonStyle, commentStyle, textInputStyle } from '../style'
import { utils } from '../utils/index'
import * as widgets from '../widgets'
import {button, ButtonType} from "../widgets";

/**
* Resolves with the logged in user's WebID
Expand Down Expand Up @@ -983,6 +984,10 @@ export function selectWorkspace (
return box // return the box element, while login proceeds
} // selectWorkspace

interface newAppInstanceOptions {
useSolidUIButton: boolean,
buttonStyle: ButtonType
}
/**
* Creates a new instance of an app.
*
Expand All @@ -1002,20 +1007,29 @@ export function selectWorkspace (
export function newAppInstance (
dom: HTMLDocument,
appDetails: AppDetails,
callback: (workspace: string | null, newBase: string) => void
callback: (workspace: string | null, newBase: string) => void,
options: newAppInstanceOptions
): HTMLElement {
const gotWS = function (ws, base) {
// log.debug("newAppInstance: Selected workspace = " + (ws? ws.uri : 'none'))
callback(ws, base)
}
const div = dom.createElement('div')
const b = dom.createElement('button')
b.setAttribute('type', 'button')
div.appendChild(b)
b.innerHTML = `Make new ${appDetails.noun}`
b.addEventListener('click', _event => {
const newAppClickHandler = _event => {
div.appendChild(selectWorkspace(dom, appDetails, gotWS))
}, false)
}
let b
if (options.useSolidUIButton) {
b = button(dom, undefined, `Make new ${appDetails.noun}`, newAppClickHandler, options.buttonStyle)
} else {
b = dom.createElement('button')
b.setAttribute('type', 'button')
div.appendChild(b)
b.innerHTML = `Make new ${appDetails.noun}`
b.addEventListener('click', _event => {
div.appendChild(selectWorkspace(dom, appDetails, gotWS))
}, false)
}
div.appendChild(b)
return div
}
Expand Down