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

Status icon updates #11911

Merged
merged 6 commits into from
Sep 13, 2022
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
2 changes: 1 addition & 1 deletion CHANGELOG-WIP.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
- Added `Craft.BaseElementIndex::getSourceLevel()`.

### Changed
- Improved the control panel accessibility. ([#10546](https://github.com/craftcms/cms/pull/10546), [#11534](https://github.com/craftcms/cms/pull/11534), [#11565](https://github.com/craftcms/cms/pull/11565), [#11578](https://github.com/craftcms/cms/pull/11578), [#11589](https://github.com/craftcms/cms/pull/11589), [#11604](https://github.com/craftcms/cms/pull/11604), [#11610](https://github.com/craftcms/cms/pull/11610), [#11611](https://github.com/craftcms/cms/pull/11611), [#11613](https://github.com/craftcms/cms/pull/11613), [#11636](https://github.com/craftcms/cms/pull/11636), [#11662](https://github.com/craftcms/cms/pull/11662)[#11703](https://github.com/craftcms/cms/pull/11703), [#11727](https://github.com/craftcms/cms/pull/11727), [#11763](https://github.com/craftcms/cms/pull/11763), [#11768](https://github.com/craftcms/cms/pull/11768), [#11775](https://github.com/craftcms/cms/pull/11775), [#11844](https://github.com/craftcms/cms/pull/11844), [#11905](https://github.com/craftcms/cms/pull/11905), [#11906](https://github.com/craftcms/cms/pull/11906))
- Improved the control panel accessibility. ([#10546](https://github.com/craftcms/cms/pull/10546), [#11534](https://github.com/craftcms/cms/pull/11534), [#11565](https://github.com/craftcms/cms/pull/11565), [#11578](https://github.com/craftcms/cms/pull/11578), [#11589](https://github.com/craftcms/cms/pull/11589), [#11604](https://github.com/craftcms/cms/pull/11604), [#11610](https://github.com/craftcms/cms/pull/11610), [#11611](https://github.com/craftcms/cms/pull/11611), [#11613](https://github.com/craftcms/cms/pull/11613), [#11636](https://github.com/craftcms/cms/pull/11636), [#11662](https://github.com/craftcms/cms/pull/11662)[#11703](https://github.com/craftcms/cms/pull/11703), [#11727](https://github.com/craftcms/cms/pull/11727), [#11763](https://github.com/craftcms/cms/pull/11763), [#11768](https://github.com/craftcms/cms/pull/11768), [#11775](https://github.com/craftcms/cms/pull/11775), [#11844](https://github.com/craftcms/cms/pull/11844), [#11905](https://github.com/craftcms/cms/pull/11905), [#11906](https://github.com/craftcms/cms/pull/11906), [#11911](https://github.com/craftcms/cms/pull/11911))
- Element indexes now respect field layouts’ user conditions when determining which custom field columns to show. ([#11913](https://github.com/craftcms/cms/pull/11913))
- Element index footers now stick to the bottom of the window, and element action triggers are now inserted into the footer rather than replacing the contents of the page’s toolbar. ([#11844](https://github.com/craftcms/cms/pull/11844))
- Notifications are now shown after executing folder actions on the Assets index page. ([#11906/](https://github.com/craftcms/cms/pull/11906))
Expand Down
16 changes: 13 additions & 3 deletions src/fields/Lightswitch.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use craft\helpers\Cp;
use craft\helpers\Db;
use craft\helpers\ElementHelper;
use craft\helpers\Html;
use GraphQL\Type\Definition\Type;
use yii\db\Schema;

Expand Down Expand Up @@ -142,11 +143,20 @@ protected function inputHtml(mixed $value, ?ElementInterface $element = null): s
*/
public function getTableAttributeHtml(mixed $value, ElementInterface $element): string
{
if ($value) {
return '<div class="status enabled" title="' . Craft::t('app', 'Enabled') . '"></div>';
if (!$value) {
return '';
}

return '<div class="status" title="' . Craft::t('app', 'Not enabled') . '"></div>';
$label = Craft::t('app', 'Enabled');

return Html::tag('div', '', [
'class' => 'checkbox-icon',
'role' => 'img',
'title' => $label,
'aria' => [
'label' => $label,
],
]);
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/templates/_elements/toolbar.twig
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@
{% if showStatusMenu or context == 'index' %}
<div>
<label id="{{ idPrefix }}status-label" class="visually-hidden">{{ "Status"|t('app') }}</label>
<button id="{{ idPrefix }}status-button" aria-labelledby="{{ idPrefix }}status-label" type="button" class="btn menubtn statusmenubtn"><span class="status"></span>{{ "All"|t('app') }}</button>
<button id="{{ idPrefix }}status-button" aria-labelledby="{{ idPrefix }}status-label" type="button" class="btn menubtn statusmenubtn"><span class="status all"></span>{{ "All"|t('app') }}</button>
<div class="menu">
<ul class="padded">
<li><a data-status="" class="sel"><span class="status"></span>{{ "All"|t('app') }}</a></li>
<li><a data-status="" class="sel"><span class="status all"></span>{{ "All"|t('app') }}</a></li>
{% if showStatusMenu %}
{% for status, info in elementInstance.statuses() %}
{% set label = info.label ?? info %}
Expand Down
2 changes: 1 addition & 1 deletion src/web/assets/cp/dist/css/cp.css

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/web/assets/cp/dist/css/cp.css.map

Large diffs are not rendered by default.

27 changes: 24 additions & 3 deletions src/web/assets/cp/src/css/_main.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3250,14 +3250,21 @@ ul.tree,
/* status icons */
.status {
display: inline-block;
position: relative;
@include margin-right(10px);
width: 10px;
height: 10px;
border: 1px solid transparent;
border-radius: 100%;
box-sizing: border-box;
background-clip: border-box;

body.use-shapes & {
&.all {
rotate: 45deg;
background-image: linear-gradient(30deg, #184cef, #e5422b);
}

&.pending {
background-color: transparent;
border-style: solid;
Expand All @@ -3266,15 +3273,17 @@ ul.tree,
border-radius: 1px;
}

&.all,
&.off,
&.suspended,
&.expired {
border-radius: 1px;
border-radius: 2px;
transform: scale(90%);
}
}
}

.status:not(.on):not(.live):not(.active):not(.enabled):not(.pending):not(.off):not(.suspended):not(.expired):not(.yellow):not(.orange):not(.red):not(.pink):not(.purple):not(.blue):not(.green):not(.turquoise):not(.light):not(.grey):not(.black) {
.status:not(.on):not(.live):not(.active):not(.enabled):not(.all):not(.pending):not(.off):not(.suspended):not(.expired):not(.yellow):not(.orange):not(.red):not(.pink):not(.purple):not(.blue):not(.green):not(.turquoise):not(.light):not(.grey):not(.black) {
border-color: var(--ui-control-color);
}

Expand All @@ -3286,6 +3295,11 @@ ul.tree,
background-color: var(--enabled-color);
}

.status.all {
background-image: linear-gradient(60deg, #184cef, #e5422b);
background-origin: border-box;
}

.orange,
.status.pending {
background-color: var(--pending-color);
Expand Down Expand Up @@ -4545,7 +4559,6 @@ ul.tree,
border-radius: 8px;
border: 2px solid transparent;
background-color: transparentize($black, 0.5);
background-clip: content-box;
}

::-webkit-scrollbar-track {
Expand Down Expand Up @@ -5633,6 +5646,14 @@ body.reduce-focus-visibility {
}
}

.checkbox-icon:before {
@include icon;
line-height: var(--checkbox-size);
color: var(--enabled-color);
content: 'check';
font-size: 15px;
}

.monaco-mouse-cursor-text {
&:focus,
&.focus-visible {
Expand Down