Skip to content

Commit

Permalink
[#574] FloatingButton 버그 수정 (#577)
Browse files Browse the repository at this point in the history
* setting: tailwind.config에 커스텀 breakpoint(Desktop 430px) 추가

* refactor: FloatingButton 수정

- fixed 적용
- 위치값을 사용부에서 string형식으로 props를 받을 수 있도록 수정

* fix: FloatingButton 버그 수정
  • Loading branch information
hanyugeon authored and gxxrxn committed Jun 17, 2024
1 parent f1c6a3c commit dd37ff5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 23 deletions.
5 changes: 4 additions & 1 deletion src/app/group/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ const GroupPage = () => {
return;
};

const FLOATING_BUTTON_POSITION =
'bottom-[8.3rem] right-[1.7rem] desktop:right-1/2 desktop:translate-x-[19.8rem]';

return (
<>
<TopHeader text="Group" />
Expand All @@ -56,7 +59,7 @@ const GroupPage = () => {
</div>
<FloatingButton
onClick={handleCreateGroupClick}
position="bottom-right"
position={FLOATING_BUTTON_POSITION}
/>
</>
);
Expand Down
25 changes: 3 additions & 22 deletions src/v1/base/FloatingButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,38 +5,19 @@ import { IconPlus } from '@public/icons';
import Portal from './Portal';

interface FloatingButtonProps extends ComponentPropsWithoutRef<'button'> {
position: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
position?: string;
onClick?: () => void;
}

const getPositionClasses = (position: string) => {
switch (position) {
case 'top-left': {
return 'top-[1.3rem] left-[1.7rem]';
}
case 'top-right': {
return 'top-[1.3rem] right-[1.7rem]';
}
case 'bottom-left': {
return 'bottom-[8.3rem] left-[1.7rem]';
}
case 'bottom-right': {
return 'bottom-[8.3rem] right-[1.7rem]';
}
}
};

const FloatingButton = ({
position,
onClick,
...props
}: FloatingButtonProps) => {
const positionClasses = getPositionClasses(position);

return (
<Portal id="floating-button-portal">
<Portal id="floating-button-root">
<button
className={`${positionClasses} absolute flex h-[5.1rem] w-[5.1rem] items-center justify-center rounded-full bg-main-900 shadow-floating-button`}
className={`fixed ${position} flex h-[5.1rem] w-[5.1rem] items-center justify-center rounded-full bg-main-900 shadow-floating-button`}
onClick={onClick}
{...props}
>
Expand Down
3 changes: 3 additions & 0 deletions tailwind.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ module.exports = {
],
theme: {
extend: {
screens: {
desktop: '430px',
},
fontSize: {
'2xs': '1.0rem',
xs: '1.2rem',
Expand Down

0 comments on commit dd37ff5

Please sign in to comment.