diff --git a/package-lock.json b/package-lock.json index 1f6ab9d8..a326f880 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1971,9 +1971,9 @@ } }, "node_modules/@codemirror/commands": { - "version": "6.11.1", - "resolved": "https://registry.npmjs.org/@codemirror/commands/-/commands-6.11.1.tgz", - "integrity": "sha512-O/4hG3SC1YwcmQ0d2UVNDs+AsaNWd1iHVxbTeEBuqH+6bExAiPK3iS/BvpY6rZGURALv4ZD3sIgcCmRvw3ehBg==", + "version": "6.11.2", + "resolved": "https://registry.npmjs.org/@codemirror/commands/-/commands-6.11.2.tgz", + "integrity": "sha512-NbH6Q9lmcXvf9s5/mMJIwL2Hjl2NEdsN/dDlezGnaFOQgNZ59dT7ndKUf21/PIjJacD/Ti2Ifi4TsBkO6WHvsg==", "license": "MIT", "dependencies": { "@codemirror/language": "^6.0.0", @@ -2117,9 +2117,9 @@ "license": "MIT" }, "node_modules/@codemirror/view": { - "version": "6.43.15", - "resolved": "https://registry.npmjs.org/@codemirror/view/-/view-6.43.15.tgz", - "integrity": "sha512-HHsfpqFeHyXLs983pSRe38Xajs0vFWZQ2BuX0m7Ki8w3jZ5iD8cuR3lBz2/5/X53Dhf32SBHKh6rtSTB6tKeGw==", + "version": "6.44.0", + "resolved": "https://registry.npmjs.org/@codemirror/view/-/view-6.44.0.tgz", + "integrity": "sha512-kAUekx35l9u64jW/NzdO054l80lz+ri+Z5ZFS+dMpMrCbG5pFiTz58twWcWghzBEInWno0SPaURNSCnHHvipnQ==", "license": "MIT", "dependencies": { "@codemirror/state": "^6.7.0", @@ -2863,9 +2863,9 @@ "license": "MIT" }, "node_modules/@lezer/common": { - "version": "1.5.6", - "resolved": "https://registry.npmjs.org/@lezer/common/-/common-1.5.6.tgz", - "integrity": "sha512-NZxu3q49ck+YYbEJPuIPIyFP37XneBvzPIarBHEXBLBVfkZqQieZ/Y2boYnGNYtmjpOZLnAKs/lwqtmDpi365w==", + "version": "1.5.7", + "resolved": "https://registry.npmjs.org/@lezer/common/-/common-1.5.7.tgz", + "integrity": "sha512-3+3PN+M/3xSjrlQz8/wBPOl+JYGJ+G37ZszHfnhphFwj41qPUPxsz4WEic3ZyVpL23rX1qefaGqz0lA7jGUqwg==", "license": "MIT" }, "node_modules/@lezer/css": { @@ -2900,9 +2900,9 @@ } }, "node_modules/@lezer/javascript": { - "version": "1.5.6", - "resolved": "https://registry.npmjs.org/@lezer/javascript/-/javascript-1.5.6.tgz", - "integrity": "sha512-sEvOqpl4vJQca0NugSQK02vQPbc5KrvoojnYGoqqFgFO0MtcYhwGiHKVEB+LuXYJnfyXo4QPA8ztbrEa4Fw5NA==", + "version": "1.5.7", + "resolved": "https://registry.npmjs.org/@lezer/javascript/-/javascript-1.5.7.tgz", + "integrity": "sha512-o3Rn+TzKuN25sdILOZFXi8hz4K/ed4OK0I+QrAi7Zzn3tXRBZmfsQrZpLX47ZYK/rZU8Vu4jLkz4SOSYRzBfjw==", "license": "MIT", "dependencies": { "@lezer/common": "^1.2.0", @@ -2922,18 +2922,18 @@ } }, "node_modules/@lezer/lr": { - "version": "1.4.12", - "resolved": "https://registry.npmjs.org/@lezer/lr/-/lr-1.4.12.tgz", - "integrity": "sha512-On9HU4oMMiHPMkQDgoTnGahjgG5n/MkN38CgG77sMraKLL+3JBbeQNi1FcCXV9QRqwF9/BUXP3caHyJC1fBOTQ==", + "version": "1.4.13", + "resolved": "https://registry.npmjs.org/@lezer/lr/-/lr-1.4.13.tgz", + "integrity": "sha512-Ez6qF9rXdnR/7hTcA6kHq1uTcPV+17hyUFjiHBVYNi0a81TgbkC0SwiNvxcuUMkvX7phuhTHo+QAXh9L2kjGdg==", "license": "MIT", "dependencies": { "@lezer/common": "^1.0.0" } }, "node_modules/@lezer/markdown": { - "version": "1.8.1", - "resolved": "https://registry.npmjs.org/@lezer/markdown/-/markdown-1.8.1.tgz", - "integrity": "sha512-M5YmEcKWO4mJ45Y1hECwqyu8cLv25EiXOK554PVOvDOWOP0olwelHHQUWr9sjF+d1bENVhy0nfJ8E57XZUTiXg==", + "version": "1.8.2", + "resolved": "https://registry.npmjs.org/@lezer/markdown/-/markdown-1.8.2.tgz", + "integrity": "sha512-q0kGuKOFrKEMi8d3ExryIOAT5XwjW86x1JO5scQB7gcXr8LobgXP3l6Gq6ArpXUQLeDju9cwRHF2Axjk6VMhLQ==", "license": "MIT", "dependencies": { "@lezer/common": "^1.5.0", @@ -3737,9 +3737,9 @@ "license": "MIT" }, "node_modules/@types/estree": { - "version": "1.0.10", - "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.10.tgz", - "integrity": "sha512-lTyOMnOcmRBzdCv6/4zUZCrEhV0xrqQiUZBZtVcbmLHBXKLnN8q89v/wKRF/Q0HbwVsqbIG3o5HDoFl9sduM+g==", + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/@types/estree/-/estree-1.0.11.tgz", + "integrity": "sha512-YBdNe5JcjYR0sPhJW1QIeRCmI11YhYvaRuGCs9+WCeTTb+Yhb2BE2XMe5/wAqF10FK5g3+q1PDhQABfT7aX0gg==", "dev": true, "license": "MIT" }, @@ -3751,18 +3751,18 @@ "license": "MIT" }, "node_modules/@types/node": { - "version": "22.20.5", - "resolved": "https://registry.npmjs.org/@types/node/-/node-22.20.5.tgz", - "integrity": "sha512-U2+DNr+wSjpsTS/wZGYHq7GcwfuSmKiKvoPvK22zwTlRhU91yOniN4qRR5KhIjvif7ysw/dz/hKmfDH0Ris4aA==", + "version": "22.20.7", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.20.7.tgz", + "integrity": "sha512-F/Mcc4pD3YwXQCG50hb8BjB5RmrOere6hge7n2XHf0V8tpkZOVEjwYv9Ql7n0MpMn8Bv7+q12P9w6UHsBm0Sfw==", "license": "MIT", "dependencies": { "undici-types": "~6.21.0" } }, "node_modules/@types/react": { - "version": "19.3.0", - "resolved": "https://registry.npmjs.org/@types/react/-/react-19.3.0.tgz", - "integrity": "sha512-N0rFCuH9YoxG9/m61l9MfpJKfmLOVU0em7ipIz6TRgSSkvReLB9vL85GB+yr8Bs5leqpvg96JSwF4ZS1s4viQg==", + "version": "19.3.3", + "resolved": "https://registry.npmjs.org/@types/react/-/react-19.3.3.tgz", + "integrity": "sha512-K8uWpJc4teiuOPdiP1umjeA9rGMgVPiXuoL66fcS1QlwBT1WMqY8PORmub9FadopIs+RCW6siYEs7Lpq+vDlog==", "license": "MIT", "peer": true, "dependencies": { @@ -3805,9 +3805,9 @@ } }, "node_modules/@typescript-eslint/eslint-plugin/node_modules/ignore": { - "version": "7.0.16", - "resolved": "https://registry.npmjs.org/ignore/-/ignore-7.0.16.tgz", - "integrity": "sha512-52N+Y4HRMOJmbLmr+DqO4iSRyyB7N52gm7PWCT6h0p978+oKbqHCB7gIJIwZvBUsjlSdWbrBFqUSmIFNZMpn0A==", + "version": "7.0.17", + "resolved": "https://registry.npmjs.org/ignore/-/ignore-7.0.17.tgz", + "integrity": "sha512-0c3zcBRlWmcKhcIQWckzkYncJRv5HHB8O32wO/FcWL8DDXWDJgiEF6SX9ThbTv5h/eZ+xJK+VvDjjQ+cQJhp3Q==", "dev": true, "license": "MIT", "engines": { @@ -4012,23 +4012,23 @@ } }, "node_modules/@uiw/codemirror-theme-vscode": { - "version": "4.25.12", - "resolved": "https://registry.npmjs.org/@uiw/codemirror-theme-vscode/-/codemirror-theme-vscode-4.25.12.tgz", - "integrity": "sha512-sIO/8/hJsT6meSa/d5RQHXw4isago+DP4iVQtqiULvaXaA3cQvtHVw0enbcZdwtVIT6rQEfERxqeoHiX9Psd5w==", + "version": "4.25.13", + "resolved": "https://registry.npmjs.org/@uiw/codemirror-theme-vscode/-/codemirror-theme-vscode-4.25.13.tgz", + "integrity": "sha512-EaqMHexflhyio53qT5tmEVMOwGFdqGos4q9LY2M74EeAQBR1nP0LbHJBLxMLQGLtgpOLutce7jeIUyFZuA5g1g==", "license": "MIT", "dependencies": { "@babel/runtime": "^7.18.6", "@lezer/highlight": "^1.0.0", - "@uiw/codemirror-themes": "4.25.12" + "@uiw/codemirror-themes": "4.25.13" }, "funding": { "url": "https://jaywcjlove.github.io/#/sponsor" } }, "node_modules/@uiw/codemirror-themes": { - "version": "4.25.12", - "resolved": "https://registry.npmjs.org/@uiw/codemirror-themes/-/codemirror-themes-4.25.12.tgz", - "integrity": "sha512-3bLX6C+gstr82SmY2FAj2TfHXnl2SnC+whRZJmRsv82wMhG8RZlZVy+o0rLuGRIPD9acuY0gpouHVRNUnzBj3g==", + "version": "4.25.13", + "resolved": "https://registry.npmjs.org/@uiw/codemirror-themes/-/codemirror-themes-4.25.13.tgz", + "integrity": "sha512-2sai+4dRRrbutz4jHyHaJDYf7beTdRYN3p1ciiE/spEH03grc58f8n2yNnUQRz3zjFRALDjMnzEu8A5LukMKyQ==", "license": "MIT", "dependencies": { "@codemirror/language": "^6.0.0", @@ -4839,9 +4839,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001827", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001827.tgz", - "integrity": "sha512-YWEDr46gSO81M8w6uPbaIy4++IXsirx2asUqvllNiD4BPf75ibxclUjWEqp8ObCenRv+UM2n5Y8xuRPT8V8FrQ==", + "version": "1.0.30001828", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001828.tgz", + "integrity": "sha512-7MWeT+3DlrpuDybTWHl4Zb1Z80Z1fLLnOXuBjDXebzDVcqnEWUlV8JcbASg8B8BhcW8QT2UiR1KAtzYFIZHZYA==", "dev": true, "funding": [ { @@ -5335,9 +5335,9 @@ } }, "node_modules/electron-to-chromium": { - "version": "1.5.492", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.492.tgz", - "integrity": "sha512-4uMs7omhajKiud0GqALLTazS/zyvHLTLmDWVTR+e6BnyJo5bSNrph/JoRWEFJJmY75ct9hCiSGsbFF9fLe5gDw==", + "version": "1.5.494", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.494.tgz", + "integrity": "sha512-Tph7ohL4Xc0ft3DXElYEIVTmPI3H0MtPCTdgtz5AwWGZG6q+vMiT3IzJ3RJX/HJQ8pYzeimQyvi6SsBTOS0nyQ==", "dev": true, "license": "ISC" }, @@ -8053,9 +8053,9 @@ } }, "node_modules/lucide": { - "version": "1.78.0", - "resolved": "https://registry.npmjs.org/lucide/-/lucide-1.78.0.tgz", - "integrity": "sha512-4lMWPv+OZGL1N2jkTNGjw86Rd3+4gyCdBHHXw+emfCvbQEojOPwPQo20y4SEUxy5ZBc3IDp3KC1vA7PPiuLbQA==", + "version": "1.80.0", + "resolved": "https://registry.npmjs.org/lucide/-/lucide-1.80.0.tgz", + "integrity": "sha512-3tsjW2GIkBNMYHlpnOUA4bP5jAh20iRHksM92tSsCzu24BktkK103HJfOqPybqJtDgYnY5NEf6LEyBiq0N+KjA==", "license": "ISC" }, "node_modules/lz-string": { @@ -8107,9 +8107,9 @@ } }, "node_modules/marked": { - "version": "18.2.1", - "resolved": "https://registry.npmjs.org/marked/-/marked-18.2.1.tgz", - "integrity": "sha512-ii4bxCTCqqwpT86XZWgJNs+ZnAIZksmLGYMViWA7PDIXYIeNo1x6cDdX3JOip9NM/cI6p8z57FxliACboTruMA==", + "version": "18.3.0", + "resolved": "https://registry.npmjs.org/marked/-/marked-18.3.0.tgz", + "integrity": "sha512-ed8zmPXlBb3UfGXN5iHMQyMhFpdqLgoV5umUXx/Q1R+FW3q8VpqpyoKUwlENL9appo2UMvNLURDVaT3AMOryGA==", "license": "MIT", "bin": { "marked": "bin/marked.js" @@ -10147,9 +10147,9 @@ "license": "MIT" }, "node_modules/tinyexec": { - "version": "1.3.1", - "resolved": "https://registry.npmjs.org/tinyexec/-/tinyexec-1.3.1.tgz", - "integrity": "sha512-GCvB3aoys96IuDFBMcTB46JOR6mdMtAToqwiW8JlWhsoh1mhHi/xn9ss/Dg7N555GiJyEt2qzoG/NHCwM6h1EA==", + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/tinyexec/-/tinyexec-1.4.0.tgz", + "integrity": "sha512-PV6lIcJQh57aFeJDwx16JNHmgFRh5xguzallrDW1qe8nAghYgr5MKz2K5k7wEyV/ygZhdnIAP8+HZSarHPBCsg==", "dev": true, "license": "MIT", "engines": { @@ -10184,22 +10184,22 @@ } }, "node_modules/tldts": { - "version": "7.5.5", - "resolved": "https://registry.npmjs.org/tldts/-/tldts-7.5.5.tgz", - "integrity": "sha512-Hy6IImaWALzJOgCIss4gIFi4G0M9lqk95pFKCUVxQPZw+biZ1Pv6f28JpYgahpJB+BufA0HYsIU/aP/WIx3KRg==", + "version": "7.6.0", + "resolved": "https://registry.npmjs.org/tldts/-/tldts-7.6.0.tgz", + "integrity": "sha512-IFk9SJW/EhTZMpJA1zRdP+69JK4NmJbMx1aRdJvLBR9em1k62eWiwolSWlDRpRdkaAnZ1dDCwFPmRPBNuLGGHA==", "dev": true, "license": "MIT", "dependencies": { - "tldts-core": "^7.5.5" + "tldts-core": "^7.6.0" }, "bin": { "tldts": "bin/cli.js" } }, "node_modules/tldts-core": { - "version": "7.5.5", - "resolved": "https://registry.npmjs.org/tldts-core/-/tldts-core-7.5.5.tgz", - "integrity": "sha512-rEJz/8cJFY/bdF354gl14yxavbrIbvM+FcbkYVQ6CSCMQTJdUFUIm39TTWSiGPvcpQh7/F6qHrD3SkwwdgtDCw==", + "version": "7.6.0", + "resolved": "https://registry.npmjs.org/tldts-core/-/tldts-core-7.6.0.tgz", + "integrity": "sha512-0By9U6fw2hNzfJAbBMuo1bsX/OyVlsj0wjGyMPV50RZKoLCRwXBOX0FQqgZDaMo2WjjaEW/ZGyVXicLUFTmXqQ==", "dev": true, "license": "MIT" }, diff --git a/src/dashboard/basicPreferences.ts b/src/dashboard/basicPreferences.ts index 2b40e1b1..38fc9966 100644 --- a/src/dashboard/basicPreferences.ts +++ b/src/dashboard/basicPreferences.ts @@ -1,6 +1,9 @@ import { PaneDefinition } from 'pane-registry' import { IndexedFormula, NamedNode, parse, Store } from 'rdflib' import { icons, login, ns, widgets } from 'solid-ui' +import '~icons/lucide/info' +import '~icons/lucide/trash-2' +import '~icons/lucide/triangle-alert' import ontologyData from './ontologyData.ttl' import preferencesFormText from './preferencesFormText.ttl' @@ -20,12 +23,17 @@ export const basicPreferencesPane: PaneDefinition = { function complainIfBad (ok: Boolean, mess: any) { if (ok) return - container.appendChild(widgets.errorMessageBlock(dom, mess, '#fee')) + main.appendChild(widgets.errorMessageBlock(dom, mess, '#fee')) } + // Two columns, as in the design: the sections, and Help & Support beside them const container = dom.createElement('div') + container.setAttribute('style', styles.layout) + const main = container.appendChild(dom.createElement('div')) + main.setAttribute('style', styles.mainColumn) + addHelpSection(container, dom) - const formArea = setupUserTypesSection(container, dom) + const formArea = setupUserTypesSection(main, dom) function loadData (doc: NamedNode, turtle: String) { doc = doc.doc() // remove # from URI if nec @@ -67,15 +75,15 @@ export const basicPreferencesPane: PaneDefinition = { renderContext.preferencesFile, complainIfBad ) - appendedForm.style.borderStyle = 'none' + styleForm(appendedForm, dom) const trustedApplicationsView = context.session.paneRegistry.byName('trustedApplications') if (trustedApplicationsView) { - container.appendChild(trustedApplicationsView.render(null, context)) + main.appendChild(trustedApplicationsView.render(null, context)) } // @@ TODO Remove need for casting as any and bang (!) syntax - addDeleteSection(container, store, renderContext.me!, dom) + addDeleteSection(main, store, renderContext.me!, dom) } doRender() @@ -91,17 +99,33 @@ function setupUserTypesSection ( const formContainer = createSection(container, dom, 'User types') const description = formContainer.appendChild(dom.createElement('p')) - description.innerText = 'Here you can self-assign user types to help the data browser know which views you would like to access.' + description.setAttribute('style', styles.description) + description.textContent = 'The options presented to you when viewing data can be customised based on your role. ' - const userTypesLink = formContainer.appendChild(dom.createElement('a')) + const userTypesLink = description.appendChild(dom.createElement('a')) userTypesLink.href = 'https://github.com/solidos/userguide/#role' - userTypesLink.innerText = 'Read more' + userTypesLink.textContent = 'Read more' const formArea = formContainer.appendChild(dom.createElement('div')) return formArea } +/** + * The form is generated by solid-ui with its own inline styles. + * Restyle the generated elements to match the Preferences design. + */ +function styleForm (form: HTMLElement, dom: HTMLDocument): void { + form.style.border = 'none' + form.style.paddingLeft = '0' + form.querySelectorAll('.formFieldName').forEach(label => { + label.setAttribute('style', styles.fieldLabel) + label.querySelectorAll('a').forEach(link => link.setAttribute('style', 'color: inherit; text-decoration: none;')) + label.appendChild(infoIcon(dom, 'Power users and developers are offered extra views of their data. This is private, and stored in your preferences file.')) + }) + form.querySelectorAll('select').forEach(select => select.setAttribute('style', styles.select)) +} + export default basicPreferencesPane // ends @@ -112,18 +136,37 @@ function addDeleteSection ( profile: NamedNode, dom: HTMLDocument ): void { - const section = createSection(container, dom, 'Delete account') + const section = createSection(container, dom, 'Delete your Solid account', + 'Account deletion is handled by your Pod provider. You will be taken to their site to confirm.') + + const description = section.appendChild(dom.createElement('p')) + description.setAttribute('style', styles.description) + description.textContent = 'If you no longer want your Solid Pod, you can delete your account.' + + const warning = section.appendChild(dom.createElement('div')) + warning.setAttribute('style', styles.warning) + warning.setAttribute('role', 'note') + const warningIcon = warning.appendChild(dom.createElement('icon-lucide-triangle-alert')) + warningIcon.setAttribute('aria-hidden', 'true') + warningIcon.setAttribute('style', 'flex: 0 0 16px; width: 16px; height: 16px; margin-top: 2px;') + const warningText = warning.appendChild(dom.createElement('div')) + const warningTitle = warningText.appendChild(dom.createElement('strong')) + warningTitle.setAttribute('style', 'font-weight: 500;') + warningTitle.textContent = 'Warning:' + const warningBody = warningText.appendChild(dom.createElement('p')) + warningBody.setAttribute('style', 'margin: 8px 0 0; color: var(--color-text-secondary, #4a5565);') + warningBody.textContent = 'When your account is deleted, all of the data is deleted and cannot be restored.' const podServerNodes = store.each(profile, ns.space('storage'), null, profile.doc()) const podServers = podServerNodes.map(node => node.value) - const list = section.appendChild(dom.createElement('ul')) + const list = section.appendChild(dom.createElement('div')) + list.setAttribute('style', 'display: flex; flex-wrap: wrap; gap: 8px;') podServers.forEach(async server => { const deletionLink = await generateDeletionLink(server, dom) if (deletionLink) { - const listItem = list.appendChild(dom.createElement('li')) - listItem.appendChild(deletionLink) + list.appendChild(deletionLink) } }) } @@ -133,7 +176,12 @@ async function generateDeletionLink ( dom: HTMLDocument ): Promise { const link = dom.createElement('a') - link.textContent = `Delete your account at ${podServer}` + link.setAttribute('style', styles.dangerButton) + link.setAttribute('title', `Delete your account at ${podServer}`) + const icon = link.appendChild(dom.createElement('icon-lucide-trash-2')) + icon.setAttribute('aria-hidden', 'true') + icon.setAttribute('style', 'width: 14px; height: 14px;') + link.appendChild(dom.createTextNode('Delete your account')) const deletionUrl = await getDeletionUrlForServer(podServer) if (typeof deletionUrl !== 'string') { return null @@ -187,16 +235,71 @@ async function getDeletionUrlForServer ( function createSection ( container: Element, dom: HTMLDocument, - title: string + title: string, + info?: string ): Element { const section = container.appendChild(dom.createElement('div')) - section.style.border = '0.3em solid #418d99' - section.style.borderRadius = '0.5em' - section.style.padding = '0.7em' - section.style.marginTop = '0.7em' + section.setAttribute('style', styles.card) const titleElement = section.appendChild(dom.createElement('h3')) - titleElement.innerText = title + titleElement.setAttribute('style', styles.cardTitle) + titleElement.textContent = title + if (info) titleElement.appendChild(infoIcon(dom, info)) return section } + +function addHelpSection (container: Element, dom: HTMLDocument): void { + const aside = container.appendChild(dom.createElement('aside')) + aside.setAttribute('style', styles.aside) + const section = aside.appendChild(dom.createElement('div')) + section.setAttribute('style', styles.card + ' padding: 16px;') + + const title = section.appendChild(dom.createElement('h3')) + title.setAttribute('style', 'margin: 0 0 8px; font-size: 1rem; font-weight: 600;') + title.textContent = 'Help & Support' + + const text = section.appendChild(dom.createElement('p')) + text.setAttribute('style', styles.description) + text.textContent = 'Your preferences are stored privately in your Pod. Trusted applications are listed in your profile. ' + const link = text.appendChild(dom.createElement('a')) + link.href = 'https://solidos.github.io/userguide/' + link.target = '_blank' + link.rel = 'noopener noreferrer' + link.textContent = 'SolidOS user guide' +} + +/** A small (i) icon whose tooltip explains a section or field */ +export function infoIcon (dom: HTMLDocument, text: string): HTMLElement { + const span = dom.createElement('span') + span.setAttribute('role', 'img') + span.setAttribute('aria-label', text) + span.setAttribute('title', text) + span.setAttribute('tabindex', '0') + span.setAttribute('style', 'display: inline-flex; width: 16px; height: 16px; color: var(--color-text-secondary, #4a5565); cursor: help;') + const icon = span.appendChild(dom.createElement('icon-lucide-info')) + icon.setAttribute('aria-hidden', 'true') + icon.setAttribute('style', 'width: 16px; height: 16px;') + return span +} + +/** Inline styles for the Preferences design (SolidOS/solid-panes#710) */ +const styles = { + layout: 'display: flex; flex-wrap: wrap; align-items: flex-start; gap: 16px; padding: 16px; ' + + 'background: var(--solid-ui-color-slate-50, #f8fafc); color: var(--color-text, #101828);', + mainColumn: 'display: flex; flex-direction: column; gap: 16px; flex: 1 1 480px; min-width: 0;', + aside: 'flex: 0 1 280px;', + card: 'background: var(--solid-ui-color-white, #ffffff); border: 1px solid var(--solid-ui-color-slate-200, #e2e8f0); ' + + 'border-radius: 5px; padding: 24px; box-sizing: border-box;', + cardTitle: 'display: flex; align-items: center; gap: 6px; margin: 0 0 8px; font-size: 1.125rem; font-weight: 500;', + description: 'margin: 0 0 16px; color: var(--color-text-secondary, #4a5565); font-size: 0.875rem; line-height: 1.5;', + fieldLabel: 'display: flex; align-items: center; gap: 6px; margin-bottom: 8px; font-weight: 500;', + select: 'width: 100%; max-width: 340px; min-height: 40px; padding: 8px 12px; margin: 0; ' + + 'border: 1px solid var(--solid-ui-color-gray-300, #d1d5dc); border-radius: 5px; ' + + 'background: var(--solid-ui-color-white, #ffffff); font: inherit; font-size: 0.875rem;', + warning: 'display: flex; gap: 8px; margin-bottom: 24px; padding: 20px 24px; border-radius: 5px; ' + + 'background: var(--solid-ui-color-red-50, #fef2f2); color: var(--solid-ui-color-red-600, #dc2626); font-size: 0.875rem;', + dangerButton: 'display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; ' + + 'border: 1px solid var(--solid-ui-color-red-600, #dc2626); border-radius: 5px; background: var(--solid-ui-color-white, #ffffff); ' + + 'color: var(--solid-ui-color-red-600, #dc2626); font-size: 0.875rem; font-weight: 500; text-decoration: none;' +} diff --git a/src/dashboard/ontologyData.ttl b/src/dashboard/ontologyData.ttl index 09393365..7a2da7fc 100644 --- a/src/dashboard/ontologyData.ttl +++ b/src/dashboard/ontologyData.ttl @@ -2,6 +2,7 @@ @prefix rdfs: . @prefix solid: . @prefix foaf: . +@prefix owl: . @prefix schema: . @prefix ui: . @prefix vcard: . @@ -10,7 +11,9 @@ solid:User a rdfs:Class; rdfs:label "user"@en, "utilisateur"@fr; rdfs:comment """Any person who might use a Solid-based system"""; - rdfs:subClassOf foaf:Person, schema:Person, vcard:Individual. + rdfs:subClassOf foaf:Person, schema:Person, vcard:Individual; + # One role at a time, so the preferences form shows a single dropdown + owl:disjointUnionOf ( solid:PowerUser solid:Developer ). # Since these options are opt-in, it is a bit strange to have new users opt in # That they are new users - also we do not use this class for anything specific diff --git a/src/dashboard/preferencesFormText.ttl b/src/dashboard/preferencesFormText.ttl index 98c414d8..feddf795 100644 --- a/src/dashboard/preferencesFormText.ttl +++ b/src/dashboard/preferencesFormText.ttl @@ -5,14 +5,8 @@ :this "Basic preferences" ; a ui:Form ; - ui:part :categorizeUser, :privateComment, :personalInformationHeading; - ui:parts ( :personalInformationHeading :privateComment :categorizeUser ). - -:personalInformationHeading a ui:Heading; - ui:contents "Personal information". - -:privateComment a ui:Comment; - ui:contents "This information is private.". + ui:part :categorizeUser; + ui:parts ( :categorizeUser ). :categorizeUser a ui:Classifier; - ui:label "Level of user"; ui:property rdf:type ; ui:category solid:User. + ui:label "Role"; ui:property rdf:type ; ui:category solid:User. diff --git a/src/trustedApplications/trustedApplications.dom.ts b/src/trustedApplications/trustedApplications.dom.ts index 404b870c..4ace6010 100644 --- a/src/trustedApplications/trustedApplications.dom.ts +++ b/src/trustedApplications/trustedApplications.dom.ts @@ -1,6 +1,7 @@ import { NamedNode, Statement, sym } from 'rdflib' import { ns } from 'solid-ui' import { store } from 'solid-logic' +import '~icons/lucide/trash-2' import { generateRandomString, getStatementsToAdd, getStatementsToDelete } from './trustedApplications.utils' interface FormElements { @@ -14,14 +15,15 @@ interface FormElements { export function createApplicationTable (subject: NamedNode) { const applicationsTable = createElement('table', { - class: 'results' + class: 'results', + style: styles.table }) - // creating headers + // creating headers: one column per access mode, as in the Preferences design const header = createContainer('tr', [ - createText('th', 'Application URL'), - createText('th', 'Access modes'), - createText('th', 'Actions') + createText('th', 'Application URL', { style: styles.th + styles.urlCell }), + ...modes.map(mode => createText('th', mode, { style: styles.th })), + createText('th', '', { style: styles.th }) ]) applicationsTable.appendChild(header); @@ -80,6 +82,8 @@ function createApplicationEntry ( { class: 'textinput', placeholder: 'Write new URL here', + 'aria-label': origin ? 'Application URL' : 'New application URL (press Enter to add)', + style: styles.urlInput, value: origin ? origin.value : '' }, {}, @@ -93,50 +97,24 @@ function createApplicationEntry ( submit: addOrEditApplication } ) - ]), - createContainer('td', [ - createContainer( - 'form', - createModesInput(trustedApplicationState), - {}, - { - submit: addOrEditApplication - } - ) - ]), - createContainer('td', [ - createContainer( - 'form', - origin - ? [ - createText('button', 'Update', { - class: 'controlButton', - style: 'background: LightGreen;' - }), - createText( - 'button', - 'Delete', - { - class: 'controlButton', - style: 'background: LightCoral;' - }, - { - click: removeApplication - } - ) - ] - : [ - createText('button', 'Add', { - class: 'controlButton', - style: 'background: LightGreen;' - }) - ], - {}, - { - submit: addOrEditApplication - } - ) - ]) + ], { style: styles.td + styles.urlCell }), + // Ticking a mode saves straight away for an existing app; + // for the new-app row, the modes are saved when the URL is entered + ...createModesInput(trustedApplicationState, origin ? addOrEditApplication : null) + .map(checkbox => createContainer('td', [checkbox], { style: styles.td })), + createContainer('td', origin + ? [ + createContainer('button', [createIcon('icon-lucide-trash-2')], { + type: 'button', + class: 'controlButton', + title: 'Remove', + 'aria-label': `Remove ${origin.value}`, + style: styles.trashButton + }, { + click: removeApplication + }) + ] + : [], { style: styles.td + 'text-align: right;' }) ]) function addOrEditApplication (event: Event) { @@ -251,26 +229,50 @@ export function createText ( return element } -function createModesInput ({ appModes, formElements }: { +const modes = ['Read', 'Write', 'Append', 'Control'] + +/** A 16px decorative icon, e.g. */ +export function createIcon (tagName: string): HTMLElement { + const icon = document.createElement(tagName) + icon.setAttribute('aria-hidden', 'true') + icon.setAttribute('style', 'width: 16px; height: 16px;') + return icon +} + +function createModesInput ({ appModes, formElements, origin }: { appModes: NamedNode[] formElements: FormElements -}) { - return ['Read', 'Write', 'Append', 'Control'].map(mode => { + origin: NamedNode | null +}, onChange: ((event: Event) => void) | null) { + return modes.map(mode => { const isChecked = appModes.some( appMode => appMode.value === ns.acl(mode).value ) - return createContainer('label', [ - createElement( - 'input', - { - type: 'checkbox', - ...(isChecked ? { checked: '' } : {}), - value: ns.acl(mode).uri - }, - {}, - element => formElements.modes.push(element) - ), - createText('span', mode) - ]) + return createElement( + 'input', + { + type: 'checkbox', + ...(isChecked ? { checked: '' } : {}), + value: ns.acl(mode).uri, + 'aria-label': `${mode} access for ${origin ? origin.value : 'the new application'}`, + style: styles.checkbox + }, + onChange ? { change: onChange } : {}, + element => formElements.modes.push(element) + ) }) } + +/** Inline styles for the trusted applications table, as in the Preferences design (#710) */ +const border = '1px solid var(--solid-ui-color-slate-200, #e2e8f0)' +const styles = { + table: `width: 100%; border-collapse: separate; border-spacing: 0; border: ${border}; border-bottom: none; border-radius: 5px; font-size: 0.875rem;`, + th: 'padding: 12px 16px; text-align: left; font-weight: 500; background: color-mix(in srgb, var(--solid-ui-color-primary, #7c4dff) 10%, #ffffff); ' + + `border-bottom: ${border};`, + td: `padding: 12px 16px; border-bottom: ${border}; vertical-align: middle;`, + urlCell: `border-right: ${border}; min-width: 240px;`, + urlInput: 'width: 100%; box-sizing: border-box; padding: 4px 0; border: none; background: transparent; font: inherit; color: inherit;', + checkbox: 'width: 16px; height: 16px; margin: 0; cursor: pointer; accent-color: var(--solid-ui-color-orange-500, #f97316);', + trashButton: 'display: inline-flex; align-items: center; justify-content: center; width: 32px; height: 32px; padding: 0; ' + + 'border: none; border-radius: 5px; background: transparent; color: var(--solid-ui-color-gray-400, #9ca3af); cursor: pointer;' +} diff --git a/src/trustedApplications/trustedApplications.view.ts b/src/trustedApplications/trustedApplications.view.ts index 9cfe21bd..1c0113cb 100644 --- a/src/trustedApplications/trustedApplications.view.ts +++ b/src/trustedApplications/trustedApplications.view.ts @@ -2,9 +2,12 @@ import { PaneDefinition } from 'pane-registry' import { NamedNode } from 'rdflib' import { icons, login, widgets } from 'solid-ui' import { store } from 'solid-logic' -import { createApplicationTable, createContainer, createText } from './trustedApplications.dom' +import '~icons/lucide/info' +import { createApplicationTable, createIcon, createText } from './trustedApplications.dom' -const thisColor = '#418d99' +const cardStyle = 'background: var(--solid-ui-color-white, #ffffff); border: 1px solid var(--solid-ui-color-slate-200, #e2e8f0); ' + + 'border-radius: 5px; padding: 24px; box-sizing: border-box;' +const descriptionStyle = 'margin: 0 0 16px; color: var(--color-text-secondary, #4a5565); font-size: 0.875rem; line-height: 1.5;' const trustedApplicationView: PaneDefinition = { global: true, @@ -15,17 +18,13 @@ const trustedApplicationView: PaneDefinition = { const dom = context.dom const div = dom.createElement('div') div.classList.add('trusted-applications-pane') - div.setAttribute( - 'style', - 'border: 0.3em solid ' + - thisColor + - '; border-radius: 0.5em; padding: 0.7em; margin-top:0.7em;' - ) + div.setAttribute('style', cardStyle) const table = div.appendChild(dom.createElement('table')) + table.setAttribute('style', 'width: 100%;') const main = table.appendChild(dom.createElement('tr')) const bottom = table.appendChild(dom.createElement('tr')) const statusArea = bottom.appendChild(dom.createElement('div')) - statusArea.setAttribute('style', 'padding: 0.7em;') + statusArea.setAttribute('style', 'padding: 0;') render(dom, main, statusArea).catch(err => statusArea.appendChild(widgets.errorMessageBlock(dom, err))) return div } @@ -41,7 +40,19 @@ async function render (dom, main, statusArea): Promise { } const editable = store.updater.editable(profile.uri, store) - main.appendChild(createText('h3', 'Manage your trusted applications')) + const notes = 'Trusted applications will get access to all resources that you have access to. ' + + 'You can limit which modes they have by default. They will not gain more access than you have.' + const heading = main.appendChild(createText('h3', 'Manage your trusted applications', { + style: 'display: flex; align-items: center; gap: 6px; margin: 0 0 8px; font-size: 1.125rem; font-weight: 500;' + })) + const info = heading.appendChild(createText('span', null, { + role: 'img', + 'aria-label': notes, + title: notes, + tabindex: '0', + style: 'display: inline-flex; width: 16px; height: 16px; color: var(--color-text-secondary, #4a5565); cursor: help;' + })) + info.appendChild(createIcon('icon-lucide-info')) if (!editable) { main.appendChild( @@ -50,30 +61,17 @@ async function render (dom, main, statusArea): Promise { return } - main.appendChild(createText('p', 'Here you can manage the applications you trust.')) + main.appendChild(createText('p', 'Before you can use third-party applications, you need to add them to the allowlist via the Trusted Application table.', { + style: descriptionStyle + })) const applicationsTable = createApplicationTable(subject) main.appendChild(applicationsTable) - main.appendChild(createText('h4', 'Notes')) - main.appendChild( - createContainer('ol', [ - main.appendChild( - createText( - 'li', - 'Trusted applications will get access to all resources that you have access to.' - ) - ), - main.appendChild( - createText('li', 'You can limit which modes they have by default.') - ), - main.appendChild( - createText('li', 'They will not gain more access than you have.') - ) - ]) - ) main.appendChild( - createText('p', 'Application URLs must be valid URL. Examples are http://localhost:3000, https://trusted.app, and https://sub.trusted.app.') + createText('p', 'To add an application, type its URL in the last row and press Enter. Application URLs must be valid URL. Examples are http://localhost:3000, https://trusted.app, and https://sub.trusted.app.', { + style: descriptionStyle + ' margin: 12px 0 0;' + }) ) }