depromeet / ggogeet-client

GgoGeet - ๊ผฌ๊นƒ ์ ‘์–ด ์ „ํ•˜๋Š” ์ด์•ผ๊ธฐ๐Ÿ’Œ
13 stars 2 forks source link

๐Ÿ’„ ํŽธ์ง€ ์ž‘์„ฑ - ์™„๋ฃŒ UI #84

Closed ding-co closed 1 year ago

ding-co commented 1 year ago

๐Ÿ“Ž ์ด์Šˆ๋ฒˆํ˜ธ

๐Ÿ“ƒ ๋ณ€๊ฒฝ์‚ฌํ•ญ

๐Ÿ“Œ ์ค‘์ ์ ์œผ๋กœ ๋ณผ ๋ถ€๋ถ„

๐ŸŽ‡ ์Šคํฌ๋ฆฐ์ƒท

https://user-images.githubusercontent.com/80014673/210162047-fb4e66fb-7358-4b02-b982-5a59dabcb525.mov

๐Ÿ’ซ ๊ธฐํƒ€์‚ฌํ•ญ

โœ” ์ฒดํฌ๋ฆฌ์ŠคํŠธ

ding-co commented 1 year ago

Screenshot 2023-01-01 at 2 42 52 PM

@Dongkyuuuu @numeru @KimGaeun0806

์ด ๋ถ€๋ถ„ ์ž‘์—…ํ•  ๋•Œ ๊ฐœ์ธ์ ์œผ๋กœ ํผ๋ธ”๋ฆฌ์‹ฑ์œผ๋กœ ๋– ์˜ค๋ฅด์ง€ ์•Š์•„์„œ ์‹œ๊ฐ„์ด ์ข€ ๊ฑธ๋ ธ์Šต๋‹ˆ๋‹ค. input์ด focus ๋˜์ง€ ์•Š์•˜์„ ๋•Œ๋Š” ๊ธธ๊ฒŒ ๊ธฐ๋ณธ์ ์ธ width๋ฅผ ๊ฐ€์ง€๊ณ  placeholder๊ฐ€ ์žˆ์œผ๋ฉฐ focus๋ฅผ ํ•˜๋Š” ์ˆœ๊ฐ„ ์ค„์–ด๋“ค์–ด์„œ ํ…์ŠคํŠธ๋ฅผ ์ž…๋ ฅํ•˜๋ฉด ๊ทธ๊ฒƒ์— ๋งž๊ฒŒ ๊ฐ€๋ณ€์ ์œผ๋กœ ๋Š˜์–ด๋‚˜๋Š” ๋””์ž์ธ์ž…๋‹ˆ๋‹ค.

css ๋งŒ์œผ๋กœ๋Š” ์ปจํŠธ๋กค ํ•˜๊ธฐ ์‰ฝ์ง€ ์•Š๋‹ค๊ณ  ์ƒ๊ฐํ•˜์—ฌ ์ปค์Šคํ…€ ํ›…์„ ํ•˜๋‚˜ ๋งŒ๋“ค์—ˆ์Šต๋‹ˆ๋‹ค. (src/components/features/LetterWrite/InputRecipient/Hooks/index.ts - useTextLengthPixel) ํ™”๋ฉด์— ๋ณด์ด์ง€ ์•Š๊ฒŒ span ํƒœ๊ทธ๋ฅผ ํ•˜๋‚˜ ๋งŒ๋“ค์–ด์„œ ๊ทธ span ํƒœ๊ทธ์— ํ…์ŠคํŠธ (์‚ฌ์šฉ์ž๊ฐ€ ์ž…๋ ฅํ•˜๋Š” ํ•œ๋งˆ๋””)๋ฅผ ๋„ฃ์–ด์„œ ๊ทธ ํ…์ŠคํŠธ์˜ offsetWidth๋ฅผ ๊ตฌํ•ฉ๋‹ˆ๋‹ค. ๊ทธ๋Ÿฌ๋ฉด ํ…์ŠคํŠธ์— ๋Œ€ํ•œ width๋ฅผ ๊ตฌํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๊ทธ๋ฆฌ๊ณ  return ํ•  ๋•Œ span์„ ์‚ญ์ œํ•ด์„œ ๋ฌด์ œํ•œ ์ƒ์„ฑ๋˜๋Š” ๊ฒƒ์„ ๋ฐฉ์ง€ํ•ฉ๋‹ˆ๋‹ค. (ํ•˜๋‚˜๋งŒ ์ƒ์„ฑ๋˜๊ณ  ํŽ˜์ด์ง€ ๋ฐ”๋€Œ๋ฉด ์‚ฌ๋ผ์ง)

