Go๋ฏผ๋ณด๋‹ค Go

ํ”„๋ก ํŠธ์—”๋“œ ๊ฐœ๋ฐœ์ž

Create

[React] ์ปดํฌ๋„ŒํŠธ๋Š” ํ•œ ๋ฒˆ์— ํ•˜๋‚˜์˜ ์ฑ…์ž„๋งŒ ์ง„๋‹ค.

SleepingOff 2024. 5. 5. 20:29

๐Ÿพ๋“ค์–ด๊ฐ€๋ฉฐ

์ƒํ™ฉ:

๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ๋ฅผ ๋งŒ๋“ค๋ฉด์„œ ์ปดํฌ๋„ŒํŠธ๋ฅผ ์‚ฌ์šฉํ•  ๋•Œ ๊ฐœ๋ฐœ์ž๊ฐ€ ์–ด๋–ป๊ฒŒ ์“ฐ๋ฉด ์ข‹์„์ง€ ๋จผ์ € ์ƒ๊ฐํ–ˆ์Šต๋‹ˆ๋‹ค. ๊ทธ๋ž˜์„œ ์‹ค์ œ๋กœ ์‚ฌ์šฉํ•  ๋•Œ์˜ ์˜ˆ์‹œ๋ฅผ ๋จผ์ € ์ž‘์„ฑํ•˜๊ณค ํ•ฉ๋‹ˆ๋‹ค.

โœจ๋ณธ๊ฒฉ์ ์œผ๋กœ

์ด๋ฒˆ์— TipBox๋ฅผ ๋งŒ๋“ค๋ฉด์„œ ๋‹ค์Œ๊ณผ ๊ฐ™์€ ์ฝ”๋“œ๋ฅผ ์ƒ๊ฐํ–ˆ์Šต๋‹ˆ๋‹ค.
tooltips๊ณผ popover tips๋ฅผ ํ•ฉ์ณ์„œ TipBox๋ผ๊ณ  ๋ถ€๋ฅด๊ธฐ๋กœ ํ–ˆ์Šต๋‹ˆ๋‹ค.

//popver ์†์„ฑ์„ ๋„˜๊ธฐ๋ฉด dialog ํ˜•ํƒœ์˜ ํˆดํŒ์ด ๋‚˜์˜จ๋‹ค.
<Hint popover>
  <Hint.Target>
    <Button>feature</Button>
  </Hint.Target>
  {/* popover ์†์„ฑ์ด ์žˆ๋Š” Hint ๋‚ด๋ถ€์—์„œ show์™€ hide ๊ฐ๊ฐ์„ ๊ฐ€์ง„ ๋‘๊ฐœ์˜ Trigger๋ฅผ ์‚ฌ์šฉํ•ด์•ผ ํ•œ๋‹ค. */}
  <Hint.Trigger show>
    <Icon src="" alt="more info"></Icon>
  </Hint.Trigger>
  {/* Content๋Š” ํˆดํŒ์ด ๋œจ๋Š” ์œ„์น˜๋ฅผ prop์œผ๋กœ ๋ฐ›๋Š”๋‹ค. */}
  <Hint.Content top center>
    Lorem, ipsum dolor sit amet consectetur adipisicing elit. Dolore ab adipisci
    sed. Molestias facilis magnam ut minus distinctio illum cum rem
    exercitationem. In vitae laboriosam expedita obcaecati illum tenetur iste.
  </Hint.Content>
  <Hint.Trigger hide>X</Hint.Trigger>
</Hint>;



//popover ์†์„ฑ์ด ์—†๊ฑฐ๋‚˜ false์ผ ๊ฒฝ์šฐ, Hint.Content์˜ ๋‚ด์šฉ์€ Hint์˜ title ์†์„ฑ์— ํ• ๋‹น๋œ๋‹ค.
<Hint>
  {/* show hide ๋‘˜ ๋‹ค ๋ฐ›๊ฑฐ๋‚˜ ๋‘˜ ๋‹ค ์—†๋Š” Trigger๊ฐ€ ํ•˜๋‚˜๋งŒ ์žˆ์–ด์•ผ ํ•œ๋‹ค. */}
  <Hint.Trigger show hide>
    <Button>feature</Button>
  </Hint.Trigger>
  {/* popover ์†์„ฑ์ด ์—†์„ ๋• Hint.Content๋Š” plain text๋งŒ ๋ฐ›์„ ์ˆ˜ ์žˆ๋‹ค. */}
  <Hint.Content top center>
    Lorem, ipsum dolor sit amet consectetur adipisicing elit. Dolore ab adipisci
    sed. Molestias facilis magnam ut minus distinctio illum cum rem
    exercitationem. In vitae laboriosam expedita obcaecati illum tenetur iste.
  </Hint.Content>
</Hint>;

๋ฌธ์ œ:
ํ•˜๋‚˜์˜ ์ปดํฌ๋„ŒํŠธ๊ฐ€ popover ์†์„ฑ์— ์˜ํ•ด ์ขŒ์šฐ๋˜๋Š” ๋‘ ๊ฐ€์ง€ ์—ญํ• ๋กœ ์‚ฌ์šฉํ•˜๋ ค๊ณ  ํ–ˆ์Šต๋‹ˆ๋‹ค.
SOLID ์›์น™์„ ์ƒ๊ฐํ•˜๋ฉด ์ •๋ง ์•ˆ ์ข‹์€ ์ปดํฌ๋„ŒํŠธ์ž„์„ ๊นจ๋‹ฌ์•˜์Šต๋‹ˆ๋‹ค.

