md to mdx

pull/5123/head
Daniel 2023-05-15 21:31:24 +05:30
parent 78c4f2df6c
commit fc73e03e5d
10 changed files with 58 additions and 59 deletions

View File

@ -77,4 +77,53 @@
</ul> </ul>
</div> </div>
</nav> </nav>
``` ```
```js
// Color Mode Toggler
(() => {
'use strict'
const storedTheme = localStorage.getItem('theme')
const getPreferredTheme = () => {
if (storedTheme) {
return storedTheme
}
return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'
}
const setTheme = function (theme) {
if (theme === 'auto' && window.matchMedia('(prefers-color-scheme: dark)').matches) {
document.documentElement.setAttribute('data-bs-theme', 'dark')
} else {
document.documentElement.setAttribute('data-bs-theme', theme)
}
}
setTheme(getPreferredTheme())
const showActiveTheme = theme => {
const activeThemeIcon = document.querySelector('.theme-icon-active i')
const btnToActive = document.querySelector('[data-bs-theme-value="' + theme + '"]')
const svgOfActiveBtn = btnToActive.querySelector('i').getAttribute('class')
document.querySelectorAll('[data-bs-theme-value]').forEach(element => {
element.classList.remove('active')
})
btnToActive.classList.add('active')
activeThemeIcon.setAttribute('class', svgOfActiveBtn)
}
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', () => {
if (storedTheme !== 'light' || storedTheme !== 'dark') {
setTheme(getPreferredTheme())
}
})
window.addEventListener('DOMContentLoaded', () => {
showActiveTheme(getPreferredTheme())
document.querySelectorAll('[data-bs-theme-value]')
.forEach(toggle => {
toggle.addEventListener('click', () => {
const theme = toggle.getAttribute('data-bs-theme-value')
localStorage.setItem('theme', theme)
setTheme(theme)
showActiveTheme(theme)
})
})
})
})()
```

View File

@ -1,48 +0,0 @@
```js
// Color Mode Toggler
(() => {
'use strict'
const storedTheme = localStorage.getItem('theme')
const getPreferredTheme = () => {
if (storedTheme) {
return storedTheme
}
return window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'
}
const setTheme = function (theme) {
if (theme === 'auto' && window.matchMedia('(prefers-color-scheme: dark)').matches) {
document.documentElement.setAttribute('data-bs-theme', 'dark')
} else {
document.documentElement.setAttribute('data-bs-theme', theme)
}
}
setTheme(getPreferredTheme())
const showActiveTheme = theme => {
const activeThemeIcon = document.querySelector('.theme-icon-active i')
const btnToActive = document.querySelector('[data-bs-theme-value="' + theme + '"]')
const svgOfActiveBtn = btnToActive.querySelector('i').getAttribute('class')
document.querySelectorAll('[data-bs-theme-value]').forEach(element => {
element.classList.remove('active')
})
btnToActive.classList.add('active')
activeThemeIcon.setAttribute('class', svgOfActiveBtn)
}
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', () => {
if (storedTheme !== 'light' || storedTheme !== 'dark') {
setTheme(getPreferredTheme())
}
})
window.addEventListener('DOMContentLoaded', () => {
showActiveTheme(getPreferredTheme())
document.querySelectorAll('[data-bs-theme-value]')
.forEach(toggle => {
toggle.addEventListener('click', () => {
const theme = toggle.getAttribute('data-bs-theme-value')
localStorage.setItem('theme', theme)
setTheme(theme)
showActiveTheme(theme)
})
})
})
})()
```

View File

@ -2,7 +2,7 @@
import Head from "@components/_head.astro"; import Head from "@components/_head.astro";
import Footer from "@components/dashboard/_footer.astro"; import Footer from "@components/dashboard/_footer.astro";
import Topbar from "@components/dashboard/_topbar.astro"; import Topbar from "@components/dashboard/_topbar.astro";
import BrowserSupport from "@components/docs/browser-support/index.md"; import BrowserSupport from "@components/docs/browser-support.mdx";
import Sidenav from "@components/dashboard/_sidenav.astro"; import Sidenav from "@components/dashboard/_sidenav.astro";
import Scripts from "@components/_scripts.astro"; import Scripts from "@components/_scripts.astro";
const title = "Browser Support | AdminLTE 4"; const title = "Browser Support | AdminLTE 4";

View File

@ -4,8 +4,7 @@ import Footer from "@components/dashboard/_footer.astro";
import Topbar from "@components/dashboard/_topbar.astro"; import Topbar from "@components/dashboard/_topbar.astro";
import Sidenav from "@components/dashboard/_sidenav.astro"; import Sidenav from "@components/dashboard/_sidenav.astro";
import Scripts from "@components/_scripts.astro"; import Scripts from "@components/_scripts.astro";
import NavbarHtml from "@components/docs/color-mode/navbar-html.md"; import ColorMode from "@components/docs/color-mode.mdx";
import ToggleScript from "@components/docs/color-mode/toggle-script.md";
const title = "Color Mode | AdminLTE 4"; const title = "Color Mode | AdminLTE 4";
const path = '../../../dist' const path = '../../../dist'
const mainPage = "docs"; const mainPage = "docs";
@ -33,7 +32,7 @@ const page = "color-mode";
<ol class="breadcrumb float-sm-end"> <ol class="breadcrumb float-sm-end">
<li class="breadcrumb-item"><a href="#">Docs</a></li> <li class="breadcrumb-item"><a href="#">Docs</a></li>
<li class="breadcrumb-item active" aria-current="page"> <li class="breadcrumb-item active" aria-current="page">
General Form Color Mode
</li> </li>
</ol> </ol>
</div> </div>
@ -127,9 +126,8 @@ const page = "color-mode";
</div> </div>
<!-- Start column --> <!-- Start column -->
<div class="col-12"> <div class="col-12">
<NavbarHtml /> <ColorMode />
<ToggleScript />
</div> </div>
</div> </div>
<!-- /.row --> <!-- /.row -->

View File

@ -2,7 +2,7 @@
import Head from "@components/_head.astro"; import Head from "@components/_head.astro";
import Footer from "@components/dashboard/_footer.astro"; import Footer from "@components/dashboard/_footer.astro";
import Topbar from "@components/dashboard/_topbar.astro"; import Topbar from "@components/dashboard/_topbar.astro";
import MainHeader1 from "@components/docs/components/main-header-1.md"; import MainHeader from "@components/docs/components/main-header.mdx";
import Sidenav from "@components/dashboard/_sidenav.astro"; import Sidenav from "@components/dashboard/_sidenav.astro";
import Scripts from "@components/_scripts.astro"; import Scripts from "@components/_scripts.astro";
const title = "Main Header Component | AdminLTE 4"; const title = "Main Header Component | AdminLTE 4";
@ -215,7 +215,7 @@ const distPath = path
</nav> </nav>
<!-- /.navbar --> <!-- /.navbar -->
<MainHeader1 /> <MainHeader />
</div> </div>
<!-- /.container-fluid --> <!-- /.container-fluid -->
</div> </div>

View File

@ -4,7 +4,7 @@ import Footer from "@components/dashboard/_footer.astro";
import Topbar from "@components/dashboard/_topbar.astro"; import Topbar from "@components/dashboard/_topbar.astro";
import Sidenav from "@components/dashboard/_sidenav.astro"; import Sidenav from "@components/dashboard/_sidenav.astro";
import Scripts from "@components/_scripts.astro"; import Scripts from "@components/_scripts.astro";
import Introduction from "@components/docs/introduction/index.md"; import Introduction from "@components/docs/introduction.mdx";
const title = "Introduction | AdminLTE 4"; const title = "Introduction | AdminLTE 4";
const path = '../../../dist' const path = '../../../dist'
const mainPage = "docs"; const mainPage = "docs";

View File

@ -59,7 +59,7 @@ const page = "layout";
<p>AdminLTE v4 provides a set of options to apply to your main layout. Each one of these classes can be added to the <code>body</code> tag to get the desired goal.</p> <p>AdminLTE v4 provides a set of options to apply to your main layout. Each one of these classes can be added to the <code>body</code> tag to get the desired goal.</p>
<ul> <ul>
<li>Fixed Sidebar: use the class <code>.layout-fixed</code> to get a fixed sidebar.</li> <li>Fixed Sidebar: use the class <code>.layout-fixed</code> to get a fixed sidebar.</li>
<li>Collapsed Sidebar: use the class <code>.sidebar-expand-lg .sidebar-mini .sidebar-collapse</code> to have a collapsed sidebar upon loading.</li> <li>Collapsed Sidebar: use the class <code>.sidebar-expand-* .sidebar-mini .sidebar-collapse</code> to have a collapsed sidebar upon loading.</li>
</ul> </ul>
</div> </div>
<!-- /.container-fluid --> <!-- /.container-fluid -->