diff --git a/client/config.tsx b/client/config.tsx index 0b4ae72d..ff2b1fb4 100644 --- a/client/config.tsx +++ b/client/config.tsx @@ -5,4 +5,6 @@ export const lean4webConfig: LeanWebConfig = { serverCountry: "Germany", contactDetails: null, impressum: null, + comparator: "https://comparator.live.lean-lang.org/", + comparatorSafeList: ["lean-lang.org", /^.*\.lean-lang\.org$/], }; diff --git a/client/src/api/config-types.ts b/client/src/api/config-types.ts index 7f05a165..0757c00c 100644 --- a/client/src/api/config-types.ts +++ b/client/src/api/config-types.ts @@ -13,4 +13,13 @@ export type LeanWebConfig = { * (example: `<>
vat number: 000
<>`) */ impressum: JSX.Element | null + /** Base href for a comparator live deployment that encourages the verification of proofs from untrusted sources. + * If `null`, the "Can I Trust This Proof?" button will be hidden. + * (example: `"https://comparator.live.lean-lang.org/"`) + */ + comparator: string | null + /** URLs to safelist so that refer links do not prompt a popup highlighting the "Can I Trust This Proof?" button. + * Ignored if `comparator` option is `null`. + */ + comparatorSafeList: (string | RegExp)[] | null } diff --git a/client/src/css/Navigation.css b/client/src/css/Navigation.css index dc155427..107bc822 100644 --- a/client/src/css/Navigation.css +++ b/client/src/css/Navigation.css @@ -78,6 +78,10 @@ nav select { padding-bottom: 0.6rem; } +nav .nav-link.disabled { + cursor: not-allowed; +} + /* Zulip logo (instead of font-awesome icon) */ nav .nav-link svg { width: 1.4rem; @@ -148,3 +152,77 @@ nav select:hover { font-style: italic; color: var(--vscode-textLink-foreground); } + +.comparator-warning { + max-width: 290px; + color: var(--vscode-editorHoverWidget-foreground); + background-color: var(--comparator-warning-bg); + font-size: 90%; + padding: 0.9em 1em; + box-shadow: 0 0.2rem 0.6rem 0 var(--vscode-widget-shadow); + border: 1px solid var(--vscode-editorHoverWidget-border); + border-radius: 0.4em; + position: relative; +} + +.comparator-warning.dark { + --comparator-warning-bg: oklch(0.2264 0.1066 0); +} +.comparator-warning.light { + --comparator-warning-bg: oklch(0.9581 0.0293 0); +} +.comparator-warning.cobalt { + --comparator-warning-bg: oklch(0.2981 0.1382 0); +} + +.comparator-warning button.comparator-warning-close { + float: right; + font-size: 1.6em; + cursor: pointer; + padding-top: 0.1em; + border: none; + background: none; + color: inherit; + margin: 0; +} +.comparator-warning button.comparator-warning-close:hover { + color: var(--vscode-inputOption-activeForeground); +} + +.comparator-warning p { + margin: 0 0 0.6em; +} + +.comparator-warning-arrow { + position: absolute; + width: 1em; + height: 1em; + margin-top: -0.5em; + top: 0; +} + +.comparator-warning-arrow::before { + content: ''; + display: block; + width: 100%; + height: 100%; + background-color: var(--comparator-warning-bg); + border: 1px solid var(--vscode-editorHoverWidget-border); + transform: rotate(45deg); + border-right: none; + border-bottom: none; +} + +.comparator-warning-perma-dismiss { + padding: 0; + background: none; + border: none; + cursor: pointer; + font-size: inherit; + color: var(--vscode-textLink-foreground); + font-weight: bold; +} + +.comparator-warning-perma-dismiss:hover { + text-decoration: underline; +} \ No newline at end of file diff --git a/client/src/navigation/NavButton.tsx b/client/src/navigation/NavButton.tsx index a7a1920e..faa641c4 100644 --- a/client/src/navigation/NavButton.tsx +++ b/client/src/navigation/NavButton.tsx @@ -1,6 +1,6 @@ import { IconDefinition } from '@fortawesome/free-solid-svg-icons' import { FontAwesomeIcon } from '@fortawesome/react-fontawesome' -import { JSX, MouseEventHandler } from 'react' +import { JSX, MouseEventHandler, Ref } from 'react' /** A button to appear in the hamburger menu or to navigation bar. */ export function NavButton({ @@ -10,6 +10,8 @@ export function NavButton({ title, onClick = () => {}, href = undefined, + disabled = false, + ref, }: { icon?: IconDefinition iconElement?: JSX.Element @@ -17,11 +19,22 @@ export function NavButton({ title?: string onClick?: MouseEventHandler
+