Skip to content

Commit

Permalink
fix(dashboard): Document expected icon behaviour
Browse files Browse the repository at this point in the history
Signed-off-by: Joas Schilling <coding@schilljs.com>
  • Loading branch information
nickvergessen committed Jul 11, 2024
1 parent 6df81d7 commit 3f1e79d
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 5 deletions.
11 changes: 8 additions & 3 deletions lib/private/Dashboard/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,23 @@ class Manager implements IManager {
/** @var array<string, IWidget> */
private array $widgets = [];

private ContainerInterface $serverContainer;
private ?IAppManager $appManager = null;

public function __construct(ContainerInterface $serverContainer) {
$this->serverContainer = $serverContainer;
public function __construct(
private ContainerInterface $serverContainer,
private LoggerInterface $logger,
) {
}

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

if (!preg_match('/^[a-z][a-z0-9\-_]*$/', $widget->getId())) {
$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');
}

$this->widgets[$widget->getId()] = $widget;
}

Expand Down
4 changes: 3 additions & 1 deletion lib/public/Dashboard/IIconWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
*/
interface IIconWidget extends IWidget {
/**
* Get the absolute url for the widget icon
* Get the absolute url for the widget icon (should be colored black or not have a color)
*
* The icon will be inverted automatically in mobile clients and when using dark mode
*
* @return string
* @since 25.0.0
Expand Down
14 changes: 13 additions & 1 deletion lib/public/Dashboard/IWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,12 @@
*/
interface IWidget {
/**
* @return string Unique id that identifies the widget, e.g. the app id
* Get a unique identifier for the widget
*
* To ensure uniqueness, it is recommended to user the app id or start with the
* app id followed by a dash.
*
* @return string Unique id that identifies the widget, e.g. the app id. Only use alphanumeric characters, dash and underscore
* @since 20.0.0
*/
public function getId(): string;
Expand All @@ -33,6 +38,13 @@ public function getTitle(): string;
public function getOrder(): int;

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

0 comments on commit 3f1e79d

Please sign in to comment.