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

Switch #6

Open
hsskey opened this issue Oct 21, 2024 · 0 comments
Open

Switch #6

hsskey opened this issue Oct 21, 2024 · 0 comments

Comments

@hsskey
Copy link
Owner

hsskey commented Oct 21, 2024

๐Ÿ“‹ ์ปดํฌ๋„ŒํŠธ ์ •๋ณด

  • ์ปดํฌ๋„ŒํŠธ ์ด๋ฆ„: Switch
  • ์ปดํฌ๋„ŒํŠธ ์„ค๋ช…: Switch๋Š” ์‚ฌ์šฉ์ž๊ฐ€ on ๋˜๋Š” off ๋‘ ๊ฐ€์ง€ ๊ฐ’ ์ค‘ ํ•˜๋‚˜๋ฅผ ์„ ํƒํ•  ์ˆ˜ ์žˆ๋Š” ์ž…๋ ฅ ์œ„์ ฏ
  • ์‚ฌ์šฉ ์‚ฌ๋ก€: ์„ค์ • ์ผœ๊ธฐ/๋„๊ธฐ, ๊ธฐ๋Šฅ ํ™œ์„ฑํ™”/๋น„ํ™œ์„ฑํ™” ๋“ฑ ์ด์ง„ ์„ ํƒ์ด ํ•„์š”ํ•œ ๊ฒฝ์šฐ ์‚ฌ์šฉ

๐Ÿ“š ์ฐธ์กฐ ๋ฐ ๋ ˆํผ๋Ÿฐ์Šค

  • ARIA Authoring Practices: W3C ARIA Switch Pattern
    • Switch ํŒจํ„ด์˜ ์„ค๋ช…, ์˜ˆ์‹œ, ํ‚ค๋ณด๋“œ ์ธํ„ฐ๋ž™์…˜, ์ ‘๊ทผ์„ฑ ๊ณ ๋ ค์‚ฌํ•ญ ๋“ฑ์„ ์ฐธ๊ณ ํ•  ์ˆ˜ ์žˆ์Œ
  • ๊ธฐํƒ€ ๋ ˆํผ๋Ÿฐ์Šค:
    • Building a switch component
      • Switch ์ปดํฌ๋„ŒํŠธ ์ œ์ž‘ ๊ณผ์ •์„ ์ž์„ธํžˆ ์„ค๋ช…ํ•œ ๊ธ€
    • MUI, Ant Design ๋“ฑ์˜ UI ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ์—์„œ Switch ์ปดํฌ๋„ŒํŠธ ๊ตฌํ˜„ ๋ฐฉ์‹์„ ์ฐธ๊ณ ํ•  ์ˆ˜ ์žˆ์Œ

