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

Video tile redesign/refactor #1989

Merged
merged 5 commits into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"@opentelemetry/instrumentation-user-interaction": "^0.34.0",
"@opentelemetry/sdk-trace-web": "^1.9.1",
"@radix-ui/react-dialog": "^1.0.4",
"@radix-ui/react-slider": "^1.1.2",
"@radix-ui/react-visually-hidden": "^1.0.3",
"@react-aria/button": "^3.3.4",
"@react-aria/focus": "^3.5.0",
Expand All @@ -49,7 +50,7 @@
"@types/lodash": "^4.14.199",
"@use-gesture/react": "^10.2.11",
"@vector-im/compound-design-tokens": "^0.1.0",
"@vector-im/compound-web": "^0.6.0",
"@vector-im/compound-web": "^1.0.0",
"@vitejs/plugin-basic-ssl": "^1.0.1",
"@vitejs/plugin-react": "^4.0.1",
"buffer": "^6.0.3",
Expand Down
11 changes: 6 additions & 5 deletions public/locales/en-GB/app.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
"home": "Home",
"loading": "Loading…",
"microphone": "Microphone",
"options": "Options",
"password": "Password",
"profile": "Profile",
"settings": "Settings",
Expand All @@ -57,10 +58,8 @@
"video": "Video"
},
"disconnected_banner": "Connectivity to the server has been lost.",
"exit_fullscreen_button_label": "Exit full screen",
"full_screen_view_description": "<0>Submitting debug logs will help us track down the problem.</0>",
"full_screen_view_h1": "<0>Oops, something's gone wrong.</0>",
"fullscreen_button_label": "Full screen",
"group_call_loader_failed_heading": "Call not found",
"group_call_loader_failed_text": "Calls are now end-to-end encrypted and need to be created from the home page. This helps make sure everyone's using the same encryption key.",
"hangup_button_label": "End call",
Expand All @@ -81,7 +80,6 @@
"join_button": "Join call",
"leave_button": "Back to recents"
},
"local_volume_label": "Local volume",
"log_in": "Log In",
"logging_in": "Logging in…",
"login_auth_links": "<0>Create an account</0> Or <2>Access as a guest</2>",
Expand Down Expand Up @@ -145,8 +143,11 @@
"unmute_microphone_button_label": "Unmute microphone",
"version": "Version: {{version}}",
"video_tile": {
"presenter_label": "{{displayName}} is presenting",
"sfu_participant_local": "You"
"exit_full_screen": "Exit full screen",
"full_screen": "Full screen",
"mute_for_me": "Mute for me",
"sfu_participant_local": "You",
"volume": "Volume"
},
"waiting_for_participants": "Waiting for other participants…"
}
2 changes: 0 additions & 2 deletions src/Overlay.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ limitations under the License.

.bg {
position: fixed;
z-index: 100;
inset: 0;
background: rgba(3, 12, 27, 0.528);
}
Expand Down Expand Up @@ -49,7 +48,6 @@ limitations under the License.

.overlay {
position: fixed;
z-index: 101;
}

