From dd3e9e68b254c982c27a3ede872c4ac8d0b9827d Mon Sep 17 00:00:00 2001 From: Paul Weidner Date: Fri, 25 Aug 2023 11:50:02 -0700 Subject: [PATCH 1/6] Remove unnecessary default container div This only adds a div to the markup that is not used to style or arrange the panes within a region. --- .../ui/dashboard/src/Controller/DashboardController.php | 9 --------- 1 file changed, 9 deletions(-) diff --git a/modules/core/ui/dashboard/src/Controller/DashboardController.php b/modules/core/ui/dashboard/src/Controller/DashboardController.php index f6c0cb92d..f1344b95c 100644 --- a/modules/core/ui/dashboard/src/Controller/DashboardController.php +++ b/modules/core/ui/dashboard/src/Controller/DashboardController.php @@ -72,15 +72,6 @@ class DashboardController extends ControllerBase { // Ask modules for dashboard groups. $build = $this->moduleHandler()->invokeAll('farm_dashboard_groups'); - // Default the group #type to container if none was provided. - foreach ($build as $region => $groups) { - foreach ($groups as $name => $group) { - if (!empty($group) && empty($group['#type'])) { - $build[$region][$name]['#type'] = 'container'; - } - } - } - // Ask modules for dashboard panes. $panes = $this->moduleHandler()->invokeAll('farm_dashboard_panes'); From 74dfee50243e01ee2c5a6d94819df43d8ec53dd5 Mon Sep 17 00:00:00 2001 From: Paul Weidner Date: Fri, 25 Aug 2023 11:57:43 -0700 Subject: [PATCH 2/6] Add dashboard-pane attribute to help target dashboard panes --- .../core/ui/dashboard/src/Controller/DashboardController.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/core/ui/dashboard/src/Controller/DashboardController.php b/modules/core/ui/dashboard/src/Controller/DashboardController.php index f1344b95c..bdaeb1167 100644 --- a/modules/core/ui/dashboard/src/Controller/DashboardController.php +++ b/modules/core/ui/dashboard/src/Controller/DashboardController.php @@ -154,6 +154,9 @@ class DashboardController extends ControllerBase { $container = [ '#type' => 'container', '#weight' => $weight, + '#attributes' => [ + 'class' => ['dashboard-pane'], + ], ]; // If a title is set, make it a fieldset. From a1957448035c2ec3cc8b90b080a50b9177ea76fd Mon Sep 17 00:00:00 2001 From: Paul Weidner Date: Thu, 7 Sep 2023 10:53:06 -0700 Subject: [PATCH 3/6] Use flexbox to position and space dashboard panes --- .../ui/dashboard/css/dashboard_layout.css | 8 ------- .../dashboard/farm_ui_dashboard.libraries.yml | 4 ---- .../src/Controller/DashboardController.php | 2 -- modules/core/ui/theme/css/dashboard.css | 23 +++++++++++++++++++ .../core/ui/theme/farm_ui_theme.libraries.yml | 4 ++++ modules/core/ui/theme/farm_ui_theme.module | 7 ++++++ 6 files changed, 34 insertions(+), 14 deletions(-) delete mode 100644 modules/core/ui/dashboard/css/dashboard_layout.css delete mode 100644 modules/core/ui/dashboard/farm_ui_dashboard.libraries.yml create mode 100644 modules/core/ui/theme/css/dashboard.css diff --git a/modules/core/ui/dashboard/css/dashboard_layout.css b/modules/core/ui/dashboard/css/dashboard_layout.css deleted file mode 100644 index 52c746bfa..000000000 --- a/modules/core/ui/dashboard/css/dashboard_layout.css +++ /dev/null @@ -1,8 +0,0 @@ -.layout--twocol .layout__region { - box-sizing: border-box; - overflow-x: scroll; -} - -.layout--twocol .layout__region--first { - padding-right: 1.5em; -} diff --git a/modules/core/ui/dashboard/farm_ui_dashboard.libraries.yml b/modules/core/ui/dashboard/farm_ui_dashboard.libraries.yml deleted file mode 100644 index 7f49a9bcd..000000000 --- a/modules/core/ui/dashboard/farm_ui_dashboard.libraries.yml +++ /dev/null @@ -1,4 +0,0 @@ -dashboard_layout: - css: - theme: - css/dashboard_layout.css: { } diff --git a/modules/core/ui/dashboard/src/Controller/DashboardController.php b/modules/core/ui/dashboard/src/Controller/DashboardController.php index bdaeb1167..facdd5bf7 100644 --- a/modules/core/ui/dashboard/src/Controller/DashboardController.php +++ b/modules/core/ui/dashboard/src/Controller/DashboardController.php @@ -185,8 +185,6 @@ class DashboardController extends ControllerBase { // Build the layout. $render = $layoutInstance->build($regions); - // Add the dashboard_layout styles. - $render['#attached']['library'][] = 'farm_ui_dashboard/dashboard_layout'; return $render; } diff --git a/modules/core/ui/theme/css/dashboard.css b/modules/core/ui/theme/css/dashboard.css new file mode 100644 index 000000000..9ff7efe0a --- /dev/null +++ b/modules/core/ui/theme/css/dashboard.css @@ -0,0 +1,23 @@ +/* Add a gap between layout regions. */ +.layout--twocol { + --dashboard-spacing: var(--gin-spacing-s); + gap: var(--dashboard-spacing); +} + +/* Use flexbox within each region. */ +.layout--twocol .layout__region, +.layout--twocol .layout__region { + flex-basis: 100%; + display: flex; + flex-direction: column; + gap: var(--dashboard-spacing); +} + +/* Split first and second regions to two columns on large screens. */ +@media (min-width: 48em) { + .layout--twocol .layout__region--first, + .layout--twocol .layout__region--second { + flex-basis: 50%; + max-width: calc(50% - var(--dashboard-spacing)*.5); + } +} diff --git a/modules/core/ui/theme/farm_ui_theme.libraries.yml b/modules/core/ui/theme/farm_ui_theme.libraries.yml index 4d20f1aff..8545f23e5 100644 --- a/modules/core/ui/theme/farm_ui_theme.libraries.yml +++ b/modules/core/ui/theme/farm_ui_theme.libraries.yml @@ -2,6 +2,10 @@ asset_map_popup: css: theme: css/asset_map_popup.css: { } +dashboard: + css: + theme: + css/dashboard.css: { } flag: css: theme: diff --git a/modules/core/ui/theme/farm_ui_theme.module b/modules/core/ui/theme/farm_ui_theme.module index d85d629df..5e6a1b510 100644 --- a/modules/core/ui/theme/farm_ui_theme.module +++ b/modules/core/ui/theme/farm_ui_theme.module @@ -109,6 +109,13 @@ function farm_ui_theme_preprocess_log__full(&$variables) { $variables['#attached']['library'][] = 'farm_ui_theme/layout'; } +/** + * Implements hook_preprocess_HOOK(). + */ +function farm_ui_theme_preprocess_page__dashboard(&$variables) { + $variables['#attached']['library'][] = 'farm_ui_theme/dashboard'; +} + /** * Implements hook_preprocess_HOOK(). */ From 7167016488f77decee75d221b7de9bccf34e3321 Mon Sep 17 00:00:00 2001 From: Paul Weidner Date: Thu, 7 Sep 2023 10:54:03 -0700 Subject: [PATCH 4/6] Style dashboard fieldsets similar to gin-layer-wrapper --- modules/core/ui/theme/css/dashboard.css | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/modules/core/ui/theme/css/dashboard.css b/modules/core/ui/theme/css/dashboard.css index 9ff7efe0a..a71fb3d7e 100644 --- a/modules/core/ui/theme/css/dashboard.css +++ b/modules/core/ui/theme/css/dashboard.css @@ -21,3 +21,13 @@ max-width: calc(50% - var(--dashboard-spacing)*.5); } } + +/* Style dashboard fieldsets similar to gin-layer-wrapper. */ +.layout__region > fieldset.dashboard-pane { + margin: 0; + padding-top: var(--gin-spacing-m); + background: var(--gin-bg-layer); + border: 1px solid var(--gin-border-color-layer); + box-shadow: var(--gin-shadow-l1); + border-radius: var(--gin-border-l); +} From 14b63d748d234090b4e34342c5c0928657ae1eb3 Mon Sep 17 00:00:00 2001 From: Paul Weidner Date: Thu, 7 Sep 2023 10:54:35 -0700 Subject: [PATCH 5/6] Reduce spacing within dashboard fieldsets --- modules/core/ui/theme/css/dashboard.css | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/modules/core/ui/theme/css/dashboard.css b/modules/core/ui/theme/css/dashboard.css index a71fb3d7e..d7b6e2327 100644 --- a/modules/core/ui/theme/css/dashboard.css +++ b/modules/core/ui/theme/css/dashboard.css @@ -31,3 +31,17 @@ box-shadow: var(--gin-shadow-l1); border-radius: var(--gin-border-l); } + +/* Reduce spacing within dashboard fieldsets. */ +.layout__region > fieldset.dashboard-pane .fieldset__label { + padding: 0 var(--gin-spacing-m); +} +.layout__region > fieldset.dashboard-pane .fieldset__wrapper { + margin: 0 var(--gin-spacing-m) var(--gin-spacing-m) var(--gin-spacing-m); +} + +/* Increase fieldset font. */ +.layout__region > fieldset.dashboard-pane .fieldset__label { + font-size: var(--gin-font-size-l); + font-weight: var(--gin-font-weight-bold); +} From 86718da176ac0fc3e24ee1f23e5f821d25fd6f12 Mon Sep 17 00:00:00 2001 From: Michael Stenta Date: Thu, 5 Oct 2023 10:26:45 -0400 Subject: [PATCH 6/6] Add CHANGELOG.md line for #712. --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ae4044be5..51bf9d04d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +- [Dashboard improvements #712](https://github.com/farmOS/farmOS/pull/712) - [Misc quick form code and documentation improvements #703](https://github.com/farmOS/farmOS/pull/703) ### Deprecated