๊ฐ€๋ณ€์ ์œผ๋กœ ๊ณ ์ • px ๊ฐ™์€ css๋กœ ์ฒ˜๋ฆฌํ•˜๊ธฐ ์• ๋งคํ–ˆ๋˜ ์ ์ด ์˜์–ด๋‚˜ ํ•œ๊ธ€ ๊ฐ™์€ ๊ฒฝ์šฐ ๊ณ ์ •ํญ์— ๋Œ€ํ•œ ๊ธธ์ด๊ฐ€ ์„œ๋กœ ๋‹ฌ๋ผ์„œ js๋กœ width๋ฅผ ๊ณ„์‚ฐํ•œ๋‹ค์Œ css๋กœ ์ฒ˜๋ฆฌํ•˜์˜€์Šต๋‹ˆ๋‹ค.

ํ•˜์ง€๋งŒ width๊ฐ€ ์ •ํ™•ํžˆ ๋งž์ง€ ์•Š๋Š”๋ฐ ์Œ ๋”ฐ์˜ดํ‘œ ์‚ฌ์ด ๊ฐ„๊ฒฉ์ด ๊ธ€์ž ์ˆ˜๊ฐ€ ๋Š˜์–ด๋‚ ์ˆ˜๋ก ์กฐ๊ธˆ ๋ฒŒ์–ด์ง‘๋‹ˆ๋‹ค. ์ด๋Ÿฐ ์ด์Šˆ๊ฐ€ ์žˆ์ง€๋งŒ..

ํ˜น์‹œ ํ•œ๋ฒˆ ๋ณด์‹œ๊ณ  ๋” ์ข‹์€ ๋ฐฉ๋ฒ•์ด๋‚˜ ํ˜„์žฌ width ๊ฐ„๊ฒฉ ๋Š˜์–ด๋‚˜๋Š” ๊ฒƒ์— ๋Œ€ํ•œ ๊ฐœ์„  ๋ฐฉ์•ˆ์ด ์žˆ์œผ์‹œ๋ฉด ๋ง์”€ํ•ด์ฃผ์„ธ์š”!

Dongkyuuuu commented 1 year ago

input focus์ผ๋•Œ width: fit-content ์ฒ˜๋ฆฌ๋Š” ์•ˆ๋˜๋Š” ๊ฑธ๊นŒ์š”?

ding-co commented 1 year ago

input focus์ผ๋•Œ width: fit-content ์ฒ˜๋ฆฌ๋Š” ์•ˆ๋˜๋Š” ๊ฑธ๊นŒ์š”?

ํ•ด๋ดค์—ˆ๋Š”๋ฐ ์ž˜ ์•ˆ๋˜๋”๋ผ๊ตฌ์š”.. input ๊ฐ™์€ ๊ฒฝ์šฐ์—๋Š” ์ƒ์œ„ ์š”์†Œ์— ๋”ฐ๋ผ ๊ธฐ๋ณธ์ ์œผ๋กœ 100%๊ฐ€ ๋จน์„ ๊ฒƒ์ด๊ณ , ๋ฐ”๊นฅ div์— ๊ฑธ์–ด๋„ input๊นŒ์ง€ ์˜ํ–ฅ์ด ์•ˆ๊ฐ€๋„ค์š”. (์ž์‹๋“ค width: inherit๋‚˜ 100% ํ•ด๋„์š”..)

ํ˜น์‹œ ์‹œ๊ฐ„ ๋˜์‹œ๋ฉด ํ•œ ๋ฒˆ ํ•ด์ฃผ์‹œ๋ฉด ๊ฐ์‚ฌ๋“œ๋ฆฌ๊ฒ ์Šต๋‹ˆ๋‹ค.