ui-lib.tsx 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. import styles from "./ui-lib.module.scss";
  2. import LoadingIcon from "../icons/three-dots.svg";
  3. export function Popover(props: {
  4. children: JSX.Element;
  5. content: JSX.Element;
  6. open?: boolean;
  7. onClose?: () => void;
  8. }) {
  9. return (
  10. <div className={styles.popover}>
  11. {props.children}
  12. {props.open && (
  13. <div className={styles["popover-content"]}>
  14. <div className={styles["popover-mask"]} onClick={props.onClose}></div>
  15. {props.content}
  16. </div>
  17. )}
  18. </div>
  19. );
  20. }
  21. export function Card(props: { children: JSX.Element[]; className?: string }) {
  22. return (
  23. <div className={styles.card + " " + props.className}>{props.children}</div>
  24. );
  25. }
  26. export function ListItem(props: { children: JSX.Element[] }) {
  27. if (props.children.length > 2) {
  28. throw Error("Only Support Two Children");
  29. }
  30. return <div className={styles["list-item"]}>{props.children}</div>;
  31. }
  32. export function List(props: { children: JSX.Element[] }) {
  33. return <div className={styles.list}>{props.children}</div>;
  34. }
  35. export function Loading() {
  36. return <div style={{
  37. height: "100vh",
  38. width: "100vw",
  39. display: "flex",
  40. alignItems: "center",
  41. justifyContent: "center"
  42. }}><LoadingIcon /></div>
  43. }