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

Update slideout to use mobile styles under 600px viewport width #11636

Merged
merged 7 commits into from
Aug 12, 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
3 changes: 2 additions & 1 deletion CHANGELOG-WIP.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@
- Added `craft\events\CreateTwigEvent`.
- Added `craft\web\Controller::getCurrentUser()`. ([#11754](https://github.com/craftcms/cms/pull/11754))
- Added `craft\web\View::EVENT_AFTER_CREATE_TWIG`. ([#11774](https://github.com/craftcms/cms/pull/11774))
- Added the `Craft.useMobileStyles()` JavaScript method. ([#11636](https://github.com/craftcms/cms/pull/11636))

### Changed
- Improved the control panel accessibility. ([#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), [#11610](https://github.com/craftcms/cms/pull/11610), [#11611](https://github.com/craftcms/cms/pull/11611), [#11613](https://github.com/craftcms/cms/pull/11613), [#11703](https://github.com/craftcms/cms/pull/11703), [#11727](https://github.com/craftcms/cms/pull/11727), [#11768](https://github.com/craftcms/cms/pull/11768))
- Improved the control panel accessibility. ([#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), [#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), [#11703](https://github.com/craftcms/cms/pull/11703), [#11727](https://github.com/craftcms/cms/pull/11727), [#11768](https://github.com/craftcms/cms/pull/11768))
- `users/session-info` responses now include a `csrfTokenName` key. ([#11706](https://github.com/craftcms/cms/pull/11706))
- `craft\helpers\Component::iconSvg()` now namespaces the SVG contents, and adds `aria-hidden="true"`. ([#11703](https://github.com/craftcms/cms/pull/11703))
- `craft\services\Search::EVENT_BEFORE_INDEX_KEYWORDS` is now cancellable by setting `$event->isValid` to `false`. ([#11705](https://github.com/craftcms/cms/discussions/11705))
Expand Down
2 changes: 1 addition & 1 deletion src/web/assets/cp/dist/cp.js

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

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.

9 changes: 5 additions & 4 deletions src/web/assets/cp/src/css/_cp.scss
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ $sidebarZIndex: 100;
$detailsWidth: 350px;
$minFullUiWidth: 1200px;
$minXlUiWidth: 1536px;
$minDesktopWidth: 600px;
$minHorizontalUiWidth: $minFullUiWidth - $sidebarWidth;

// Colors
Expand Down Expand Up @@ -1537,8 +1538,8 @@ li.breadcrumb-toggle-wrapper {
}
}

// 2 cols for 500 - 1535px
@media only screen and (min-width: 500px) and (max-width: $minXlUiWidth - 1px) {
// 2 cols for 600 - 1535px
@media only screen and (min-width: $minDesktopWidth) and (max-width: $minXlUiWidth - 1px) {
&.width-25,
&.width-50 {
width: 50%;
Expand All @@ -1552,8 +1553,8 @@ li.breadcrumb-toggle-wrapper {
& > :not(h2):not(hr):not(.line-break) {
&,
&:last-child {
// 2 cols for >= 1536px
@media only screen and (min-width: $minXlUiWidth) {
// 2 cols for >= 1200
@media only screen and (min-width: $minDesktopWidth * 2) {
&.width-25,
&.width-50 {
width: 50%;
Expand Down
4 changes: 4 additions & 0 deletions src/web/assets/cp/src/js/Craft.js
Original file line number Diff line number Diff line change
Expand Up @@ -2303,6 +2303,10 @@ $.extend(Craft, {
document.visibilityState === 'visible'
);
},

useMobileStyles: function () {
return Garnish.isMobileBrowser() || document.body.clientWidth < 600;
},
});

// -------------------------------------------
Expand Down
10 changes: 5 additions & 5 deletions src/web/assets/cp/src/js/Slideout.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
init: function (contents, settings) {
this.setSettings(settings, Craft.Slideout.defaults);

if (!Garnish.isMobileBrowser()) {
if (!Craft.useMobileStyles()) {
this.$shade = $('<div class="slideout-shade"/>').appendTo(
Garnish.$bod
);
Expand Down Expand Up @@ -42,7 +42,7 @@

Garnish.addModalAttributes(this.$outerContainer);

if (Garnish.isMobileBrowser()) {
if (Craft.useMobileStyles()) {
this.$container.addClass('so-mobile');
}

Expand All @@ -69,7 +69,7 @@

this.$outerContainer.appendTo(Garnish.$bod).removeClass('hidden');

if (Garnish.isMobileBrowser()) {
if (Craft.useMobileStyles()) {
this.$container.css('top', '100vh');
} else {
this.$container.css(Garnish.ltr ? 'left' : 'right', '100vw');
Expand Down Expand Up @@ -173,7 +173,7 @@
openPanels: [],
addPanel: function (panel) {
Craft.Slideout.openPanels.unshift(panel);
if (Garnish.isMobileBrowser()) {
if (Craft.useMobileStyles()) {
panel.$container.css('top', 0);
} else {
Craft.Slideout.updateStyles();
Expand All @@ -183,7 +183,7 @@
Craft.Slideout.openPanels = Craft.Slideout.openPanels.filter(
(m) => m !== panel
);
if (Garnish.isMobileBrowser()) {
if (Craft.useMobileStyles()) {
panel.$container.css('top', '100vh');
} else {
panel.$container.css(Garnish.ltr ? 'left' : 'right', '100vw');
Expand Down