diff --git a/frontend/src/routing/Router.tsx b/frontend/src/routing/Router.tsx index 43d20df8..d4353458 100644 --- a/frontend/src/routing/Router.tsx +++ b/frontend/src/routing/Router.tsx @@ -13,9 +13,18 @@ // limitations under the License. import { useAtom, useAtomValue } from "jotai"; -import { lazy, useEffect } from "react"; +import { useEffect } from "react"; import LoadingSpinner from "../components/LoadingSpinner"; +import BrowserSession from "../pages/BrowserSession"; +import BrowserSessionList from "../pages/BrowserSessionList"; +import CompatSessionList from "../pages/CompatSessionList"; +import OAuth2Client from "../pages/OAuth2Client"; +import OAuth2SessionList from "../pages/OAuth2SessionList"; +import Profile from "../pages/Profile"; +import SessionDetail from "../pages/SessionDetail"; +import SessionsOverview from "../pages/SessionsOverview"; +import VerifyEmail from "../pages/VerifyEmail"; import { getRouteActionRedirection } from "./actions"; import { locationAtom, routeAtom } from "./atoms"; @@ -42,16 +51,6 @@ const useRouteWithRedirect = (): [Route, boolean] => { return [route, redirecting]; }; -const SessionsOverview = lazy(() => import("../pages/SessionsOverview")); -const SessionDetail = lazy(() => import("../pages/SessionDetail")); -const Profile = lazy(() => import("../pages/Profile")); -const OAuth2Client = lazy(() => import("../pages/OAuth2Client")); -const BrowserSession = lazy(() => import("../pages/BrowserSession")); -const BrowserSessionList = lazy(() => import("../pages/BrowserSessionList")); -const CompatSessionList = lazy(() => import("../pages/CompatSessionList")); -const OAuth2SessionList = lazy(() => import("../pages/OAuth2SessionList")); -const VerifyEmail = lazy(() => import("../pages/VerifyEmail")); - const Router: React.FC = () => { const [route, redirecting] = useRouteWithRedirect(); diff --git a/frontend/src/styles/cpd-button.css b/frontend/src/styles/cpd-button.css new file mode 100644 index 00000000..fa97155a --- /dev/null +++ b/frontend/src/styles/cpd-button.css @@ -0,0 +1,127 @@ +/* Copyright 2023 The Matrix.org Foundation C.I.C. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +.cpd-button { + display: block; + text-align: center; + border-radius: var(--cpd-radius-pill-effect); + cursor: pointer; + -webkit-appearance: none; +} + +.cpd-button[disabled] { + cursor: not-allowed; + pointer-events: all !important; +} + +/** + * SIZES + */ + +.cpd-button[data-size="lg"] { + font: var(--cpd-font-body-lg-semibold); + padding: var(--cpd-space-3x) var(--cpd-space-10x); +} + +.cpd-button[data-size="sm"] { + font: var(--cpd-font-body-md-semibold); + padding: var(--cpd-space-1x) var(--cpd-space-6x); +} + +/** + * KINDS + */ + +.cpd-button[data-kind="primary"] { + color: var(--cpd-color-text-on-solid-primary); + background: var(--cpd-color-bg-action-primary-rest); + border-width: 0; +} + +.cpd-button[data-kind="primary"]:hover { + background: var(--cpd-color-bg-action-primary-hovered); +} + +.cpd-button[data-kind="primary"]:active { + background: var(--cpd-color-bg-action-primary-pressed); +} + +.cpd-button[data-kind="primary"][disabled] { + color: var(--cpd-color-text-disabled); + background: var(--cpd-color-bg-subtle-primary); +} + +.cpd-button[data-kind="secondary"] { + border: 1px solid var(--cpd-color-border-interactive-primary); + color: var(--cpd-color-text-primary); + background: var(--cpd-color-bg-canvas-default); +} + +.cpd-button[data-kind="secondary"]:hover { + border-color: var(--cpd-color-border-interactive-hovered); + background: var(--cpd-color-bg-subtle-secondary); +} + +.cpd-button[data-kind="secondary"]:active { + border-color: var(--cpd-color-border-interactive-hovered); + background: var(--cpd-color-bg-subtle-primary); +} + +.cpd-button[data-kind="secondary"][disabled] { + border-color: var(--cpd-color-border-interactive-secondary); + color: var(--cpd-color-text-disabled); + background: var(--cpd-color-bg-subtle-secondary); +} + +.cpd-button[data-kind="tertiary"] { + border: none; + color: var(--cpd-color-text-primary); + text-decoration: underline; + background: transparent; +} + +.cpd-button[data-kind="tertiary"]:hover { + background: var(--cpd-color-bg-subtle-secondary); +} + +.cpd-button[data-kind="tertiary"]:active { + background: var(--cpd-color-bg-subtle-primary); +} + +.cpd-button[data-kind="tertiary"][disabled] { + color: var(--cpd-color-text-disabled); +} + +.cpd-button[data-kind="destructive"] { + border: 1px solid var(--cpd-color-border-critical-primary); + color: var(--cpd-color-text-critical-primary); + background: var(--cpd-color-bg-canvas-default); +} + +.cpd-button[data-kind="destructive"]:hover { + border-color: var(--cpd-color-border-critical-hovered); + background: var(--cpd-color-bg-critical-subtle); +} + +.cpd-button[data-kind="destructive"]:active { + border-color: var(--cpd-color-border-critical-hovered); + background: var(--cpd-color-bg-critical-subtle-hovered); +} + +.cpd-button[data-kind="destructive"][disabled] { + border-color: var(--cpd-color-border-interactive-secondary); + color: var(--cpd-color-text-disabled); + background: var(--cpd-color-bg-subtle-secondary); +} diff --git a/frontend/src/styles/cpd-link.css b/frontend/src/styles/cpd-link.css new file mode 100644 index 00000000..d90135ac --- /dev/null +++ b/frontend/src/styles/cpd-link.css @@ -0,0 +1,51 @@ +/* Copyright 2023 The Matrix.org Foundation C.I.C. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +.cpd-link { + display: inline-block; + text-decoration: underline; + color: var(--cpd-color-text-primary); + font-weight: var(--cpd-font-weight-medium); + border-radius: var(--cpd-radius-pill-effect); + padding-inline: 0.25rem; +} + +.cpd-link[data-kind="primary"] { + color: var(--cpd-color-text-primary); +} + +.cpd-link[data-kind="critical"] { + color: var(--cpd-color-text-critical-primary); +} + +.cpd-link[data-kind="primary"]:hover { + background: var(--cpd-color-gray-300); +} + +.cpd-link[data-kind="critical"]:hover { + background: var(--cpd-color-red-300); +} + +.cpd-link:active { + color: var(--cpd-color-text-on-solid-primary); +} + +.cpd-link[data-kind="primary"]:active { + background: var(--cpd-color-text-primary); +} + +.cpd-link[data-kind="critical"]:active { + background: var(--cpd-color-text-critical-primary); +} \ No newline at end of file diff --git a/frontend/src/templates.css b/frontend/src/templates.css index 43c616b4..843d66a2 100644 --- a/frontend/src/templates.css +++ b/frontend/src/templates.css @@ -19,9 +19,20 @@ @import "@fontsource/inter/700.css"; @import "@vector-im/compound-design-tokens/assets/web/css/compound-design-tokens.css"; @import "@vector-im/compound-web/dist/style.css"; +@import "./styles/cpd-button.css"; +@import "./styles/cpd-link.css"; @config "../tailwind.templates.config.cjs"; @tailwind base; @tailwind components; -@tailwind utilities; \ No newline at end of file +@tailwind utilities; + +body { + /* XXX: I'm unsure why this is not part of the tokens */ + --cpd-radius-pill-effect: 9999px; + + font: var(--cpd-font-body-md-regular); + background: var(--cpd-color-bg-canvas-default); + color: var(--cpd-color-text-primary); +} diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts index 059d6c2b..524c3769 100644 --- a/frontend/vite.config.ts +++ b/frontend/vite.config.ts @@ -36,9 +36,10 @@ export default defineConfig((env) => ({ assetsInlineLimit: 0, sourcemap: true, modulePreload: false, - // We don't handle CSS code splitting well yet, so we disable it for now - // This means we have to load all the CSS through the `style.css` virtual entrypoint - cssCodeSplit: false, + + // We don't exactly handle CSS code splitting well if we're lazy loading components. + // We disabled lazy loading for now, but we should fix this at some point. + cssCodeSplit: true, rollupOptions: { input: [ diff --git a/templates/app.html b/templates/app.html index ea56c1a3..cf40187f 100644 --- a/templates/app.html +++ b/templates/app.html @@ -28,9 +28,9 @@ limitations under the License. const query = window.matchMedia("(prefers-color-scheme: dark)"); function handleChange(list) { if (list.matches) { - document.documentElement.classList.add("dark"); + document.documentElement.classList.add("cpd-theme-dark"); } else { - document.documentElement.classList.remove("dark"); + document.documentElement.classList.remove("cpd-theme-dark"); } } @@ -38,7 +38,6 @@ limitations under the License. handleChange(query); })(); - {{ include_asset(path='style.css') | indent(prefix=" ") | safe }} {{ include_asset(path='src/main.tsx') | indent(prefix=" ") | safe }} diff --git a/templates/base.html b/templates/base.html index 42593abc..a8716e63 100644 --- a/templates/base.html +++ b/templates/base.html @@ -28,10 +28,9 @@ limitations under the License.
This will allow {{ client.client_name | default(value=client.client_id) }} to:
+This will allow {{ client.client_name | default(value=client.client_id) }} to:
{{ scope::list(scopes=grant.scope) }} @@ -44,13 +44,13 @@ limitations under the License. {% if client.policy_uri or client.tos_uri %} Find out how {{ client.client_name }} will handle your data by reviewing it's {% if client.policy_uri %} - privacy policy{% if not client.tos_uri %}.{% endif %} + privacy policy{% if not client.tos_uri %}.{% endif %} {% endif %} {% if client.policy_uri and client.tos_uri%} and {% endif %} {% if client.tos_uri %} - terms of service. + terms of service. {% endif %} {% endif %}
@@ -63,7 +63,7 @@ limitations under the License.