@@ -1097,8 +1097,45 @@ public static function _datalist(string $type, string $name, string $id, array $
10971097 * Custom preloader component
10981098 *
10991099 * @param string|array $children Item to display as preloader
1100- */
1101- public static function _preloader ($ children ) {
1102- return self ::merge ();
1100+ * @param array $props Preloader properties
1101+ */
1102+ public static function _preloader ($ children , array $ props = []) {
1103+ if (!isset ($ props ["id " ])) $ props ["id " ] = "leaf-ui-preloader " ;
1104+ return self ::_fragment ([
1105+ self ::_style ([
1106+ "# {$ props ['id ' ]}" => "
1107+ position: fixed !important;
1108+ z-index: 1000 !important;
1109+ top: 0 !important;
1110+ left: 0 !important;
1111+ width: 100% !important;
1112+ height: 100% !important;
1113+ display: flex !important;
1114+ justify-content: center !important;
1115+ align-items: center !important;
1116+ background: white;
1117+ " ,
1118+ "# {$ props ['id ' ]} > * " => "
1119+ width: 100px !important;
1120+ " ,
1121+ "# {$ props ['id ' ]}.hidden " => "
1122+ animation: fadeOut 1.5s !important;
1123+ animation-fill-mode: forwards !important;
1124+ " ,
1125+ "@keyframes fadeOut " => [
1126+ "100% " => "
1127+ opacity: 0;
1128+ visibility: hidden;
1129+ "
1130+ ]
1131+ ]),
1132+ self ::div ($ props , $ children ),
1133+ self ::_script (["
1134+ window.addEventListener('load', function() {
1135+ const leafUILoader = document.getElementById(' {$ props ['id ' ]}');
1136+ leafUILoader.className += ' hidden';
1137+ });
1138+ " ])
1139+ ]);
11031140 }
11041141}
0 commit comments