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

Add EmptyStateBar widget #204

Merged
merged 2 commits into from
Sep 13, 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
11 changes: 11 additions & 0 deletions asset/css/empty-state.less
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
.empty-state {
color: @empty-state-color;
}

.empty-state-bar {
padding: 1em;
text-align: center;

.rounded-corners();
background-color: @empty-state-bar-bg;
}
9 changes: 1 addition & 8 deletions asset/css/list/item-list.less
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@

.item-list {
list-style-type: none;

> .empty-state {
.rounded-corners();
background-color: @empty-state-bg-in-lists;
}
}

// Layout
Expand Down Expand Up @@ -55,10 +50,8 @@
}
}

> .empty-state {
> .empty-state-bar {
margin: 0 1em;
padding: 1em;
text-align: center;
}
}

Expand Down
11 changes: 1 addition & 10 deletions asset/css/list/item-table.less
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,6 @@ ul.item-table {
list-style-type: none;
}

div.item-table {
> .empty-state {
.rounded-corners();
background-color: @empty-state-bg-in-lists;
}
}

.table-row {
color: @default-text-color-light;

Expand Down Expand Up @@ -87,10 +80,8 @@ ul.item-table {
}

div.item-table {
> .empty-state {
> .empty-state-bar {
margin: 0 1em;
padding: 1em;
text-align: center;
}
}

Expand Down
10 changes: 8 additions & 2 deletions asset/css/variables.less
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
@base-gray: #c4c4c4;
@base-gray-light: #5c5c5c;
@base-gray-lighter: #4b4b4b;
@base-gray-semilight: #888;
@base-disabled: #9a9a9a;

@base-primary-color: #00C3ED;
Expand Down Expand Up @@ -121,7 +122,9 @@
@schedule-element-fields-disabled-selected-bg: @base-gray-light;
@schedule-element-keyboard-note-bg: @base-gray-light;

@empty-state-bg-in-lists: @base-gray-lighter;
@empty-state-color: @base-gray-semilight;
@empty-state-bar-bg: @base-gray-lighter;

@list-item-title-hover-color: @base-primary-color;
@list-item-separation-bg: @base-gray-light;

Expand All @@ -130,6 +133,7 @@
--base-gray: #819398;
--base-gray-light: #d0d3da;
--base-gray-lighter: #e8ecef;
--base-gray-semilight: #94a5a6;
--base-disabled: var(--base-gray-light);

--base-remove-bg: @state-critical;
Expand Down Expand Up @@ -204,7 +208,9 @@
--schedule-element-fields-disabled-selected-bg: var(--base-gray-light);
--schedule-element-keyboard-note-bg: var(--base-gray-light);

--empty-state-bg-in-lists: var(--base-gray-lighter);
--empty-state-color: var(--base-gray-semilight);
--empty-state-bar-bg: var(--base-gray-lighter);

--list-item-title-hover-color: var(--base-primary-color);
--list-item-separation-bg: var(--base-gray-light);
}
Expand Down
4 changes: 2 additions & 2 deletions src/Common/BaseItemList.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use ipl\Html\BaseHtmlElement;
use ipl\Orm\ResultSet;
use ipl\Stdlib\BaseFilter;
use ipl\Web\Widget\EmptyState;
use ipl\Web\Widget\EmptyStateBar;

/**
* Base class for item lists
Expand Down Expand Up @@ -67,7 +67,7 @@ protected function assemble(): void

if ($this->isEmpty()) {
$this->setTag('div');
$this->addHtml(new EmptyState(t('No items found.')));
$this->addHtml(new EmptyStateBar(t('No items found.')));
}
}
}
4 changes: 2 additions & 2 deletions src/Common/BaseItemTable.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use ipl\Html\BaseHtmlElement;
use ipl\Orm\ResultSet;
use ipl\Stdlib\BaseFilter;
use ipl\Web\Widget\EmptyState;
use ipl\Web\Widget\EmptyStateBar;

/**
* Base class for item tables
Expand Down Expand Up @@ -82,7 +82,7 @@ protected function assemble(): void

if ($this->isEmpty()) {
$this->setTag('div');
$this->addHtml(new EmptyState(t('No items found.')));
$this->addHtml(new EmptyStateBar(t('No items found.')));
}
}
}
4 changes: 2 additions & 2 deletions src/Common/BaseOrderedItemList.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace ipl\Web\Common;

use ipl\Web\Widget\EmptyState;
use ipl\Web\Widget\EmptyStateBar;

/**
* @method BaseOrderedListItem getItemClass()
Expand All @@ -25,7 +25,7 @@ protected function assemble(): void

if ($this->isEmpty()) {
$this->setTag('div');
$this->addHtml(new EmptyState(t('No items found.')));
$this->addHtml(new EmptyStateBar(t('No items found.')));
}
}
}
30 changes: 30 additions & 0 deletions src/Widget/EmptyStateBar.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

namespace ipl\Web\Widget;

use ipl\Html\BaseHtmlElement;

class EmptyStateBar extends BaseHtmlElement
{
/** @var mixed Content */
protected $content;

protected $tag = 'div';

protected $defaultAttributes = ['class' => ['empty-state', 'empty-state-bar']];

/**
* Create an empty list
*
* @param mixed $content
*/
public function __construct($content)
{
$this->content = $content;
}

protected function assemble(): void
{
$this->add($this->content);
}
}