Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions assets/admin_entry.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove empty line, or indicate this is for "demo" purpose (how to extend entrypoint)

import '@sylius/bootstrap-admin-ui/entrypoint';

import './styles/app.css';
3 changes: 2 additions & 1 deletion assets/app.js
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
import './scripts/statistics_chart.js';
// App entrypoint - Leave empty unless need to override entrypoint from BootstrapAdminUi
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 maybe remove this file, or use it instead admin_entry


10 changes: 8 additions & 2 deletions assets/controllers.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
{
"controllers": {
"@sylius/bootstrap-admin-ui": {
"theme-switcher": {
"enabled": true,
"fetch": "eager"
}
},
"@symfony/ux-autocomplete": {
"autocomplete": {
"enabled": true,
"fetch": "eager",
"autoimport": {
"tom-select/dist/css/tom-select.default.css": true,
"tom-select/dist/css/tom-select.default.css": false,
"tom-select/dist/css/tom-select.bootstrap4.css": false,
"tom-select/dist/css/tom-select.bootstrap5.css": false
"tom-select/dist/css/tom-select.bootstrap5.css": true
Comment thread
Jibbarth marked this conversation as resolved.
}
}
},
Expand Down
153 changes: 153 additions & 0 deletions assets/controllers/chart_controller.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
import { Controller } from '@hotwired/stimulus';
import ApexCharts from 'apexcharts';

export default class extends Controller {
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could be lazy, as used only on dashboard page

static values = {
intervals: Array,
talks: Array
}

chart = null;
isInitialized = false;

connect() {
this.renderChart();
this.observeThemeChanges();
this.isInitialized = true;
}

disconnect() {
if (this.chart) {
this.chart.destroy();
}
if (this.themeObserver) {
this.themeObserver.disconnect();
}
}

intervalsValueChanged() {
if (this.isInitialized) {
this.updateChart();
}
}

talksValueChanged() {
if (this.isInitialized) {
this.updateChart();
}
}

updateChart() {
if (this.chart) {
this.chart.destroy();
}
this.renderChart();
}

renderChart() {
const styles = getComputedStyle(document.documentElement);
const labelColor = styles.getPropertyValue('--tblr-body-color').trim();
const primaryColor = styles.getPropertyValue('--tblr-primary').trim();
const isDark = document.documentElement.getAttribute('data-bs-theme') === 'dark';

const options = {
colors: [primaryColor],
fill: {
colors: [primaryColor]
},
series: [{
name: 'talks',
data: this.talksValue
}],
chart: {
toolbar: {
show: false
},
height: 350,
type: 'bar'
},
plotOptions: {
bar: {
borderRadius: 4,
dataLabels: {
position: 'top'
}
}
},
dataLabels: {
enabled: true,
offsetY: -20,
style: {
fontSize: '12px',
colors: [labelColor]
}
},
xaxis: {
categories: this.intervalsValue,
position: 'top',
labels: {
style: {
colors: labelColor
}
},
axisBorder: {
show: false
},
axisTicks: {
show: false
},
crosshairs: {
fill: {
type: 'gradient',
gradient: {
colorFrom: primaryColor,
colorTo: primaryColor,
stops: [0, 100],
opacityFrom: 0.4,
opacityTo: 0.5
}
}
},
tooltip: {
enabled: true
}
},
yaxis: {
axisBorder: {
show: false
},
axisTicks: {
show: false
},
labels: {
show: false,
}
},
title: {
floating: true,
offsetY: 330,
align: 'center',
style: {
color: labelColor
}
},
tooltip: {
theme: isDark ? 'dark' : 'light'
}
};

this.chart = new ApexCharts(this.element, options);
this.chart.render();
}

observeThemeChanges() {
this.themeObserver = new MutationObserver(() => {
this.updateChart();
});

this.themeObserver.observe(document.documentElement, {
attributes: true,
attributeFilter: ['data-bs-theme']
});
}
}
134 changes: 0 additions & 134 deletions assets/scripts/statistics_chart.js

This file was deleted.

4 changes: 2 additions & 2 deletions assets/styles/app.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
body {
background-color: skyblue;
:root {
--tblr-primary: red !important;
}
33 changes: 16 additions & 17 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,13 @@
"league/csv": "^9.0",
"pagerfanta/doctrine-orm-adapter": "^4.6",
"pagerfanta/twig": "^4.6",
"sylius/admin-ui": "@dev",
"sylius/bootstrap-admin-ui": "@dev",
"sylius/grid-bundle": "^1.13 || ^1.15@alpha",
"sylius/resource-bundle": "^1.13 || ^1.14@alpha",
"sylius/twig-extra": "@dev",
"sylius/twig-hooks": "@dev",
"sylius/ui-translations": "@dev",
"symfony/asset": "^6.4 || ^7.4 || ^8.0",
"symfony/asset-mapper": "^6.4 || ^7.4 || ^8.0",
"symfony/config": "^6.4 || ^7.4 || ^8.0",
Expand Down Expand Up @@ -69,15 +74,7 @@
"vich/uploader-bundle": "^2.4",
"zenstruck/foundry": "^2.0"
},
"autoload": {
"psr-4": {
"Sylius\\AdminUi\\": "src/AdminUi/src/",
"Sylius\\BootstrapAdminUi\\": "src/BootstrapAdminUi/src/",
"Sylius\\TwigExtra\\": "src/TwigExtra/src/",
"Sylius\\TwigHooks\\": "src/TwigHooks/src/",
"Sylius\\UiTranslations\\": "src/UiTranslations/src/"
}
},
"autoload": {},
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

todo: double check if we can keep the autoload here. I think it'll be simplier for IDE integration

"autoload-dev": {
"psr-4": {
"App\\": "app/",
Expand All @@ -93,13 +90,15 @@
"Tests\\Sylius\\UiTranslations\\": "src/UiTranslations/tests/"
}
},
"replace": {
"sylius/admin-ui": "self.version",
"sylius/bootstrap-admin-ui": "self.version",
"sylius/twig-extra": "self.version",
"sylius/twig-hooks": "self.version",
"sylius/ui-translations": "self.version"
},
"repositories": [
{
"type": "path",
"url": "./src/*/",
"options": {
"symlink": true
}
}
],
"config": {
"allow-plugins": {
"symfony/flex": true,
Expand All @@ -126,4 +125,4 @@
"@auto-scripts"
]
}
}
}
Loading
Loading