Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
4ee8245
Add video effects items as ui components with story
JamesBurnside Mar 1, 2023
cf3a51b
update styles being applied
JamesBurnside Mar 1, 2023
1eb3c47
update api files
JamesBurnside Mar 1, 2023
d144bd3
Change files
JamesBurnside Mar 1, 2023
329ed8d
Duplicate change files for beta release
JamesBurnside Mar 1, 2023
bcf03ee
add keys
JamesBurnside Mar 1, 2023
0f8eb9e
Add background picker component
JamesBurnside Mar 1, 2023
b404553
Change files
JamesBurnside Mar 1, 2023
200600c
Duplicate change files for beta release
JamesBurnside Mar 1, 2023
f8ca7aa
remove unused import
JamesBurnside Mar 2, 2023
626ed53
Merge branch 'main' into jaburnsi/background-video-effects-option
dmceachernmsft Mar 2, 2023
442935f
update with PR comments
JamesBurnside Mar 2, 2023
5b40a79
Add controlled component warning
JamesBurnside Mar 3, 2023
439b971
update api files
JamesBurnside Mar 3, 2023
21df880
Merge remote-tracking branch 'origin/jaburnsi/background-video-effect…
JamesBurnside Mar 3, 2023
b1376b1
update snippet imports
JamesBurnside Mar 3, 2023
fe20d40
remove confusing props
JamesBurnside Mar 7, 2023
5e22ac2
remove confusing props
JamesBurnside Mar 7, 2023
b06d8d2
Merge remote-tracking branch 'origin/main' into jaburnsi/background-v…
JamesBurnside Mar 7, 2023
7c6d15f
Merge remote-tracking branch 'origin/jaburnsi/background-video-effect…
JamesBurnside Mar 7, 2023
544838d
Merge remote-tracking branch 'origin/main' into jaburnsi/video-backgr…
JamesBurnside Mar 7, 2023
5ac9ba2
update beta api
JamesBurnside Mar 7, 2023
b2ab508
Merge branch 'main' into jaburnsi/video-background-effects-picker
JamesBurnside Mar 10, 2023
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "Add Video background effects picker component",
"packageName": "@azure/communication-react",
"email": "2684369+JamesBurnside@users.noreply.github.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "Add video background effect choice items for upcoming background picker",
"packageName": "@azure/communication-react",
"email": "2684369+JamesBurnside@users.noreply.github.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "Add Video background effects picker component",
"packageName": "@azure/communication-react",
"email": "2684369+JamesBurnside@users.noreply.github.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "prerelease",
"comment": "Add video background effect choice items for upcoming background picker",
"packageName": "@azure/communication-react",
"email": "2684369+JamesBurnside@users.noreply.github.com",
"dependentChangeType": "patch"
}
60 changes: 60 additions & 0 deletions packages/react-components/review/beta/react-components.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { IRenderFunction } from '@fluentui/react';
import { IStyle } from '@fluentui/react';
import { IStyleFunctionOrObject } from '@fluentui/react';
import { ITextFieldStyles } from '@fluentui/react';
import { ITooltipHostProps } from '@fluentui/react';
import { MessageStatus } from '@internal/acs-ui-common';
import { PartialTheme } from '@fluentui/react';
import { PersonaPresence } from '@fluentui/react';
Expand Down Expand Up @@ -1652,6 +1653,65 @@ export const _usePermissions: () => _Permissions;
// @public
export const useTheme: () => Theme;

// @internal
export type _VideoBackgroundEffectChoiceOption = _VideoEffectsItemProps;

// @internal
export const _VideoBackgroundEffectsPicker: (props: _VideoBackgroundEffectsPickerProps) => JSX.Element;

// @internal
export interface _VideoBackgroundEffectsPickerProps {
itemsPerRow?: 'wrap' | number;
label?: string;
onChange?: (effectKey: string) => void;
options: _VideoBackgroundEffectChoiceOption[];
selectedEffectKey?: string;
styles?: _VideoBackgroundEffectsPickerStyles;
}

// @internal
export interface _VideoBackgroundEffectsPickerStyles {
label?: IStyle;
root?: IStyle;
rowRoot?: IStyle;
}

// @internal
export const _VideoEffectsItem: (props: _VideoEffectsItemProps) => JSX.Element;

// @internal
export const _VideoEffectsItemAddImage: (props: _VideoEffectsItemProps) => JSX.Element;

// @internal
export const _VideoEffectsItemBlur: (props: _VideoEffectsItemProps) => JSX.Element;

