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

z-index 문제로 프로필 이미지가 보이지 않는 문제 수정 #757

Merged
merged 2 commits into from
Oct 24, 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
11 changes: 10 additions & 1 deletion frontend/src/components/KebabMenu/KebabMenu.style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,18 @@ export const kebabContainer = (props: { theme: Theme }) => css`
border-bottom: 1px;
}
`;

export const kebabItem = (props: { theme: Theme }) => css`
white-space: nowrap;
background: ${props.theme.colorPalette.white[100]};
${props.theme.typography.ButtonFont}
border: none;
border-bottom: 1px;
`;

export const optionBox = (props: { theme: Theme }) => css`
position: absolute;
top: 100%;
top: 5rem;
right: 0;

display: flex;
Expand Down
36 changes: 18 additions & 18 deletions frontend/src/components/KebabMenu/KebabMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import * as S from '@_components/KebabMenu/KebabMenu.style';

import { FocusEvent, useRef, useState } from 'react';

import KebabButton from '@_common/assets/kebab_menu.svg';
import { useTheme } from '@emotion/react';
import { createPortal } from 'react-dom'; // createPortal 추가

type Option = { name: string; disabled: boolean; onClick: () => void };
export interface KebabMenuProps {
Expand Down Expand Up @@ -35,6 +34,22 @@ export default function KebabMenu(props: KebabMenuProps) {
onClick();
};

const kebabMenu = isKebabOpen ? (
<div ref={optionsRef} css={S.optionBox({ theme })}>
{options.map((option) => (
<button
css={S.kebabItem({ theme })}
aria-label={option.name}
key={option.name}
onClick={() => handleOptionClick(option.onClick)}
disabled={option.disabled}
>
{option.name}
</button>
))}
</div>
) : null;

return (
<div css={S.kebabContainer({ theme })}>
<button
Expand All @@ -45,22 +60,7 @@ export default function KebabMenu(props: KebabMenuProps) {
>
<KebabButton />
</button>
{isKebabOpen && (
<div ref={optionsRef} css={S.optionBox({ theme })}>
{options.map((option) => {
return (
<button
aria-label={option.name}
key={option.name}
onClick={() => handleOptionClick(option.onClick)}
disabled={option.disabled}
>
{option.name}
</button>
);
})}
</div>
)}
{createPortal(kebabMenu, document.body)} {/* createPortal 사용 */}
</div>
);
}
1 change: 0 additions & 1 deletion frontend/src/components/ProfileFrame/ProfileFrame.style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ type Size = number;
export const profileBox = () => {
return css`
position: relative;
z-index: -1;
`;
};

Expand Down
Loading