Skip to content
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

Icon for k-stat #5908

Merged
merged 2 commits into from
Nov 3, 2023
Merged
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
17 changes: 9 additions & 8 deletions config/areas/system/views.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'
]
];

Expand Down
14 changes: 9 additions & 5 deletions panel/lab/components/stats/1_stats/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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;
})
});
}
}
};
Expand Down
3 changes: 3 additions & 0 deletions panel/lab/components/stats/2_stat/index.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<template>
<k-lab-examples>
<k-lab-example label="icon">
<k-stat label="Pages" value="123" info="Last week" icon="page" />
</k-lab-example>
<k-lab-example label="theme">
<k-stat label="Pages" value="123" info="Last week" theme="info" />
</k-lab-example>
Expand Down
41 changes: 22 additions & 19 deletions panel/src/components/Layout/Stat.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<template>
<component :is="component" :data-theme="theme" :to="target" class="k-stat">
<dt v-if="label" class="k-stat-label">{{ label }}</dt>
<dt v-if="label" class="k-stat-label">
<k-icon v-if="icon" :type="icon" />

{{ label }}
</dt>
<dd v-if="value" class="k-stat-value">{{ value }}</dd>
<dd v-if="info" class="k-stat-info">{{ info }}</dd>
</component>
Expand All @@ -18,37 +22,30 @@ export default {
/**
* Label text of the stat (2nd line)
*/
label: {
type: String
},
label: String,
/**
* Main text of the stat (1st line)
*/
value: {
type: String
},
value: String,
/**
* Additional icon for the stat
* @since 4.0.0
*/
icon: String,
/**
* Additional text of the stat (3rd line)
*/
info: {
type: String
},
info: String,
/**
* @values "negative", "positive", "warning", "info"
*/
theme: {
type: String
},
theme: String,
/** Absolute or relative URL */
link: {
type: String
},
link: String,
/**
* Function to be called when clicked
*/
click: {
type: Function
},
click: Function,
/**
* Dialog endpoint or options to be passed to `this.$dialog`
*/
Expand Down Expand Up @@ -111,7 +108,13 @@ export default {
margin-bottom: var(--spacing-1);
}
.k-stat-label {
--icon-size: var(--text-sm);

order: 2;
display: flex;
justify-content: start;
align-items: center;
gap: var(--spacing-1);
font-size: var(--text-xs);
}
.k-stat-info {
Expand Down
54 changes: 31 additions & 23 deletions tests/Panel/Areas/SystemTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,40 +49,44 @@ public function testView(): void
$this->assertSame('k-system-view', $view['component']);
$this->assertSame([
[
'label' => 'Please enter your license code',
'value' => 'Unregistered',
'theme' => 'negative',
'label' => 'Please enter your license code',
'value' => 'Unregistered',
'theme' => 'negative',
'icon' => 'key',
'dialog' => 'registration'
],
[
'label' => 'Free update 88888.8.8 available',
'value' => $this->app->version(),
'link' => 'https://getkirby.com/releases/88888.8.8',
'theme' => 'info'
'link' => 'https://getkirby.com/releases/88888.8.8',
'theme' => 'info',
'icon' => 'info'
],
[
'label' => 'PHP',
'value' => phpversion()
'value' => phpversion(),
'icon' => 'code'
],
[
'label' => 'Server',
'value' => 'php'
'value' => 'php',
'icon' => 'server'
],
], $props['environment']);
$this->assertSame([], $props['exceptions']);
$this->assertSame([], $props['plugins']);
$this->assertSame([
[
'text' => 'This is a very important announcement!',
'text' => 'This is a very important announcement!',
'kirby' => '*',
'php' => '*'
'php' => '*'
]
], $props['security']);
$this->assertSame([
'content' => 'https://example.com/content/site.txt',
'git' => null,
'kirby' => null,
'site' => 'https://example.com/site'
'git' => null,
'kirby' => null,
'site' => 'https://example.com/site'
], $props['urls']);
}

Expand All @@ -102,9 +106,9 @@ public function testViewDebug(): void
$this->assertSame([], $props['exceptions']);
$this->assertSame([
[
'text' => 'This is a very important announcement!',
'text' => 'This is a very important announcement!',
'kirby' => '*',
'php' => '*'
'php' => '*'
],
[
'id' => 'debug',
Expand All @@ -129,9 +133,9 @@ public function testViewHttps(): void

$this->assertSame([
[
'text' => 'This is a very important announcement!',
'text' => 'This is a very important announcement!',
'kirby' => '*',
'php' => '*'
'php' => '*'
],
[
'id' => 'https',
Expand Down Expand Up @@ -358,24 +362,28 @@ public function testViewWithoutUpdateCheck(): void

$this->assertSame([
[
'label' => 'Please enter your license code',
'value' => 'Unregistered',
'theme' => 'negative',
'label' => 'Please enter your license code',
'value' => 'Unregistered',
'theme' => 'negative',
'icon' => 'key',
'dialog' => 'registration'
],
[
'label' => 'Version',
'value' => $this->app->version(),
'link' => 'https://github.com/getkirby/kirby/releases/tag/' . $this->app->version(),
'theme' => null
'link' => 'https://github.com/getkirby/kirby/releases/tag/' . $this->app->version(),
'theme' => null,
'icon' => 'info'
],
[
'label' => 'PHP',
'value' => phpversion()
'value' => phpversion(),
'icon' => 'code'
],
[
'label' => 'Server',
'value' => 'php'
'value' => 'php',
'icon' => 'server'
],
], $props['environment']);
$this->assertSame([], $props['security']);
Expand Down