From cdc07c42fdd24bc83b33b4b9325e99f9bfb2b41b Mon Sep 17 00:00:00 2001 From: Nico Hoffmann Date: Thu, 2 Nov 2023 22:07:55 +0100 Subject: [PATCH 01/75] Revert autoresize scroll restore --- panel/src/components/Forms/Autosize.js | 13 ------------- panel/src/components/Forms/Input/TextareaInput.vue | 4 +++- 2 files changed, 3 insertions(+), 14 deletions(-) diff --git a/panel/src/components/Forms/Autosize.js b/panel/src/components/Forms/Autosize.js index efcaadb847..80ad83ff5f 100644 --- a/panel/src/components/Forms/Autosize.js +++ b/panel/src/components/Forms/Autosize.js @@ -17,12 +17,10 @@ export default class Autosize extends HTMLElement { textarea.autosize = () => { textarea.style.height = "auto"; textarea.style.height = textarea.scrollHeight + "px"; - this.restoreScroll(); }; // trigger resize on input textarea.addEventListener("input", () => textarea.autosize()); - textarea.addEventListener("beforeinput", () => this.storeScroll()); } // resize all textareas when the container size changes @@ -38,15 +36,4 @@ export default class Autosize extends HTMLElement { disconnectedCallback() { this.resizer.unobserve(this); } - - restoreScroll() { - if (this.scrollY !== undefined) { - window.scroll(0, this.scrollY); - this.scroll = undefined; - } - } - - storeScroll() { - this.scrollY = window.scrollY; - } } diff --git a/panel/src/components/Forms/Input/TextareaInput.vue b/panel/src/components/Forms/Input/TextareaInput.vue index 3525fe0183..c4f6040573 100644 --- a/panel/src/components/Forms/Input/TextareaInput.vue +++ b/panel/src/components/Forms/Input/TextareaInput.vue @@ -112,8 +112,10 @@ export default { } }, watch: { - value() { + async value() { this.onInvalid(); + await this.$nextTick(); + this.$refs.input.autosize(); } }, mounted() { From 48e9f54e6853dddc2c4029fbe2d5d4735b338ad6 Mon Sep 17 00:00:00 2001 From: Nico Hoffmann Date: Thu, 2 Nov 2023 23:30:39 +0100 Subject: [PATCH 02/75] Exclude UI docs and lab from regular bundle --- .gitattributes | 2 + config/areas/lab/drawers.php | 9 ++++ config/areas/lab/views.php | 61 +++++++++++++++++--------- panel/src/components/Lab/IndexView.vue | 6 +++ src/Panel/Lab/Category.php | 5 +++ src/Panel/Lab/Docs.php | 17 ++++++- 6 files changed, 78 insertions(+), 22 deletions(-) diff --git a/.gitattributes b/.gitattributes index 3db48397e3..01e107ec49 100644 --- a/.gitattributes +++ b/.gitattributes @@ -15,7 +15,9 @@ tests/ export-ignore panel/.env.example export-ignore panel/.eslintrc.js export-ignore panel/.prettierrc.json export-ignore +panel/dist/ui export-ignore panel/jsconfig.json export-ignore +panel/lab export-ignore panel/package-lock.json export-ignore panel/package.json export-ignore panel/public export-ignore diff --git a/config/areas/lab/drawers.php b/config/areas/lab/drawers.php index 24a80acf54..9d16d81f14 100644 --- a/config/areas/lab/drawers.php +++ b/config/areas/lab/drawers.php @@ -6,6 +6,15 @@ 'lab.docs' => [ 'pattern' => 'lab/docs/(:any)', 'load' => function (string $component) { + if (Docs::installed() === false) { + return [ + 'component' => 'k-text-drawer', + 'props' => [ + 'text' => 'The UI docs are not installed.' + ] + ]; + } + $docs = new Docs($component); return [ diff --git a/config/areas/lab/views.php b/config/areas/lab/views.php index 9753d63883..53428dda99 100644 --- a/config/areas/lab/views.php +++ b/config/areas/lab/views.php @@ -10,8 +10,9 @@ return [ 'component' => 'k-lab-index-view', 'props' => [ - 'tab' => 'examples', 'categories' => Category::all(), + 'info' => Category::installed() ? null : 'The default Lab examples are not installed.', + 'tab' => 'examples', ], ]; } @@ -19,6 +20,17 @@ 'lab.docs' => [ 'pattern' => 'lab/docs', 'action' => function () { + $props = match (Docs::installed()) { + true => [ + 'categories' => [['examples' => Docs::all()]], + 'tab' => 'docs', + ], + false => [ + 'info' => 'The UI docs are not installed.', + 'tab' => 'docs', + ] + }; + return [ 'component' => 'k-lab-index-view', 'title' => 'Docs', @@ -28,34 +40,43 @@ 'link' => 'lab/docs' ] ], - 'props' => [ - 'tab' => 'docs', - 'categories' => [ - ['examples' => Docs::all()] - ], - ], + 'props' => $props, ]; } ], 'lab.doc' => [ 'pattern' => 'lab/docs/(:any)', 'action' => function (string $component) { + $crumbs = [ + [ + 'label' => 'Docs', + 'link' => 'lab/docs' + ], + [ + 'label' => $component, + 'link' => 'lab/docs/' . $component + ] + ]; + + if (Docs::installed() === false) { + return [ + 'component' => 'k-lab-index-view', + 'title' => $component, + 'breadcrumb' => $crumbs, + 'props' => [ + 'info' => 'The UI docs are not installed.', + 'tab' => 'docs', + ], + ]; + } + $docs = new Docs($component); return [ - 'component' => 'k-lab-docs-view', - 'title' => $component, - 'breadcrumb' => [ - [ - 'label' => 'Docs', - 'link' => 'lab/docs' - ], - [ - 'label' => $component, - 'link' => 'lab/docs/' . $component - ] - ], - 'props' => [ + 'component' => 'k-lab-docs-view', + 'title' => $component, + 'breadcrumb' => $crumbs, + 'props' => [ 'component' => $component, 'docs' => $docs->toArray(), 'lab' => $docs->lab() diff --git a/panel/src/components/Lab/IndexView.vue b/panel/src/components/Lab/IndexView.vue index 9bdca66753..60040622ad 100644 --- a/panel/src/components/Lab/IndexView.vue +++ b/panel/src/components/Lab/IndexView.vue @@ -10,6 +10,8 @@ ]" /> + + id; } + public static function installed(): bool + { + return Dir::exists(static::base()) === true; + } + public function name(): string { return $this->props['name'] ?? ucfirst($this->id); diff --git a/src/Panel/Lab/Docs.php b/src/Panel/Lab/Docs.php index 3e92c0b320..44a6af0361 100644 --- a/src/Panel/Lab/Docs.php +++ b/src/Panel/Lab/Docs.php @@ -36,8 +36,8 @@ public function __construct( public static function all(): array { - $dist = App::instance()->root('panel') . '/dist/ui'; - $tmp = App::instance()->root('panel') . '/tmp'; + $dist = static::root(); + $tmp = static::root(true); $files = Dir::inventory($dist)['files']; if (Dir::exists($tmp) === true) { @@ -131,6 +131,11 @@ public function github(): string return 'https://github.com/getkirby/kirby/tree/main/panel/' . $this->json['sourceFile']; } + public static function installed(): bool + { + return Dir::exists(static::root()) === true; + } + protected function kt(string $text, bool $inline = false): string { return $this->kirby->kirbytext($text, [ @@ -278,6 +283,14 @@ protected function read(): array return Data::read($file); } + public static function root(bool $tmp = false): string + { + return App::instance()->root('panel') . '/' . match ($tmp) { + true => 'tmp', + default => 'dist/ui', + }; + } + public function since(): string|null { return $this->json['tags']['since'][0]['description'] ?? null; From 6451075c5b699c016cc3073287f4cd5190b1e445 Mon Sep 17 00:00:00 2001 From: Nico Hoffmann Date: Thu, 2 Nov 2023 22:45:57 +0100 Subject: [PATCH 03/75] Icon for `k-stat` --- config/areas/system/views.php | 17 +++--- panel/lab/components/stats/1_stats/index.vue | 14 +++-- panel/lab/components/stats/2_stat/index.vue | 3 ++ panel/src/components/Layout/Stat.vue | 41 ++++++++------- tests/Panel/Areas/SystemTest.php | 54 +++++++++++--------- 5 files changed, 74 insertions(+), 55 deletions(-) diff --git a/config/areas/system/views.php b/config/areas/system/views.php index dab7de6cfd..b786f06c9a 100644 --- a/config/areas/system/views.php +++ b/config/areas/system/views.php @@ -17,25 +17,26 @@ 'label' => $license ? I18n::translate('license') : I18n::translate('license.register.label'), 'value' => $license ? 'Kirby 3' : I18n::translate('license.unregistered.label'), 'theme' => $license ? null : 'negative', + 'icon' => $license ? 'info' : 'key', 'dialog' => $license ? 'license' : 'registration' ], [ 'label' => $updateStatus?->label() ?? I18n::translate('version'), 'value' => $kirby->version(), - 'link' => ( - $updateStatus ? - $updateStatus->url() : - 'https://github.com/getkirby/kirby/releases/tag/' . $kirby->version() - ), - 'theme' => $updateStatus?->theme() + 'link' => $updateStatus?->url() ?? + 'https://github.com/getkirby/kirby/releases/tag/' . $kirby->version(), + 'theme' => $updateStatus?->theme(), + 'icon' => $updateStatus?->icon() ?? 'info' ], [ 'label' => 'PHP', - 'value' => phpversion() + 'value' => phpversion(), + 'icon' => 'code' ], [ 'label' => I18n::translate('server'), - 'value' => $system->serverSoftware() ?? '?' + 'value' => $system->serverSoftware() ?? '?', + 'icon' => 'server' ] ]; diff --git a/panel/lab/components/stats/1_stats/index.vue b/panel/lab/components/stats/1_stats/index.vue index 30ea13fc7c..2c3c4515de 100644 --- a/panel/lab/components/stats/1_stats/index.vue +++ b/panel/lab/components/stats/1_stats/index.vue @@ -18,27 +18,31 @@ export default { label: "Views", value: "12.250", info: "+120%", - theme: "positive" + theme: "positive", + icon: "preview" }, { label: "Visitors", value: "3.500", info: "0%", - theme: "info" + theme: "info", + icon: "users" }, { label: "Searches", value: "1.250", info: "-10%", - theme: "negative" + theme: "negative", + icon: "search" } ]; }, reportsWithoutTheme() { - return this.$helper.clone(this.reports).map(report => { + return this.$helper.clone(this.reports).map((report) => { + report.icon = null; report.theme = null; return report; - }) + }); } } }; diff --git a/panel/lab/components/stats/2_stat/index.vue b/panel/lab/components/stats/2_stat/index.vue index d5be376c8a..b855ad1a5d 100644 --- a/panel/lab/components/stats/2_stat/index.vue +++ b/panel/lab/components/stats/2_stat/index.vue @@ -1,5 +1,8 @@