import {ArrowUpOutlined} from "@ant-design/icons";


type ButtonToTopProps = {
	onClick?: () => void;
	visible?: boolean;
	container?: HTMLElement | string;
}
export default function ButtonToTop(props: ButtonToTopProps) {
	return (
		<div className={'page-action-to-top'}>
			{props.visible && <button className="btn-to-top text-white" onClick={()=>{
				if(props.onClick){
					props.onClick()
				}else if(props.container){
					const container = typeof(props.container) == 'string'? document.querySelector(props.container):props.container
					if(container){
						container.scrollTop = 0
					}
				}
			}}><ArrowUpOutlined/></button>}
		</div>
	)
}