mirror of
https://github.com/tabler/tabler.git
synced 2025-12-22 01:44:25 +04:00
Merge branch 'main' of https://github.com/tabler/tabler into dev
This commit is contained in:
10
gulpfile.js
10
gulpfile.js
@@ -285,6 +285,10 @@ gulp.task('js-demo', () => {
|
|||||||
return compileJs('demo')
|
return compileJs('demo')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
gulp.task('js-demo-theme', () => {
|
||||||
|
return compileJs('demo-theme')
|
||||||
|
})
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Compile JS module files to dist directory
|
* Compile JS module files to dist directory
|
||||||
*/
|
*/
|
||||||
@@ -416,7 +420,7 @@ gulp.task('build-critical', (cb) => {
|
|||||||
*/
|
*/
|
||||||
gulp.task('watch', (cb) => {
|
gulp.task('watch', (cb) => {
|
||||||
gulp.watch('./src/scss/**/*.scss', gulp.series('sass'))
|
gulp.watch('./src/scss/**/*.scss', gulp.series('sass'))
|
||||||
gulp.watch('./src/js/**/*.js', gulp.parallel('js', 'mjs', 'js-demo'))
|
gulp.watch('./src/js/**/*.js', gulp.parallel('js', 'mjs', gulp.parallel('js-demo', 'js-demo-theme')))
|
||||||
cb()
|
cb()
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -516,8 +520,8 @@ gulp.task('add-banner', () => {
|
|||||||
|
|
||||||
gulp.task('clean', gulp.series('clean-dirs', 'clean-jekyll'))
|
gulp.task('clean', gulp.series('clean-dirs', 'clean-jekyll'))
|
||||||
|
|
||||||
gulp.task('start', gulp.series('clean', 'sass', 'js', 'js-demo', 'mjs', 'build-jekyll', gulp.parallel('watch-jekyll', 'watch', 'browser-sync')))
|
gulp.task('start', gulp.series('clean', 'sass', 'js', gulp.parallel('js-demo', 'js-demo-theme'), 'mjs', 'build-jekyll', gulp.parallel('watch-jekyll', 'watch', 'browser-sync')))
|
||||||
|
|
||||||
gulp.task('build-core', gulp.series('build-on', 'clean', 'sass', 'css-rtl', 'css-minify', 'js', 'js-demo', 'mjs', 'copy-images', 'copy-libs', 'add-banner'))
|
gulp.task('build-core', gulp.series('build-on', 'clean', 'sass', 'css-rtl', 'css-minify', 'js', gulp.parallel('js-demo', 'js-demo-theme'), 'mjs', 'copy-images', 'copy-libs', 'add-banner'))
|
||||||
gulp.task('build-demo', gulp.series('build-on', 'build-jekyll', 'copy-static', 'copy-dist', 'build-cleanup', 'build-purgecss'/*, 'build-critical'*/))
|
gulp.task('build-demo', gulp.series('build-on', 'build-jekyll', 'copy-static', 'copy-dist', 'build-cleanup', 'build-purgecss'/*, 'build-critical'*/))
|
||||||
gulp.task('build', gulp.series('build-core', 'build-demo'))
|
gulp.task('build', gulp.series('build-core', 'build-demo'))
|
||||||
|
|||||||
25
src/js/demo-theme.js
Normal file
25
src/js/demo-theme.js
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
/**
|
||||||
|
* demo-theme is specifically loaded right after the body and not deferred
|
||||||
|
* to ensure we switch to the chosen dark/light theme as fast as possible.
|
||||||
|
* This will prevent any flashes of the light theme (default) before switching.
|
||||||
|
*/
|
||||||
|
|
||||||
|
const themeStorageKey = 'tablerTheme'
|
||||||
|
const defaultTheme = 'light'
|
||||||
|
let selectedTheme
|
||||||
|
|
||||||
|
// https://stackoverflow.com/a/901144
|
||||||
|
const params = new Proxy(new URLSearchParams(window.location.search), {
|
||||||
|
get: (searchParams, prop) => searchParams.get(prop),
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!!params.theme) {
|
||||||
|
localStorage.setItem(themeStorageKey, params.theme)
|
||||||
|
selectedTheme = params.theme
|
||||||
|
} else {
|
||||||
|
const storedTheme = localStorage.getItem(themeStorageKey)
|
||||||
|
selectedTheme = storedTheme ? storedTheme : defaultTheme
|
||||||
|
}
|
||||||
|
|
||||||
|
document.body.classList.remove('theme-dark', 'theme-light');
|
||||||
|
document.body.classList.add(`theme-${selectedTheme}`);
|
||||||
@@ -1,6 +1,5 @@
|
|||||||
// Setting items
|
// Setting items
|
||||||
const items = {
|
const items = {
|
||||||
'theme': { localStorage: 'tablerTheme', default: 'light' },
|
|
||||||
'menu-position': { localStorage: 'tablerMenuPosition', default: 'top' },
|
'menu-position': { localStorage: 'tablerMenuPosition', default: 'top' },
|
||||||
'menu-behavior': { localStorage: 'tablerMenuBehavior', default: 'sticky' },
|
'menu-behavior': { localStorage: 'tablerMenuBehavior', default: 'sticky' },
|
||||||
'container-layout': { localStorage: 'tablerContainerLayout', default: 'boxed' }
|
'container-layout': { localStorage: 'tablerContainerLayout', default: 'boxed' }
|
||||||
@@ -44,16 +43,6 @@ const toggleFormControls = (form) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update body classes
|
|
||||||
const updateBodyClasses = () => {
|
|
||||||
document.body.classList.remove('theme-dark', 'theme-light');
|
|
||||||
document.body.classList.add(`theme-${config.theme}`);
|
|
||||||
|
|
||||||
// for (const [key, params] of Object.entries(items)) {
|
|
||||||
// document.body.setAttribute(`data-${key}`, config[key]);
|
|
||||||
// }
|
|
||||||
}
|
|
||||||
|
|
||||||
// Submit form
|
// Submit form
|
||||||
const submitForm = (form) => {
|
const submitForm = (form) => {
|
||||||
// Save data to localStorage
|
// Save data to localStorage
|
||||||
@@ -66,9 +55,6 @@ const submitForm = (form) => {
|
|||||||
config[key] = value
|
config[key] = value
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update body classes
|
|
||||||
updateBodyClasses();
|
|
||||||
|
|
||||||
window.dispatchEvent(new Event('resize'));
|
window.dispatchEvent(new Event('resize'));
|
||||||
|
|
||||||
(new bootstrap.Offcanvas(form)).hide()
|
(new bootstrap.Offcanvas(form)).hide()
|
||||||
@@ -78,9 +64,6 @@ const submitForm = (form) => {
|
|||||||
// Parse url
|
// Parse url
|
||||||
parseUrl()
|
parseUrl()
|
||||||
|
|
||||||
// Update body classes
|
|
||||||
updateBodyClasses();
|
|
||||||
|
|
||||||
// Elements
|
// Elements
|
||||||
const form = document.querySelector('#offcanvasSettings')
|
const form = document.querySelector('#offcanvasSettings')
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,13 @@
|
|||||||
{% capture script %}
|
{% capture script %}
|
||||||
{% assign colors = include.colors | default: 1 %}
|
{% assign colors = include.colors | default: 1 %}
|
||||||
<script>
|
<script>
|
||||||
var options = {
|
// @formatter:off
|
||||||
|
document.addEventListener("DOMContentLoaded", function () {
|
||||||
|
{% if jekyll.environment == 'development' %}
|
||||||
|
window.tabler_chart = window.tabler_chart || {};
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
window.ApexCharts && ({% if jekyll.environment == 'development' %}window.tabler_chart["chart-{{ include.chart-id }}"] = {% endif %}new ApexCharts(document.getElementById('chart-{{ id }}'), {
|
||||||
chart: {
|
chart: {
|
||||||
height: {{ height | times: 16 }},
|
height: {{ height | times: 16 }},
|
||||||
type: "heatmap",
|
type: "heatmap",
|
||||||
@@ -54,7 +60,8 @@
|
|||||||
series: [
|
series: [
|
||||||
{% for i in site.months-short limit: 12 %}
|
{% for i in site.months-short limit: 12 %}
|
||||||
{% assign month-i = forloop.index %}
|
{% assign month-i = forloop.index %}
|
||||||
{ name: "{{ i }}", data: [{% for j in (1..16) %}{x: '{{ j }}', y: {{ j | random_number: 0, 100 | plus: month-i | random_number: 0, 100 }}},{% endfor %}] },{% endfor %}
|
{ name: "{{ i }}", data: [{% for j in (1..16) %}{x: '{{ j }}', y: {{ j | random_number: 0, 100 | plus: month-i | random_number: 0, 100 }}},{% endfor %}] },
|
||||||
|
{% endfor %}
|
||||||
],
|
],
|
||||||
xaxis: {
|
xaxis: {
|
||||||
type: "category"
|
type: "category"
|
||||||
@@ -76,9 +83,9 @@
|
|||||||
show: false,
|
show: false,
|
||||||
{% endif %}
|
{% endif %}
|
||||||
},
|
},
|
||||||
};
|
})).render();
|
||||||
|
});
|
||||||
(new ApexCharts(document.querySelector("#chart-{{ id }}"),options)).render();
|
// @formatter:on
|
||||||
</script>
|
</script>
|
||||||
{% endcapture %}
|
{% endcapture %}
|
||||||
|
|
||||||
|
|||||||
@@ -43,6 +43,7 @@
|
|||||||
|
|
||||||
{% assign layout-dark = page.layout-dark | default: site.layout-dark %}
|
{% assign layout-dark = page.layout-dark | default: site.layout-dark %}
|
||||||
<body {% if layout.body-class or page.body-class %} class="{% if layout.body-class %} {{ layout.body-class }}{% endif %}{% if page.body-class %} {{ page.body-class }}{% endif %}"{% endif %}>
|
<body {% if layout.body-class or page.body-class %} class="{% if layout.body-class %} {{ layout.body-class }}{% endif %}{% if page.body-class %} {{ page.body-class }}{% endif %}"{% endif %}>
|
||||||
|
<script src="{{ site.base }}/dist/js/demo-theme{% if jekyll.environment != 'development' %}.min{% endif %}.js{% if jekyll.environment == 'preview' %}?{{ site.time | date: '%s' }}{% endif %}"></script>
|
||||||
|
|
||||||
{{ content }}
|
{{ content }}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user