๐Ÿ“ ์ ‘๊ทผ์„ฑ ๋ฐ ARIA ์ ์šฉ ์—ฌ๋ถ€

  • ARIA Pattern ์ ์šฉ: W3C ARIA Switch Pattern
    • ์‚ฌ์šฉ๋œ ARIA ์†์„ฑ:
      • role="switch": ์š”์†Œ๊ฐ€ switch์ž„์„ ๋‚˜ํƒ€๋ƒ„
      • aria-checked="true|false": switch์˜ ์ƒํƒœ(on/off)๋ฅผ ๋‚˜ํƒ€๋ƒ„
      • aria-labelledby, aria-label: switch์˜ ๋ ˆ์ด๋ธ”์„ ์ œ๊ณต
      • aria-describedby: switch์— ๋Œ€ํ•œ ์ถ”๊ฐ€ ์„ค๋ช…์„ ์ œ๊ณต
  • ์ ‘๊ทผ์„ฑ ๊ด€๋ จ ๊ณ ๋ ค์‚ฌํ•ญ:
    • Switch์˜ ์ƒํƒœ ๋ณ€ํ™”๋ฅผ ์‹œ๊ฐ์ ์œผ๋กœ ๋ช…ํ™•ํžˆ ํ‘œ์‹œํ•ด์•ผ ํ•จ
    • Switch์˜ ์ƒํƒœ๋ฅผ ๋‚˜ํƒ€๋‚ด๋Š” ํ…์ŠคํŠธ(On/Off ๋“ฑ)๋Š” ์Šคํฌ๋ฆฐ ๋ฆฌ๋”์—์„œ ์ค‘๋ณต ์ฝํžˆ์ง€ ์•Š๋„๋ก aria-hidden ์†์„ฑ ์‚ฌ์šฉ
    • Switch์˜ ์ƒํƒœ ๋ณ€ํ™” ์‹œ ๋ ˆ์ด๋ธ”์ด ๋ณ€๊ฒฝ๋˜์ง€ ์•Š์•„์•ผ ํ•จ
    • ํ‚ค๋ณด๋“œ๋กœ ์กฐ์ž‘ ๊ฐ€๋Šฅํ•ด์•ผ ํ•จ
  • ์ ‘๊ทผ์„ฑ ๊ธฐ๋Šฅ ์š”์•ฝ:
    • role="switch"์™€ aria-checked๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ switch์˜ ์—ญํ• ๊ณผ ์ƒํƒœ๋ฅผ ์ „๋‹ฌ
    • ๋ ˆ์ด๋ธ”๊ณผ ์„ค๋ช…์„ ์ œ๊ณตํ•˜์—ฌ switch์˜ ๋ชฉ์ ์„ ๋ช…ํ™•ํžˆ ํ•จ
    • ํ‚ค๋ณด๋“œ ์กฐ์ž‘์„ ์ง€์›ํ•˜์—ฌ ์ ‘๊ทผ์„ฑ์„ ๋†’์ž„

๐Ÿ—๏ธ ๋งˆํฌ์—… ๊ตฌ์กฐ ๋ถ„์„

  • HTML ์‹œ๋งจํ‹ฑ ํƒœ๊ทธ ์‚ฌ์šฉ:
    • W3C ์˜ˆ์ œ: <div role="switch">, <span>
    • MUI: <div class="MuiSwitch-root">, <input type="checkbox" role="switch">
    • Ant Design: <button type="button" role="switch">
  • ๋งˆํฌ์—… ๊ตฌ์กฐ ๋น„๊ต:
    • W3C:
      <div role="switch"
           aria-checked="false"
           tabindex="0">
        <span class="label">
          Notifications
        </span>
        <span class="switch">
          <span></span>
        </span>
        <span class="on" aria-hidden="true">
          On
        </span>
        <span class="off" aria-hidden="true">
          Off
        </span>
      </div>
    • MUI:
      <div class="MuiSwitch-root">
        <span class="MuiSwitch-track">
          <span class="MuiSwitch-thumb"></span>
        </span>
        <div class="MuiSwitch-action">
          <input type="checkbox" role="switch" class="MuiSwitch-input">
        </div>
      </div>
    • Ant Design:
      <button type="button" role="switch" aria-checked="true" class="ant-switch ant-switch-checked">
        <div class="ant-switch-handle"></div>
        <span class="ant-switch-inner">
          <span class="ant-switch-inner-checked"></span>
          <span class="ant-switch-inner-unchecked"></span>
        </span>
      </button>
  • ๊ตฌ์กฐ์  ์„ ํƒ ์ด์œ :
    • W3C: switch์˜ ์—ญํ• ๊ณผ ์ƒํƒœ๋ฅผ ๋ช…์‹œ์ ์œผ๋กœ ํ‘œํ˜„ํ•˜๊ธฐ ์œ„ํ•ด role๊ณผ aria-* ์†์„ฑ ์‚ฌ์šฉ
    • MUI: <input type="checkbox" role="switch">๋ฅผ ๊ธฐ๋ฐ˜์œผ๋กœ ์Šคํƒ€์ผ๋ง ๋ฐ ๊ธฐ๋Šฅ ์ถ”๊ฐ€
    • Ant Design: <button>์„ ๊ธฐ๋ฐ˜์œผ๋กœ ์Šคํƒ€์ผ๋ง ๋ฐ ๊ธฐ๋Šฅ ์ถ”๊ฐ€ํ•˜๊ณ  role๊ณผ aria-* ์†์„ฑ์œผ๋กœ ์ ‘๊ทผ์„ฑ ๋ณด์žฅ

