-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
닉네임, 제목이 길 때 UI 깨지는 문제
- Loading branch information
Showing
11 changed files
with
118 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { useEffect, useRef, useState } from 'react'; | ||
|
||
export default function useNicknameWidthEffect({ | ||
nickname, | ||
maxNicknameWidth, | ||
}: { | ||
nickname: string; | ||
maxNicknameWidth: number; | ||
}) { | ||
const nicknameRef = useRef<HTMLDivElement>(null); | ||
const [formattedNickname, setFormattedNickname] = useState(nickname); | ||
|
||
useEffect(() => { | ||
const nicknameEl = nicknameRef.current; | ||
if (!nicknameEl) { | ||
return; | ||
} | ||
|
||
const nicknameWidth = nicknameEl.offsetWidth; | ||
if (nicknameWidth > maxNicknameWidth) { | ||
const midpoint = Math.ceil(nickname.length / 2); | ||
const firstPart = nickname.slice(0, midpoint); | ||
const secondPart = nickname.slice(midpoint); | ||
setFormattedNickname(`${firstPart}\n${secondPart}`); | ||
} | ||
}, [nickname, maxNicknameWidth]); | ||
|
||
return { | ||
nicknameRef, | ||
formattedNickname, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 6 additions & 4 deletions
10
frontend/src/pages/Bet/BetDetailPage/components/ProfileList/ProfileCard/ProfileCard.style.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,18 @@ | ||
import { css, Theme } from '@emotion/react'; | ||
|
||
export const ProfileCard = css` | ||
export const profileCard = css` | ||
display: flex; | ||
flex-direction: column; | ||
gap: 0.4rem; | ||
align-items: center; | ||
justify-content: flex-end; | ||
justify-content: flex-start; | ||
width: auto; | ||
width: fit-content; | ||
`; | ||
|
||
export const ProfileName = (props: { theme: Theme }) => css` | ||
${props.theme.typography.s2} | ||
export const profileNickname = (props: { theme: Theme }) => css` | ||
${props.theme.typography.c2} | ||
text-align: center; | ||
white-space: pre-line; | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 7 additions & 4 deletions
11
...end/src/pages/Moim/MoimDetailPage/components/ProfileList/ProfileCard/ProfileCard.style.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,19 @@ | ||
import { css, Theme } from '@emotion/react'; | ||
|
||
export const ProfileCard = css` | ||
export const profileCard = css` | ||
display: flex; | ||
flex-direction: column; | ||
gap: 0.4rem; | ||
align-items: center; | ||
justify-content: flex-end; | ||
justify-content: flex-start; | ||
width: auto; | ||
width: fit-content; | ||
padding-top: 14px; | ||
`; | ||
|
||
export const ProfileName = (props: { theme: Theme }) => css` | ||
${props.theme.typography.s2} | ||
export const profileName = (props: { theme: Theme }) => css` | ||
${props.theme.typography.c2} | ||
text-align: center; | ||
white-space: pre-line; | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters