Replace LayoutToggle with compound-web Switch component
This commit is contained in:
+1
-1
@@ -81,7 +81,7 @@
|
|||||||
"@typescript-eslint/parser": "^8.31.0",
|
"@typescript-eslint/parser": "^8.31.0",
|
||||||
"@use-gesture/react": "^10.2.11",
|
"@use-gesture/react": "^10.2.11",
|
||||||
"@vector-im/compound-design-tokens": "^10.0.0",
|
"@vector-im/compound-design-tokens": "^10.0.0",
|
||||||
"@vector-im/compound-web": "^9.0.0",
|
"@vector-im/compound-web": "element-hq/compound-web#e7c91ef18e20f2fc70069696f4414018361ac512",
|
||||||
"@vitejs/plugin-react": "^4.0.1",
|
"@vitejs/plugin-react": "^4.0.1",
|
||||||
"@vitest/coverage-v8": "^4.0.18",
|
"@vitest/coverage-v8": "^4.0.18",
|
||||||
"babel-plugin-transform-vite-meta-env": "^1.0.3",
|
"babel-plugin-transform-vite-meta-env": "^1.0.3",
|
||||||
|
|||||||
Generated
+6
-5
@@ -150,8 +150,8 @@ importers:
|
|||||||
specifier: ^10.0.0
|
specifier: ^10.0.0
|
||||||
version: 10.1.0(@types/react@19.2.14)(react@19.2.5)
|
version: 10.1.0(@types/react@19.2.14)(react@19.2.5)
|
||||||
'@vector-im/compound-web':
|
'@vector-im/compound-web':
|
||||||
specifier: ^9.0.0
|
specifier: element-hq/compound-web#e7c91ef18e20f2fc70069696f4414018361ac512
|
||||||
version: 9.2.0(@fontsource/inconsolata@5.2.8)(@fontsource/inter@5.2.8)(@types/react-dom@19.2.3(@types/react@19.2.14))(@types/react@19.2.14)(@vector-im/compound-design-tokens@10.1.0(@types/react@19.2.14)(react@19.2.5))(react-dom@19.2.5(react@19.2.5))(react@19.2.5)
|
version: https://codeload.github.com/element-hq/compound-web/tar.gz/e7c91ef18e20f2fc70069696f4414018361ac512(@fontsource/inconsolata@5.2.8)(@fontsource/inter@5.2.8)(@types/react-dom@19.2.3(@types/react@19.2.14))(@types/react@19.2.14)(@vector-im/compound-design-tokens@10.1.0(@types/react@19.2.14)(react@19.2.5))(react-dom@19.2.5(react@19.2.5))(react@19.2.5)
|
||||||
'@vitejs/plugin-react':
|
'@vitejs/plugin-react':
|
||||||
specifier: ^4.0.1
|
specifier: ^4.0.1
|
||||||
version: 4.7.0(vite@8.0.8(@types/node@24.12.2)(esbuild@0.27.7)(jiti@2.6.1)(sass@1.99.0)(terser@5.46.1)(yaml@2.8.3))
|
version: 4.7.0(vite@8.0.8(@types/node@24.12.2)(esbuild@0.27.7)(jiti@2.6.1)(sass@1.99.0)(terser@5.46.1)(yaml@2.8.3))
|
||||||
@@ -3037,8 +3037,9 @@ packages:
|
|||||||
react:
|
react:
|
||||||
optional: true
|
optional: true
|
||||||
|
|
||||||
'@vector-im/compound-web@9.2.0':
|
'@vector-im/compound-web@https://codeload.github.com/element-hq/compound-web/tar.gz/e7c91ef18e20f2fc70069696f4414018361ac512':
|
||||||
resolution: {integrity: sha512-jHbABGEQ2yqNtm5xRIkklQs198VEfSk9AJQolI+e4WSJ0xg8Ozyv9t9KIuKQAmjdSV9aow5G6hDE861XB6DQgw==}
|
resolution: {tarball: https://codeload.github.com/element-hq/compound-web/tar.gz/e7c91ef18e20f2fc70069696f4414018361ac512}
|
||||||
|
version: 9.2.1
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
'@fontsource/inconsolata': ^5
|
'@fontsource/inconsolata': ^5
|
||||||
'@fontsource/inter': ^5
|
'@fontsource/inter': ^5
|
||||||
@@ -9473,7 +9474,7 @@ snapshots:
|
|||||||
'@types/react': 19.2.14
|
'@types/react': 19.2.14
|
||||||
react: 19.2.5
|
react: 19.2.5
|
||||||
|
|
||||||
'@vector-im/compound-web@9.2.0(@fontsource/inconsolata@5.2.8)(@fontsource/inter@5.2.8)(@types/react-dom@19.2.3(@types/react@19.2.14))(@types/react@19.2.14)(@vector-im/compound-design-tokens@10.1.0(@types/react@19.2.14)(react@19.2.5))(react-dom@19.2.5(react@19.2.5))(react@19.2.5)':
|
'@vector-im/compound-web@https://codeload.github.com/element-hq/compound-web/tar.gz/e7c91ef18e20f2fc70069696f4414018361ac512(@fontsource/inconsolata@5.2.8)(@fontsource/inter@5.2.8)(@types/react-dom@19.2.3(@types/react@19.2.14))(@types/react@19.2.14)(@vector-im/compound-design-tokens@10.1.0(@types/react@19.2.14)(react@19.2.5))(react-dom@19.2.5(react@19.2.5))(react@19.2.5)':
|
||||||
dependencies:
|
dependencies:
|
||||||
'@floating-ui/react': 0.27.19(react-dom@19.2.5(react@19.2.5))(react@19.2.5)
|
'@floating-ui/react': 0.27.19(react-dom@19.2.5(react@19.2.5))(react@19.2.5)
|
||||||
'@fontsource/inconsolata': 5.2.8
|
'@fontsource/inconsolata': 5.2.8
|
||||||
|
|||||||
@@ -8,6 +8,12 @@ Please see LICENSE in the repository root for full details.
|
|||||||
import { type FC, type JSX, type Ref, useMemo } from "react";
|
import { type FC, type JSX, type Ref, useMemo } from "react";
|
||||||
import classNames from "classnames";
|
import classNames from "classnames";
|
||||||
import { BehaviorSubject } from "rxjs";
|
import { BehaviorSubject } from "rxjs";
|
||||||
|
import { Switch } from "@vector-im/compound-web";
|
||||||
|
import { t } from "i18next";
|
||||||
|
import {
|
||||||
|
SpotlightIcon,
|
||||||
|
GridIcon,
|
||||||
|
} from "@vector-im/compound-design-tokens/assets/web/icons";
|
||||||
|
|
||||||
import LogoMark from "../icons/LogoMark.svg?react";
|
import LogoMark from "../icons/LogoMark.svg?react";
|
||||||
import LogoType from "../icons/LogoType.svg?react";
|
import LogoType from "../icons/LogoType.svg?react";
|
||||||
@@ -23,7 +29,6 @@ import {
|
|||||||
type ReactionData,
|
type ReactionData,
|
||||||
} from "../button";
|
} from "../button";
|
||||||
import styles from "./CallFooter.module.css";
|
import styles from "./CallFooter.module.css";
|
||||||
import { LayoutToggle } from "../room/LayoutToggle";
|
|
||||||
import { type GridMode } from "../state/CallViewModel/CallViewModel";
|
import { type GridMode } from "../state/CallViewModel/CallViewModel";
|
||||||
|
|
||||||
export interface AudioOutputSwitcher {
|
export interface AudioOutputSwitcher {
|
||||||
@@ -232,10 +237,16 @@ export const CallFooter: FC<FooterProps> = ({
|
|||||||
</div>
|
</div>
|
||||||
{!hideControls && <div className={styles.buttons}>{buttons}</div>}
|
{!hideControls && <div className={styles.buttons}>{buttons}</div>}
|
||||||
{setLayoutMode && layoutMode && showLayoutSwitcher && (
|
{setLayoutMode && layoutMode && showLayoutSwitcher && (
|
||||||
<LayoutToggle
|
<Switch
|
||||||
|
leftLabel={t("layout_spotlight_label")}
|
||||||
|
leftValue="spotlight"
|
||||||
|
leftIcon={SpotlightIcon}
|
||||||
|
rightLabel={t("layout_grid_label")}
|
||||||
|
rightValue="grid"
|
||||||
|
rightIcon={GridIcon}
|
||||||
className={styles.layout}
|
className={styles.layout}
|
||||||
layout={layoutMode}
|
value={layoutMode}
|
||||||
setLayout={setLayoutMode}
|
onChange={setLayoutMode}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,79 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 2023, 2024 New Vector Ltd.
|
|
||||||
|
|
||||||
SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
|
||||||
Please see LICENSE in the repository root for full details.
|
|
||||||
*/
|
|
||||||
|
|
||||||
.toggle {
|
|
||||||
padding: 2px;
|
|
||||||
border: 1px solid var(--cpd-color-border-interactive-secondary);
|
|
||||||
border-radius: var(--cpd-radius-pill-effect);
|
|
||||||
background: var(--cpd-color-bg-canvas-default);
|
|
||||||
display: flex;
|
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
|
|
||||||
.toggle input {
|
|
||||||
appearance: none;
|
|
||||||
/* Safari puts a margin on these, which is not removed via appearance: none */
|
|
||||||
margin: 0;
|
|
||||||
block-size: var(--cpd-space-11x);
|
|
||||||
inline-size: var(--cpd-space-11x);
|
|
||||||
cursor: pointer;
|
|
||||||
border-radius: var(--cpd-radius-pill-effect);
|
|
||||||
background: var(--cpd-color-bg-action-secondary-rest);
|
|
||||||
box-shadow: var(--small-drop-shadow);
|
|
||||||
transition: background-color 0.1s;
|
|
||||||
}
|
|
||||||
|
|
||||||
.toggle svg {
|
|
||||||
display: block;
|
|
||||||
position: absolute;
|
|
||||||
padding: calc(2.5 * var(--cpd-space-1x));
|
|
||||||
pointer-events: none;
|
|
||||||
color: var(--cpd-color-icon-primary);
|
|
||||||
transition: color 0.1s;
|
|
||||||
}
|
|
||||||
|
|
||||||
.toggle svg:nth-child(2) {
|
|
||||||
inset-inline-start: 2px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.toggle svg:nth-child(4) {
|
|
||||||
inset-inline-end: 2px;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (hover: hover) {
|
|
||||||
.toggle input:hover {
|
|
||||||
background: var(--cpd-color-bg-action-secondary-hovered);
|
|
||||||
box-shadow: none;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.toggle input:active {
|
|
||||||
background: var(--cpd-color-bg-action-secondary-pressed);
|
|
||||||
box-shadow: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.toggle input:checked {
|
|
||||||
background: var(--cpd-color-bg-action-primary-rest);
|
|
||||||
}
|
|
||||||
|
|
||||||
.toggle input:checked + svg {
|
|
||||||
color: var(--cpd-color-icon-on-solid-primary);
|
|
||||||
}
|
|
||||||
|
|
||||||
@media (hover: hover) {
|
|
||||||
.toggle input:checked:hover {
|
|
||||||
background: var(--cpd-color-bg-action-primary-hovered);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.toggle input:checked:active {
|
|
||||||
background: var(--cpd-color-bg-action-primary-pressed);
|
|
||||||
}
|
|
||||||
|
|
||||||
.toggle input:first-child {
|
|
||||||
margin-inline-end: 5px;
|
|
||||||
}
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 2026 Element Creations Ltd.
|
|
||||||
|
|
||||||
SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
|
||||||
Please see LICENSE in the repository root for full details.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import { fn } from "storybook/test";
|
|
||||||
|
|
||||||
import type { Meta, StoryObj } from "@storybook/react-vite";
|
|
||||||
import { LayoutToggle } from "./LayoutToggle";
|
|
||||||
|
|
||||||
const meta = {
|
|
||||||
component: LayoutToggle,
|
|
||||||
} satisfies Meta<typeof LayoutToggle>;
|
|
||||||
|
|
||||||
export default meta;
|
|
||||||
type Story = StoryObj<typeof meta>;
|
|
||||||
|
|
||||||
export const Default: Story = {
|
|
||||||
args: {
|
|
||||||
layout: "grid",
|
|
||||||
setLayout: fn(),
|
|
||||||
},
|
|
||||||
};
|
|
||||||
@@ -1,59 +0,0 @@
|
|||||||
/*
|
|
||||||
Copyright 2023, 2024 New Vector Ltd.
|
|
||||||
|
|
||||||
SPDX-License-Identifier: AGPL-3.0-only OR LicenseRef-Element-Commercial
|
|
||||||
Please see LICENSE in the repository root for full details.
|
|
||||||
*/
|
|
||||||
|
|
||||||
import { type ChangeEvent, type FC, useCallback } from "react";
|
|
||||||
import { useTranslation } from "react-i18next";
|
|
||||||
import { Tooltip } from "@vector-im/compound-web";
|
|
||||||
import {
|
|
||||||
SpotlightIcon,
|
|
||||||
GridIcon,
|
|
||||||
} from "@vector-im/compound-design-tokens/assets/web/icons";
|
|
||||||
import classNames from "classnames";
|
|
||||||
|
|
||||||
import styles from "./LayoutToggle.module.css";
|
|
||||||
|
|
||||||
export type Layout = "spotlight" | "grid";
|
|
||||||
|
|
||||||
type Props = {
|
|
||||||
layout: Layout;
|
|
||||||
setLayout: (layout: Layout) => void;
|
|
||||||
className?: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
export const LayoutToggle: FC<Props> = ({ layout, setLayout, className }) => {
|
|
||||||
const { t } = useTranslation();
|
|
||||||
|
|
||||||
const onChange = useCallback(
|
|
||||||
(e: ChangeEvent<HTMLInputElement>) => setLayout(e.target.value as Layout),
|
|
||||||
[setLayout],
|
|
||||||
);
|
|
||||||
|
|
||||||
return (
|
|
||||||
<form className={classNames(styles.toggle, className)}>
|
|
||||||
<Tooltip label={t("layout_spotlight_label")}>
|
|
||||||
<input
|
|
||||||
type="radio"
|
|
||||||
name="layout"
|
|
||||||
value="spotlight"
|
|
||||||
checked={layout === "spotlight"}
|
|
||||||
onChange={onChange}
|
|
||||||
/>
|
|
||||||
</Tooltip>
|
|
||||||
<SpotlightIcon aria-hidden width={24} height={24} />
|
|
||||||
<Tooltip label={t("layout_grid_label")}>
|
|
||||||
<input
|
|
||||||
type="radio"
|
|
||||||
name="layout"
|
|
||||||
value="grid"
|
|
||||||
checked={layout === "grid"}
|
|
||||||
onChange={onChange}
|
|
||||||
/>
|
|
||||||
</Tooltip>
|
|
||||||
<GridIcon aria-hidden width={24} height={24} />
|
|
||||||
</form>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
Reference in New Issue
Block a user