๐Ÿ’ก UI ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ๋น„๊ต ๋ถ„์„

  • MUI:
    • <div>์™€ <input type="checkbox" role="switch">๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ๊ตฌํ˜„
    • CSS ํด๋ž˜์Šค๋ฅผ ์‚ฌ์šฉํ•˜์—ฌ ์Šคํƒ€์ผ๋ง
    • ์ƒํƒœ์— ๋”ฐ๋ฅธ ์Šคํƒ€์ผ ๋ณ€๊ฒฝ์€ ํด๋ž˜์Šค ์ถ”๊ฐ€/์ œ๊ฑฐ๋กœ ์ฒ˜๋ฆฌ
  • Ant Design:
    • <button>์„ ์‚ฌ์šฉํ•˜์—ฌ ๊ตฌํ˜„
    • role๊ณผ aria-* ์†์„ฑ์„ ์‚ฌ์šฉํ•˜์—ฌ ์ ‘๊ทผ์„ฑ ๋ณด์žฅ
    • ์ƒํƒœ์— ๋”ฐ๋ฅธ ์Šคํƒ€์ผ ๋ณ€๊ฒฝ์€ ํด๋ž˜์Šค ์ถ”๊ฐ€/์ œ๊ฑฐ๋กœ ์ฒ˜๋ฆฌ

โš™๏ธ ๊ตฌํ˜„ ๋ฐ ์„ค๊ณ„ ๊ณ ๋ ค์‚ฌํ•ญ

  • ์ฃผ์š” ์„ค๊ณ„ ๊ณ ๋ ค์‚ฌํ•ญ:
    • ์ ‘๊ทผ์„ฑ: ํ‚ค๋ณด๋“œ ์กฐ์ž‘ ๊ฐ€๋Šฅ, ์ ์ ˆํ•œ ๋ ˆ์ด๋ธ” ๋ฐ ์„ค๋ช… ์ œ๊ณต, ์ƒํƒœ ๋ณ€ํ™” ๋ช…ํ™•ํžˆ ์ „๋‹ฌ
    • ์ƒํƒœ ๊ด€๋ฆฌ: on/off ์ƒํƒœ๋ฅผ ๊ด€๋ฆฌํ•˜๊ณ  ๋ณ€๊ฒฝํ•  ์ˆ˜ ์žˆ์–ด์•ผ ํ•จ
    • ์Šคํƒ€์ผ๋ง: ์ƒํƒœ์— ๋”ฐ๋ฅธ ์‹œ๊ฐ์  ๋ณ€ํ™”๋ฅผ ๋ช…ํ™•ํžˆ ํ‘œํ˜„
  • ์ฝ”๋“œ ์˜ˆ์‹œ:
    <label class="switch">
      <input type="checkbox" role="switch" aria-checked="false">
      <span class="slider"></span>
      <span class="label">Switch Label</span>
    </label>