.overlay.animate {
Expand Down
66 changes: 66 additions & 0 deletions src/Slider.module.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/*
Copyright 2023 New Vector Ltd

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.
*/

.slider {
display: flex;
align-items: center;
position: relative;
}

.track {
flex-grow: 1;
border-radius: var(--cpd-radius-pill-effect);
background: var(--cpd-color-bg-subtle-primary);
height: var(--cpd-space-2x);
outline: var(--cpd-border-width-1) solid
var(--cpd-color-border-interactive-primary);
outline-offset: calc(-1 * var(--cpd-border-width-1));
cursor: pointer;
transition: outline-color ease 0.15s;
}

.track[data-disabled] {
cursor: initial;
outline-color: var(--cpd-color-border-disabled);
}

.highlight {
background: var(--cpd-color-bg-action-primary-rest);
position: absolute;
block-size: 100%;
border-radius: var(--cpd-radius-pill-effect);
transition: background-color ease 0.15s;
}

.highlight[data-disabled] {
background: var(--cpd-color-bg-action-primary-disabled);
}

.handle {
display: block;
block-size: var(--cpd-space-4x);
inline-size: var(--cpd-space-4x);
border-radius: var(--cpd-radius-pill-effect);
background: var(--cpd-color-bg-action-primary-rest);
box-shadow: 0 0 0 2px var(--cpd-color-bg-canvas-default);
cursor: pointer;
transition: background-color ease 0.15s;
}

.handle[data-disabled] {
cursor: initial;
background: var(--cpd-color-bg-action-primary-disabled);
}
68 changes: 68 additions & 0 deletions src/Slider.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
Copyright 2023 New Vector Ltd

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.
*/

import { FC, useCallback } from "react";
import { Root, Track, Range, Thumb } from "@radix-ui/react-slider";
import classNames from "classnames";

import styles from "./Slider.module.css";

interface Props {
className?: string;
label: string;
value: number;
onValueChange: (value: number) => void;
min: number;
max: number;
step: number;
disabled?: boolean;
}

/**
* A slider control allowing a value to be selected from a range.
*/
export const Slider: FC<Props> = ({
className,
label,
value,
onValueChange: onValueChangeProp,
min,
max,
step,
disabled,
}) => {
const onValueChange = useCallback(
([v]: number[]) => onValueChangeProp(v),
[onValueChangeProp],
);

return (
<Root
className={classNames(className, styles.slider)}
value={[value]}
onValueChange={onValueChange}
min={min}
max={max}
step={step}
disabled={disabled}
>
<Track className={styles.track}>
<Range className={styles.highlight} />
</Track>
<Thumb className={styles.handle} aria-label={label} />
</Root>
);
};
11 changes: 6 additions & 5 deletions src/UserMenuContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { useHistory, useLocation } from "react-router-dom";

import { useClientLegacy } from "./ClientContext";
import { useProfile } from "./profile/useProfile";
import { SettingsModal } from "./settings/SettingsModal";
import { defaultSettingsTab, SettingsModal } from "./settings/SettingsModal";
import { UserMenu } from "./UserMenu";

interface Props {
Expand All @@ -37,17 +37,17 @@ export const UserMenuContainer: FC<Props> = ({ preventNavigation = false }) => {
[setSettingsModalOpen],
);

const [defaultSettingsTab, setDefaultSettingsTab] = useState<string>();
const [settingsTab, setSettingsTab] = useState(defaultSettingsTab);

const onAction = useCallback(
async (value: string) => {
switch (value) {
case "user":
setDefaultSettingsTab("profile");
setSettingsTab("profile");
setSettingsModalOpen(true);
break;
case "settings":
setDefaultSettingsTab("audio");
setSettingsTab("audio");
setSettingsModalOpen(true);
break;
case "logout":
Expand Down Expand Up @@ -76,9 +76,10 @@ export const UserMenuContainer: FC<Props> = ({ preventNavigation = false }) => {
{client && (
<SettingsModal
client={client}
defaultTab={defaultSettingsTab}
open={settingsModalOpen}
onDismiss={onDismissSettingsModal}
tab={settingsTab}
onTabChange={setSettingsTab}
/>
)}
</>
Expand Down
45 changes: 0 additions & 45 deletions src/button/Button.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,6 @@ import SettingsSolidIcon from "@vector-im/compound-design-tokens/icons/settings-
import ChevronDownIcon from "@vector-im/compound-design-tokens/icons/chevron-down.svg?react";

import styles from "./Button.module.css";
import Fullscreen from "../icons/Fullscreen.svg?react";
import FullscreenExit from "../icons/FullscreenExit.svg?react";
import { VolumeIcon } from "./VolumeIcon";

export type ButtonVariant =
| "default"
Expand Down Expand Up @@ -233,45 +230,3 @@ export const SettingsButton: FC<{
</Tooltip>
);
};

interface AudioButtonProps extends Omit<Props, "variant"> {
/**
* A number between 0 and 1
*/
volume: number;
}

export const AudioButton: FC<AudioButtonProps> = ({ volume, ...rest }) => {
const { t } = useTranslation();

return (
<Tooltip label={t("local_volume_label")}>
<Button variant="icon" {...rest}>
<VolumeIcon volume={volume} aria-label={t("local_volume_label")} />
</Button>
</Tooltip>
);
};

interface FullscreenButtonProps extends Omit<Props, "variant"> {
fullscreen?: boolean;
}

export const FullscreenButton: FC<FullscreenButtonProps> = ({
fullscreen,
...rest
}) => {
const { t } = useTranslation();
const Icon = fullscreen ? FullscreenExit : Fullscreen;
const label = fullscreen
? t("exit_fullscreen_button_label")
: t("fullscreen_button_label");

return (
<Tooltip label={label}>
<Button variant="icon" {...rest}>
<Icon aria-label={label} />
</Button>
</Tooltip>
);
};
35 changes: 0 additions & 35 deletions src/button/VolumeIcon.tsx

This file was deleted.

4 changes: 0 additions & 4 deletions src/icons/AudioLow.svg

This file was deleted.

3 changes: 0 additions & 3 deletions src/icons/AudioMuted.svg

This file was deleted.

3 changes: 0 additions & 3 deletions src/icons/Fullscreen.svg

This file was deleted.

3 changes: 0 additions & 3 deletions src/icons/FullscreenExit.svg

This file was deleted.

3 changes: 3 additions & 0 deletions src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,9 @@ body,
#root {
display: flex;
flex-direction: column;
/* The root should be a separate stacking context so that portalled elements
like modals and menus always appear over top of it */
isolation: isolate;
}

/* On Android and iOS, prefer native system fonts. The global.css file of
Expand Down
Loading