Skip to content

Conversation

OscarFava
Copy link
Contributor

What is this PR doing?

This PR is adding the capability to add custom images that will be used to replace the background of the publisher.

How should this be manually tested?

What are the relevant tickets?

A maintainer will add this ticket number.

Resolves VIDSOL-105

Checklist

[ ] Branch is based on develop (not main).
[ ] Resolves a Known Issue.
[ ] If yes, did you remove the item from the docs/KNOWN_ISSUES.md?
[ ] Resolves an item reported in Issues.
If yes, which issue? Issue Number?

@OscarFava OscarFava changed the title Tabs layout VIDSOL-105: Background Replacement Support for Web VERA - Custom Images Aug 6, 2025
Base automatically changed from vidsol-105/background-replacement to develop August 19, 2025 09:56
Copy link

Copy link
Contributor

@behei-vonage behei-vonage left a comment

Choose a reason for hiding this comment

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

great job on this PR! left a few comments and suggestions, thanks 🙏

expect(await screen.findByText(/Image must be less than 2MB/i)).toBeInTheDocument();
});

it('calls customBackgroundImageChange on valid file upload', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I think the name of the test is too literal. could we change it to something more generic?

}));

describe('AddBackgroundEffectLayout', () => {
it('should render without crashing', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: I think we can just say should render

import FileUploader from '../../FileUploader/FileUploader';

export type AddBackgroundEffectLayoutProps = {
customBackgroundImageChange: (param1: string) => void;
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: can we change the name param1 to something else? something like dataUrl?

const AddBackgroundEffectLayout = ({
customBackgroundImageChange,
}: AddBackgroundEffectLayoutProps): ReactElement => {
const MAX_SIZE_MB = 2;
Copy link
Contributor

Choose a reason for hiding this comment

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

could this be moved to the constants file and be imported here instead?

Comment on lines +33 to +35
const [fileError, setFileError] = useState('');
const [imageLink, setImageLink] = useState('');
const [linkLoading, setLinkLoading] = useState(false);
Copy link
Contributor

Choose a reason for hiding this comment

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

could you specify the types i.e useState<string> and useState<boolean>?

expect(handleFileChange).toHaveBeenCalled();
});

it('calls handleFileChange on drop', () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: the name of the test is too literal

const [backgroundSelected, setBackgroundSelected] = useState<string>('none');
const isShortScreen = useMediaQuery('(max-height:825px)');
Copy link
Contributor

Choose a reason for hiding this comment

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

looks like we use the useMediaQuery in a few places in this PR and otherwise. any chance that useIsSmallViewport can be renamed and changed to be re-used in these cases?

Comment on lines +78 to +80
toggleBackgroundEffects={() => {
toggleBackgroundEffects();
handleToggle();
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: it could be nice adding a new function, handleToggletBackgroundEffects that has toggleBackgroundEffects() and handleToggle() in it

* Custom hook for managing image storage in localStorage.
* @returns {object} - The image storage methods and error state.
*/
export const useImageStorage = () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

could you use the const useImageStorage = () => {} and export default useImageStorage approach that we do in other files?

import { useCallback, useState } from 'react';
import { getStorageItem, setStorageItem, STORAGE_KEYS } from '../storage';

const MAX_LOCAL_STORAGE_BYTES = 4 * 1024 * 1024;
Copy link
Contributor

Choose a reason for hiding this comment

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

this can go to the constants file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants