Skip to content

Commit 37d3312

Browse files
nickvergessennextcloud-command
authored andcommitted
fix(dashboard): Document expected icon behaviour
Signed-off-by: Joas Schilling <coding@schilljs.com> Signed-off-by: nextcloud-command <nextcloud-command@users.noreply.github.com>
1 parent 5368b93 commit 37d3312

File tree

3 files changed

+24
-5
lines changed

3 files changed

+24
-5
lines changed

lib/private/Dashboard/Manager.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,23 @@ class Manager implements IManager {
2525
/** @var array<string, IWidget> */
2626
private array $widgets = [];
2727

28-
private ContainerInterface $serverContainer;
2928
private ?IAppManager $appManager = null;
3029

31-
public function __construct(ContainerInterface $serverContainer) {
32-
$this->serverContainer = $serverContainer;
30+
public function __construct(
31+
private ContainerInterface $serverContainer,
32+
private LoggerInterface $logger,
33+
) {
3334
}
3435

3536
private function registerWidget(IWidget $widget): void {
3637
if (array_key_exists($widget->getId(), $this->widgets)) {
3738
throw new InvalidArgumentException('Dashboard widget with this id has already been registered');
3839
}
3940

41+
if (!preg_match('/^[a-z][a-z0-9\-_]*$/', $widget->getId())) {
42+
$this->logger->debug('Deprecated dashboard widget ID provided: "' . $widget->getId() . '" [ ' . get_class($widget) . ' ]. Please use a-z, 0-9, - and _ only, starting with a-z');
43+
}
44+
4045
$this->widgets[$widget->getId()] = $widget;
4146
}
4247

lib/public/Dashboard/IIconWidget.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
*/
1515
interface IIconWidget extends IWidget {
1616
/**
17-
* Get the absolute url for the widget icon
17+
* Get the absolute url for the widget icon (should be colored black or not have a color)
18+
*
19+
* The icon will be inverted automatically in mobile clients and when using dark mode
1820
*
1921
* @return string
2022
* @since 25.0.0

lib/public/Dashboard/IWidget.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,12 @@
1515
*/
1616
interface IWidget {
1717
/**
18-
* @return string Unique id that identifies the widget, e.g. the app id
18+
* Get a unique identifier for the widget
19+
*
20+
* To ensure uniqueness, it is recommended to user the app id or start with the
21+
* app id followed by a dash.
22+
*
23+
* @return string Unique id that identifies the widget, e.g. the app id. Only use alphanumeric characters, dash and underscore
1924
* @since 20.0.0
2025
*/
2126
public function getId(): string;
@@ -33,6 +38,13 @@ public function getTitle(): string;
3338
public function getOrder(): int;
3439

3540
/**
41+
* CSS class that shows the widget icon (should be colored black or not have a color)
42+
*
43+
* The icon will be inverted automatically in mobile clients and when using dark mode.
44+
* Therefore, it is NOT recommended to use a css class that sets the background with:
45+
* `var(--icon-…)` as those will adapt to dark/bright mode in the web and still be inverted
46+
* resulting in a dark icon on dark background.
47+
*
3648
* @return string css class that displays an icon next to the widget title
3749
* @since 20.0.0
3850
*/

0 commit comments

Comments
 (0)