ํ•ด๊ฒฐ:
๋”ฐ๋ผ์„œ ๋‘ ์ปดํฌ๋„ŒํŠธ๋ฅผ ๋ณ„๋„๋กœ ๋งŒ๋“ค๊ณ  Hint ์ปดํฌ๋„ŒํŠธ๋กœ ์‘์ง‘ํ•˜๋ ค๊ณ  ํ•ฉ๋‹ˆ๋‹ค.

๊ฒฐ๊ณผ:
tooltips

    <Hint title="Lorem" position="top">
      feature
    </Hint>

popovertips

    <Hint popover>
      <Hint.Target>feature</Hint.Target>
      <Hint.Trigger>?</Hint.Trigger>
      <Hint.Content>
        <Hint.Panel>
          Lorem ipsum dolor sit amet consectetur adipisicing elit. Assumenda,
          nisi incidunt culpa voluptatum nihil ex sunt. Vel nesciunt eius sed
          minima illo laborum vero accusantium. Facilis voluptate numquam ut
          magnam!
        </Hint.Panel>
        <Hint.Button>close</Hint.Button>
      </Hint.Content>
    </Hint>

์‚ฌ์‹ค ์—ฌ๊ธฐ์—์„œ Hint๋กœ ์“ฐ๋Š” ๊ฒƒ์ด ์•„๋‹Œ ๊ฐ๊ฐ Tooltips์™€ Popovertips๋ผ๋Š” ๋ณ„๋„์˜ ์ปดํฌ๋„ŒํŠธ๋กœ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ์ด ๋ฐ”๋žŒ์งํ•ฉ๋‹ˆ๋‹ค. ๋‹ค๋งŒ, ์ œ๊ฐ€ ์ƒ๊ฐํ•œ Hint ์ปดํฌ๋„ŒํŠธ์˜ ์ฑ…์ž„์€ ํ•˜๋‚˜์˜ ์ปดํฌ๋„ŒํŠธ๋กœ ๋‘ ๊ฐ€์ง€๋ฅผ ๋ชจ๋‘ ์‚ฌ์šฉํ•ด๋ณผ ์ˆ˜ ์žˆ๊ฒŒ ํ•˜๋Š” ๊ฒƒ์ž…๋‹ˆ๋‹ค. ( ์‚ฌ์‹ค ์‹œ๊ฐ„์ด ์—†๊ธฐ๋„ ํ–ˆ๊ณ ... ) ๊ทธ๋ž˜์„œ ์œ„์™€ ๊ฐ™์ด ์ฝ”๋“œ๋ฅผ ์ž‘์„ฑํ•  ์ˆ˜ ์žˆ๊ฒŒ ํ•˜๋Š” ๊ฒƒ์œผ๋กœ ๋งŒ๋“ค์—ˆ์Šต๋‹ˆ๋‹ค...ใ…Žใ…Ž

โœ”๏ธ๊ฒฐ๋ก 

๋ฆฌ์•กํŠธ UI๋ฅผ ๋งŒ๋“ค์–ด๋ณด๋ฉด์„œ ์‹ค์ œ๋กœ ์ผ์ฃผ์ผ ์•ˆ์— ํ•˜๋‚˜์˜ UI๋งŒ ๊ตฌํ˜„ํ•˜๋Š” ๊ฒƒ์€ ์ •๋ง ์‰ฝ์Šต๋‹ˆ๋‹ค. ์‚ฌ์‹ค ๋ป˜์ง“๋งŒ ์•ˆํ•˜๋ฉด 3์‹œ๊ฐ„ ์•ˆ์— ๋งŒ๋“ค ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค. ๊ทธ๋ ‡์ง€๋งŒ, ์ ‘๊ทผ์„ฑ๊ณผ ์ปดํฌ๋„ŒํŠธ ๊ฐ„์˜ ์˜์กด์„ฑ๊ณผ ์žฌ์‚ฌ์šฉ์„ฑ์„ ๊ณ ๋ คํ•˜๋ฉด์„œ ๋‹ค์‹œ ๋งŒ๋“ค๊ณ  ๋‹ค์‹œ ๋งŒ๋“ค๊ณ ๋ฅผ ๋ฐ˜๋ณตํ•˜๋‹ค ๋ณด๋‹ˆ ์‹œ๊ฐ„์ด ์ข€ ์˜ค๋ž˜ ๊ฑธ๋ฆฌ๊ณ , ๊ตฌํ˜„ํ•œ ๋‚ด์šฉ์„ ๊ธ€๋กœ ์ •๋ฆฌํ•˜๋ฉด ๋˜ ์•„์‰ฌ์šด ๋ถ€๋ถ„์ด ๋ˆˆ์— ๋ณด์ž…๋‹ˆ๋‹ค. ๊ทธ๋ž˜๋„ ๋‹ค์Œ UI๋ฅผ ๋งŒ๋“ค๊ธฐ ์œ„ํ•ด todo๋กœ ์ƒ๋žตํ•˜๊ณ  ๋„˜์–ด๊ฐ€๊ณ  ์žˆ๊ณ , ์ค‘์š”ํ•œ ์ ์— ์ง‘์ค‘ํ•˜๋ ค๊ณ  ํ•ฉ๋‹ˆ๋‹ค. ํ™”์ดํŒ…!!

728x90