Skip to content

Commit

Permalink
Merge pull request ColorlibHQ#3284 from danny007in/preloader-add
Browse files Browse the repository at this point in the history
Preloader Added
  • Loading branch information
REJack authored Jan 19, 2021
2 parents 76de56d + e932382 commit c104f19
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 0 deletions.
8 changes: 8 additions & 0 deletions build/js/Layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ const SELECTOR_FOOTER = '.main-footer'
const SELECTOR_PUSHMENU_BTN = '[data-widget="pushmenu"]'
const SELECTOR_LOGIN_BOX = '.login-box'
const SELECTOR_REGISTER_BOX = '.register-box'
const SELECTOR_PRELOADER = '.preloader'

const CLASS_NAME_SIDEBAR_COLLAPSED = 'sidebar-collapse'
const CLASS_NAME_SIDEBAR_FOCUSED = 'sidebar-focused'
Expand Down Expand Up @@ -173,6 +174,13 @@ class Layout {
setTimeout(() => {
$('body.hold-transition').removeClass('hold-transition')
}, 50)
const $preloader = $(SELECTOR_PRELOADER)
if ($preloader) {
$preloader.css('height', 0)
setTimeout(() => {
$preloader.children().hide()
}, 200)
}
}

_max(numbers) {
Expand Down
18 changes: 18 additions & 0 deletions build/scss/_layout.scss
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,20 @@ body,
min-height: 100%;
}

.preloader {
display: flex;
align-items: center;
justify-content: center;
background-color: $main-bg;
height: 100vh;
width: 100%;
transition: height 200ms linear;
position: fixed;
left: 0;
top: 0;
z-index: $zindex-preloader;
}

.wrapper {
position: relative;

Expand Down Expand Up @@ -669,4 +683,8 @@ body:not(.layout-fixed) {
color: $white;
}
}
.preloader {
background-color: $dark;
color: $white;
}
}
1 change: 1 addition & 0 deletions build/scss/_variables.scss
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ $zindex-main-sidebar: $zindex-fixed + 8 !default;
$zindex-main-footer: $zindex-fixed + 2 !default;
$zindex-control-sidebar: $zindex-fixed + 1 !default;
$zindex-toasts: $zindex-main-sidebar + 2 !default;
$zindex-preloader: 9999 !default;

// TRANSITIONS SETTINGS
// --------------------------------------------------------
Expand Down
17 changes: 17 additions & 0 deletions docs/layout.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,23 @@ You can also use the following classes for responsive changes with placing
{: .quote-info}


#### Preloader

Preloader to avoid [https://github.com/ColorlibHQ/AdminLTE/discussions/3319](https://github.com/ColorlibHQ/AdminLTE/discussions/3319)

```html
<div class="wrapper">
<!-- Preloader -->
<div class="preloader">
<img src="dist/img/AdminLTELogo.png" alt="AdminLTELogo" height="60" width="60">
</div>
</div>
```

- Preloader elements should be added inside `.wrapper` element.
- You can replace image OR modify size OR include any preload items inside `.preloader` element.


#### Dark Mode

AdminLTE 3.1 provides a dark mode option. You can add in body tag:
Expand Down
5 changes: 5 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@
<body class="hold-transition sidebar-mini layout-fixed">
<div class="wrapper">

<!-- Preloader -->
<div class="preloader">
<img src="dist/img/AdminLTELogo.png" alt="AdminLTELogo" height="60" width="60">
</div>

<!-- Navbar -->
<nav class="main-header navbar navbar-expand navbar-white navbar-light">
<!-- Left navbar links -->
Expand Down

0 comments on commit c104f19

Please sign in to comment.