Skip to content

Commit

Permalink
refactor: change FullScreen functional Components
Browse files Browse the repository at this point in the history
  • Loading branch information
tosaken1116 committed Nov 5, 2023
1 parent fedccce commit 320df61
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 23 deletions.
4 changes: 1 addition & 3 deletions src/components/functional/FullScreen/index.test.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import React from 'react';

import { render, screen, fireEvent } from '@testing-library/react';

import '@testing-library/jest-dom';
Expand Down Expand Up @@ -61,7 +59,7 @@ describe('functional/FullScreen', () => {
);

expect(screen.getByRole('button')).toHaveClass(
'absolute right-0 bottom-0 p-2'
'absolute right-0 bottom-0 p-2 z-50'
);
});
});
34 changes: 14 additions & 20 deletions src/components/functional/FullScreen/index.tsx
Original file line number Diff line number Diff line change
@@ -1,41 +1,35 @@
type Props = {
children: ReactNode;
};
import type { ReactNode } from 'react';

import { Maximize, Minimize } from 'lucide-react';
import { FullScreen as ReactFullScreen } from 'react-full-screen';

import { useFullScreen } from './hook';
type Props = {
children: ReactNode;
};

export const FullScreen: React.FC<Props> = ({ children }) => {
const { handle, handleClick } = useFullScreen();
return (
<div className="relative select-none h-full w-full">
{!handle.active && (
<ReactFullScreen handle={handle} className="relative h-full w-full">
{children}
<button
onClick={handleClick}
className="absolute right-0 bottom-0 z-50"
className="absolute right-0 bottom-0 p-2 z-50"
>
<Maximize
className="dark:text-black text-white shadow-black drop-shadow"
size={36}
/>
</button>
)}
<ReactFullScreen handle={handle} className="relative h-full w-full">
{children}
{handle.active && (
<button
onClick={handleClick}
className="absolute right-0 bottom-0 p-2"
>
{handle.active ? (
<Minimize
className="dark:text-black text-white shadow-black drop-shadow"
size={36}
/>
</button>
)}
) : (
<Maximize
className="dark:text-black text-white shadow-black drop-shadow"
size={36}
/>
)}
</button>
</ReactFullScreen>
</div>
);
Expand Down

0 comments on commit 320df61

Please sign in to comment.