// @internal
export const _VideoEffectsItemNone: (props: _VideoEffectsItemProps) => JSX.Element;

// @internal
export interface _VideoEffectsItemProps {
backgroundProps?: {
url: string;
position?: string;
size?: string;
};
disabled?: boolean;
iconProps?: IIconProps;
isSelected?: boolean;
key: string;
onSelect?: (key: string) => void;
styles?: _VideoEffectsItemStyles;
title?: string;
tooltipProps?: ITooltipHostProps;
}

// @internal
export interface _VideoEffectsItemStyles {
iconContainer: IStyle;
root: IStyle;
textContainer: IStyle;
}

// @public
export const VideoGallery: (props: VideoGalleryProps) => JSX.Element;

Expand Down
60 changes: 60 additions & 0 deletions packages/react-components/review/stable/react-components.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { IRenderFunction } from '@fluentui/react';
import { IStyle } from '@fluentui/react';
import { IStyleFunctionOrObject } from '@fluentui/react';
import { ITextFieldStyles } from '@fluentui/react';
import { ITooltipHostProps } from '@fluentui/react';
import { MessageStatus } from '@internal/acs-ui-common';
import { PartialTheme } from '@fluentui/react';
import { PersonaPresence } from '@fluentui/react';
Expand Down Expand Up @@ -1398,6 +1399,65 @@ export const _useContainerWidth: (containerRef: RefObject<HTMLElement>) => numbe
// @public
export const useTheme: () => Theme;

// @internal
export type _VideoBackgroundEffectChoiceOption = _VideoEffectsItemProps;

// @internal
export const _VideoBackgroundEffectsPicker: (props: _VideoBackgroundEffectsPickerProps) => JSX.Element;

// @internal
export interface _VideoBackgroundEffectsPickerProps {
itemsPerRow?: 'wrap' | number;
label?: string;
onChange?: (effectKey: string) => void;
options: _VideoBackgroundEffectChoiceOption[];
selectedEffectKey?: string;
styles?: _VideoBackgroundEffectsPickerStyles;
}

// @internal
export interface _VideoBackgroundEffectsPickerStyles {
label?: IStyle;
root?: IStyle;
rowRoot?: IStyle;
}

// @internal
export const _VideoEffectsItem: (props: _VideoEffectsItemProps) => JSX.Element;

// @internal
export const _VideoEffectsItemAddImage: (props: _VideoEffectsItemProps) => JSX.Element;

// @internal
export const _VideoEffectsItemBlur: (props: _VideoEffectsItemProps) => JSX.Element;

// @internal
export const _VideoEffectsItemNone: (props: _VideoEffectsItemProps) => JSX.Element;

// @internal
export interface _VideoEffectsItemProps {
backgroundProps?: {
url: string;
position?: string;
size?: string;
};
disabled?: boolean;
iconProps?: IIconProps;
isSelected?: boolean;
key: string;
onSelect?: (key: string) => void;
styles?: _VideoEffectsItemStyles;
title?: string;
tooltipProps?: ITooltipHostProps;
}

// @internal
export interface _VideoEffectsItemStyles {
iconContainer: IStyle;
root: IStyle;
textContainer: IStyle;
}

// @public
export const VideoGallery: (props: VideoGalleryProps) => JSX.Element;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

import React from 'react';
import { _VideoEffectsItem, _VideoEffectsItemProps } from './VideoEffectsItem';

/**
* 'None' Video Effects Item.
*
* @internal
*/
export const _VideoEffectsItemNone = (props: _VideoEffectsItemProps): JSX.Element => {
const iconProps = props.iconProps ?? {
iconName: 'VideoEffectsNone'
};
const title = props.title ?? 'None';
const tooltipProps = props.tooltipProps ?? {
content: props.title ?? 'Remove Background'
};

return <_VideoEffectsItem {...props} iconProps={iconProps} title={title} tooltipProps={tooltipProps} />;
};

/**
* 'Blur' Video Effects Item.
*
* @internal
*/
export const _VideoEffectsItemBlur = (props: _VideoEffectsItemProps): JSX.Element => {
const iconProps = props.iconProps ?? {
iconName: 'VideoEffectsBlur'
};
const title = props.title ?? 'Blurred';
const tooltipProps = props.tooltipProps ?? {
content: props.title ?? 'Blur Background'
};

return <_VideoEffectsItem {...props} iconProps={iconProps} title={title} tooltipProps={tooltipProps} />;
};

/**
* 'Add Image' Video Effects Item.
*
* @internal
*/
export const _VideoEffectsItemAddImage = (props: _VideoEffectsItemProps): JSX.Element => {
const iconProps = props.iconProps ?? {
iconName: 'VideoEffectsAddImage'
};
const title = props.title ?? 'Image';
const tooltipProps = props.tooltipProps ?? {
content: props.title ?? 'Upload Background Image'
};

return <_VideoEffectsItem {...props} iconProps={iconProps} title={title} tooltipProps={tooltipProps} />;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT license.

import { IStyle, Label, mergeStyles, Stack } from '@fluentui/react';
import React from 'react';
import { chunk } from '../utils';
import { _VideoEffectsItem, _VideoEffectsItemProps } from './VideoEffectsItem';

/**
* Props for {@link _VideoBackgroundEffectsPicker}
* @internal
*/
export interface _VideoBackgroundEffectsPickerProps {
/**
* The options to display in the picker.
*/
options: _VideoBackgroundEffectChoiceOption[];

/**
* The key of the current selected Video Background Effect.
* If you provide this, you must maintain selection state by observing onChange events and passing a new value in when changed.
*/
selectedEffectKey?: string;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice controlled component concept such that if this is not defined the component will manage the state but if defined the user must manage the state through the onChange event.


/**
* Callback to invoke when a Video Background Effect is selected.
* @param effectKey - The key of the Video Background Effect that was selected.
*/
onChange?: (effectKey: string) => void;

/**
* The label to display for the picker.
*/
label?: string;

/**
* The number of items to display per row.
* @default 3
*/
itemsPerRow?: 'wrap' | number;

/**
* Styles for the picker.
*/
styles?: _VideoBackgroundEffectsPickerStyles;
}

/**
* Option for the {@link _VideoBackgroundEffectsPicker}.
* @internal
*/
export type _VideoBackgroundEffectChoiceOption = _VideoEffectsItemProps;

/**
* Styles for the {@link _VideoBackgroundEffectsPicker}.
* @internal
*/
export interface _VideoBackgroundEffectsPickerStyles {
/**
* Styles for the root element.
*/
root?: IStyle;

/**
* Styles for the label.
*/
label?: IStyle;

/**
* Styles for the root of each row element.
*/
rowRoot?: IStyle;
}

/**
* Picker for choosing a Video Background Effect.
*
* @remarks
* This functions similar to a radio group of buttons, where the user can select one of the options.
*
* @internal
*/
export const _VideoBackgroundEffectsPicker = (props: _VideoBackgroundEffectsPickerProps): JSX.Element => {
const [componentControlledSelectedEffectKey, setComponentControlledSelectedEffectKey] = React.useState<
string | undefined
>(props.selectedEffectKey);

const selectedEffect = props.selectedEffectKey ?? componentControlledSelectedEffectKey;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the selectedEffect provided is not present/removed should we console warn like when a pinned participant id is not one of the remote participants as shown here?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is an excellent comment! Added. This also pointed me to this: https://github.com/microsoft/fluentui/blob/306fe5e1e38b36e84daf48a23817704416be2bb4/packages/utilities/src/warn/warnControlledUsage.ts#L31. Turns out fluent exports a component for warning against bad controlled component use! It has other warnings too in useWarning and only logs in development mode!

const setSelectedEffect = (selectedEffectKey: string): void => {
setComponentControlledSelectedEffectKey(selectedEffectKey);
props.onChange?.(selectedEffectKey);
};

const convertedOptions: _VideoEffectsItemProps[] = props.options.map((option) => ({
isSelected: option.key === selectedEffect,
onSelect: () => setSelectedEffect(option.key),
...option
}));

const optionsByRow =
props.itemsPerRow === 'wrap' ? [convertedOptions] : chunk(convertedOptions, props.itemsPerRow ?? 3);

return (
<Stack tokens={{ childrenGap: '0.5rem' }}>
<Label className={mergeStyles(props.styles?.label)}>{props.label}</Label>
{optionsByRow.map((options, rowIndex) => (
<Stack
className={mergeStyles(props.styles?.rowRoot)}
wrap={props.itemsPerRow === 'wrap'}
horizontal
key={rowIndex}
tokens={{ childrenGap: '0.5rem' }}
>
{options.map((option) => (
<_VideoEffectsItem {...option} key={option.key} />
))}
</Stack>
))}
</Stack>
);
};
Loading