import WithDraggable from '@/components/common/draggable/WithDraggable'
import { useState } from 'react'
import { usePopup } from '@/hooks/usePopup'
import { useRecoilValue } from 'recoil'
import { contextPopupPositionState } from '@/store/popupAtom'
import { useMessage } from '@/hooks/useMessage'

export default function ImageSizeSetting(props) {
  const contextPopupPosition = useRecoilValue(contextPopupPositionState)
  const { id, pos = contextPopupPosition, size, setSize } = props
  const [sizeValue, setSizeValue] = useState(100)
  const { getMessage } = useMessage()
  const { closePopup } = usePopup()

  return (
    <WithDraggable isShow={true} pos={pos}>
      <div className={`modal-pop-wrap xxxm`}>
        <div className="modal-head">
          <h1 className="title">{getMessage('modal.image.size.setting')} </h1>
          <button className="modal-close" onClick={() => closePopup(id)}>
            닫기
          </button>
        </div>
        <div className="modal-body">
          <div className="range-wrap">
            <input
              type="range"
              id="size"
              name="volume"
              min="20"
              max="200"
              step={10}
              value={sizeValue}
              onChange={(e) => setSizeValue(e.target.value)}
            />
            <label htmlFor="size">{sizeValue}%</label>
          </div>
        </div>
      </div>
    </WithDraggable>
  )
}
