WbwParentIcon.tsx 974 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. import { Tooltip } from "antd";
  2. import type { IWbw } from "./WbwWord"
  3. import { Dict2SvgIcon } from "../../../assets/icon";
  4. import { errorClass } from "./WbwMeaning";
  5. interface IWidget {
  6. data: IWbw;
  7. answer?: IWbw;
  8. }
  9. const WbwParentIcon = ({ data, answer }: IWidget) => {
  10. const iconEmpty = answer?.parent ? <Dict2SvgIcon /> : <></>;
  11. let title: string | null | undefined = "空";
  12. if (typeof data.parent?.value === "string" && data.parent?.value.length > 0) {
  13. title = data.parent?.value;
  14. }
  15. const icon = data.parent?.value ? (
  16. data.parent.value.trim() !== "" ? (
  17. <Tooltip title={title}>
  18. <Dict2SvgIcon />
  19. </Tooltip>
  20. ) : (
  21. iconEmpty
  22. )
  23. ) : (
  24. iconEmpty
  25. );
  26. const errClass = answer
  27. ? errorClass("parent", data.parent?.value, answer?.parent?.value)
  28. : "";
  29. return (
  30. <span className={"wbw_word_item" + errClass}>
  31. <span className="icon">{icon}</span>
  32. </span>
  33. );
  34. };
  35. export default WbwParentIcon;