index.ts 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. import "./index.css";
  2. import { type Component, h, defineComponent } from "vue";
  3. export interface attrsType {
  4. width?: string;
  5. height?: string;
  6. borderRadius?: number | string;
  7. background?: string;
  8. scale?: number | string;
  9. }
  10. /**
  11. * 圆点、方形闪烁动画组件
  12. * @param width 可选 string 宽
  13. * @param height 可选 string 高
  14. * @param borderRadius 可选 number | string 传0为方形、传50%或者不传为圆形
  15. * @param background 可选 string 闪烁颜色
  16. * @param scale 可选 number | string 闪烁范围,默认2,值越大闪烁范围越大
  17. * @returns Component
  18. */
  19. export function useRenderFlicker(attrs?: attrsType): Component {
  20. return defineComponent({
  21. name: "ReFlicker",
  22. render() {
  23. return h(
  24. "div",
  25. {
  26. class: "point point-flicker",
  27. style: {
  28. "--point-width": attrs?.width ?? "12px",
  29. "--point-height": attrs?.height ?? "12px",
  30. "--point-background":
  31. attrs?.background ?? "var(--el-color-primary)",
  32. "--point-border-radius": attrs?.borderRadius ?? "50%",
  33. "--point-scale": attrs?.scale ?? "2"
  34. }
  35. },
  36. {
  37. default: () => []
  38. }
  39. );
  40. }
  41. });
  42. }