TopLoader.tsx 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. import React from "react";
  2. import { useAppSelector } from "../hooks/useRedux";
  3. const TopLoader = () => {
  4. const isLoading = useAppSelector((state) => state.loading.isLoading);
  5. return (
  6. isLoading && (
  7. <div
  8. className={`fixed top-0 left-0 w-full h-[3px] z-[9999] pointer-events-none transition-opacity duration-500 ${
  9. isLoading ? "opacity-100" : "opacity-0"
  10. }`}
  11. >
  12. {/* Primary loading bar */}
  13. <div className="absolute inset-0 bg-[#EE0434] shadow-[0_0_15px_rgba(238,4,52,0.6)] animate-[progress-fill_2s_infinite_ease-in-out]" />
  14. {/* Secondary shimmer effect for a more active feel */}
  15. <div className="absolute inset-0 bg-gradient-to-r from-transparent via-white/40 to-transparent w-1/2 animate-[shimmer-flow_1.5s_infinite_linear]" />
  16. <style>{`
  17. @keyframes progress-fill {
  18. 0% { width: 0%; left: 0%; }
  19. 50% { width: 70%; left: 15%; }
  20. 100% { width: 0%; left: 100%; }
  21. }
  22. @keyframes shimmer-flow {
  23. 0% { transform: translateX(-100%); }
  24. 100% { transform: translateX(200%); }
  25. }
  26. `}</style>
  27. </div>
  28. )
  29. );
  30. };
  31. export default TopLoader;