-
Notifications
You must be signed in to change notification settings - Fork 31
[BootstrapAdminUI] Expose as ux bundle #362
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
07c57db
d91ce50
c1523cd
28de28d
2854fd0
3f94c88
f4e1b41
c517904
9964c1c
b2715ab
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
|
|
||
| import '@sylius/bootstrap-admin-ui/entrypoint'; | ||
|
|
||
| import './styles/app.css'; | ||
| 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 | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤔 maybe remove this file, or use it instead admin_entry |
||
|
|
||
| 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 { | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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'] | ||
| }); | ||
| } | ||
| } | ||
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| body { | ||
| background-color: skyblue; | ||
| :root { | ||
| --tblr-primary: red !important; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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", | ||
|
|
@@ -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": {}, | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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/", | ||
|
|
@@ -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, | ||
|
|
@@ -126,4 +125,4 @@ | |
| "@auto-scripts" | ||
| ] | ||
| } | ||
| } | ||
| } | ||
There was a problem hiding this comment.
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)