๐Ÿ” ํ…Œ์ŠคํŠธ ๋ฐ ๊ฒ€ํ† 

  • ์ ‘๊ทผ์„ฑ ํ…Œ์ŠคํŠธ:
    • ํ‚ค๋ณด๋“œ๋กœ ์กฐ์ž‘ ๊ฐ€๋Šฅํ•œ์ง€ ํ™•์ธ
    • ์Šคํฌ๋ฆฐ ๋ฆฌ๋”์—์„œ ์ ์ ˆํžˆ ์ฝํžˆ๋Š”์ง€ ํ™•์ธ
  • ๋ธŒ๋ผ์šฐ์ € ํ˜ธํ™˜์„ฑ ํ…Œ์ŠคํŠธ: ์ฃผ์š” ๋ธŒ๋ผ์šฐ์ €์—์„œ ์ผ๊ด€๋œ ๋™์ž‘๊ณผ ์Šคํƒ€์ผ๋ง ๋˜๋Š”์ง€ ํ™•์ธ
  • ์‚ฌ์šฉ์ž ํ”ผ๋“œ๋ฐฑ: ์‚ฌ์šฉ์„ฑ ํ…Œ์ŠคํŠธ๋ฅผ ํ†ตํ•ด ํ”ผ๋“œ๋ฐฑ์„ ์ˆ˜๋ ดํ•˜๊ณ  ๊ฐœ์„  ์‚ฌํ•ญ ๋ฐ˜์˜

๐Ÿ“Œ ์ถ”๊ฐ€ ์ฐธ๊ณ  ์‚ฌํ•ญ

  • ๊ด€๋ จ ๋ฌธ์„œ:
  • ์˜๊ฒฌ ๋ฐ ์ œ์•ˆ:
    • ๋ผ๋ฒจ ์œ„์น˜ ๋“ฑ ๋””์ž์ธ ์ ์ธ ์š”์†Œ๋Š” ํ”„๋กœ์ ํŠธ์˜ ํŠน์„ฑ์— ๋งž๊ฒŒ ์กฐ์ • ํ•„์š”
    • ์ƒํƒœ ๋ณ€๊ฒฝ ์‹œ ์• ๋‹ˆ๋ฉ”์ด์…˜ ํšจ๊ณผ๋ฅผ ์ถ”๊ฐ€ํ•˜์—ฌ ์‚ฌ์šฉ์ž ๊ฒฝํ—˜ ๊ฐœ์„  ๊ฐ€๋Šฅ

๐ŸŽฏ ์—ญํ• , ์†์„ฑ, ์ƒํƒœ ๋ฐ ํƒœ๊ทธ ์†์„ฑ

  • Role, Attribute, State
    • Role: switch
    • Attribute:
      • aria-checked: switch์˜ ์ƒํƒœ(on/off)๋ฅผ ๋‚˜ํƒ€๋ƒ„
      • aria-labelledby, aria-label: switch์˜ ๋ ˆ์ด๋ธ”์„ ์ œ๊ณต
      • aria-describedby: switch์— ๋Œ€ํ•œ ์ถ”๊ฐ€ ์„ค๋ช…์„ ์ œ๊ณต
    • State: checked: switch์˜ ์ƒํƒœ(on/off)๋ฅผ ๋‚˜ํƒ€๋ƒ„
  • JavaScript ๋ฐ CSS ์‚ฌ์šฉ ์—ฌ๋ถ€
    • JavaScript ์‚ฌ์šฉ ์—ฌ๋ถ€:
      • ์ƒํƒœ ๋ณ€๊ฒฝ ์ด๋ฒคํŠธ ์ฒ˜๋ฆฌ
      • ํ‚ค๋ณด๋“œ ์ด๋ฒคํŠธ ์ฒ˜๋ฆฌ
      • ์ ‘๊ทผ์„ฑ ์†์„ฑ ๋™์  ๋ณ€๊ฒฝ
    • CSS ์ ์šฉ ์‚ฌํ•ญ:
      • ์ƒํƒœ์— ๋”ฐ๋ฅธ ์Šคํƒ€์ผ ๋ณ€๊ฒฝ
      • ํŠธ๋ž™๊ณผ ์ธ์˜ ๋ชจ์–‘ ๋ฐ ์œ„์น˜ ์กฐ์ •
      • ์• ๋‹ˆ๋ฉ”์ด์…˜ ํšจ๊ณผ ์ ์šฉ
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant