Skip to content

Commit f828b11

Browse files
jaygeorgejasonvargajackmcdade
authored
[6.x] Max width control for the CP (Expand/Constrain Layout) (#13647)
* Draft an alert component * Fix icons * Alert - improve markup * Alert - tweak alignment * Alert - message styling * Alert - Style code snippets * Alert / Style code snippets - remove unnecessary borders * Alert / Style code snippets - fix dark mode legibility * Alert / Style code snippets - improve * Dashboard demo * Move the demo to the playground * Improve realism of demo messages * Add alert component to the test's expected exports list * Add Alert to the package export file * Alert - make code size smaller * Alert - add storybook component * Add some rich content examples * Fix icon * Add docs * Add instruction * Simplify the Alert component to use Vue's slot fallback syntax * Alerts should work with the Heading and Description components * Add some demos * Tweak variations * Finish documenting using Alerts with Heading/Description components * heading prop and use heading/description components * Fix color inconsistencies * Fix color inconsistencies * Fix dark icon colors * Dark mode fix * Fix inconsistency * Try a new max-width * Replace all max-width-5xl with new max-width-page * Max width toggle prototype * Make the icons match more * Hide the toggle width button for smaller screens; it's just noise and doesn't do anything meaningful at that width * Add a tooltip instead of a title * Change phrasing * Improve phrasing * Improve phrasing * Fix /cp/collections not responding to the layout toggle control * Make the layout-width button pulse when it appears * Reduce max-width-page slightly * Use a different approach - wip * Revert "Use a different approach - wip" This reverts commit 8e3f94d. * Get this bad boy working * Add max-w-5xl (maybe?) around lots of things * Switch to a data-attribute to better separate tailwind classes with custom objects we're using * Try a max width of 6xl for narrower pages * Tidy - Add a few comments * irrelevant * Tweak layout expand icon animation slightly * Tweak layout expand icon animation slightly * Dynamic max width… Only switch to max-w-6xl on larger screens. On smaller screens max-w-6xl feels too wide, but on larger screens max-w-5xl feels to narrow --------- Co-authored-by: Jason Varga <jason@pixelfear.com> Co-authored-by: Jack McDade <jack@jackmcdade.com>
1 parent ae3f7d0 commit f828b11

49 files changed

Lines changed: 356 additions & 263 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

resources/css/components/fieldtypes/bard.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@
262262
@apply fixed inset-0 min-h-screen overflow-scroll border-none rounded-none bg-gray-100 pt-14 dark:bg-gray-850;
263263

264264
& > .bard-editor {
265-
@apply relative mx-auto my-6 max-w-5xl rounded-lg bg-white px-8 shadow-ui-md dark:bg-gray-925 dark:shadow-lg;
265+
@apply relative mx-auto my-6 max-w-page rounded-lg bg-white px-8 shadow-ui-md dark:bg-gray-925 dark:shadow-lg;
266266
}
267267
.bard-content {
268268
@apply dark:bg-gray-925;

resources/css/components/fieldtypes/markdown.css

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@
110110
}
111111

112112
.editor {
113-
@apply relative mx-auto my-6 max-w-5xl rounded-lg bg-white dark:bg-gray-900! px-2 shadow-ui-md md:px-8 md:pt-8;
113+
@apply relative mx-auto my-6 max-w-page rounded-lg bg-white dark:bg-gray-900! px-2 shadow-ui-md md:px-8 md:pt-8;
114114

115115
.CodeMirror-scroll {
116116
@apply m-0;
@@ -126,6 +126,6 @@
126126
}
127127

128128
.markdown-preview {
129-
@apply relative mx-auto max-w-5xl bg-transparent p-8 text-lg;
129+
@apply relative mx-auto max-w-page bg-transparent p-8 text-lg;
130130
}
131131
}

resources/css/core/utilities.css

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,3 +379,19 @@
379379
@utility shape-squircle {
380380
corner-shape: squircle;
381381
}
382+
383+
/* UTILITIES / ANIMATIONS
384+
=================================================== */
385+
@keyframes pulse-on-appearance {
386+
50% {
387+
opacity: 0.85;
388+
transform: scale(1.1);
389+
}
390+
100% {
391+
transform: scale(1);
392+
}
393+
}
394+
395+
@utility animate-pulse-on-appearance {
396+
animation: pulse-on-appearance 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
397+
}

resources/css/ui.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,9 @@
156156
}
157157

158158
@theme {
159+
/* This is the outer width of the page content area. */
160+
--max-width-page: 85rem;
161+
159162
--text-4xs: 0.4rem;
160163
--text-3xs: 0.5rem;
161164
--text-2xs: 0.7rem;
@@ -166,6 +169,8 @@
166169
--breakpoint-xs: 30rem;
167170
--breakpoint-2xs: 20rem;
168171
--breakpoint-3xs: 15rem;
172+
/* 1920px */
173+
--breakpoint-3xl: 120rem;
169174

170175
--shadow-ui-xs: 0px 1px 3px -1px rgba(0,0,0,0.10);
171176
--shadow-ui-sm: 0px 2px 3px -2px rgba(0,0,0,0.15);

resources/js/components/fieldtypes/replicator/SetPicker.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
:title="__('Add Set')"
1212
v-model:open="isOpen"
1313
v-else-if="shouldUseModal"
14-
class="xl:max-w-3xl 2xl:max-w-5xl"
14+
class="xl:max-w-3xl 2xl:max-w-page"
1515
>
1616
<template #trigger>
1717
<slot name="trigger" />

resources/js/components/global-header/Header.vue

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
11
<script setup>
2+
import { inject } from 'vue';
3+
import { Icon } from '@ui';
24
import Logo from './Logo.vue';
35
import Breadcrumbs from './Breadcrumbs.vue';
46
import SiteSelector from './SiteSelector.vue';
57
import Search from './Search.vue';
68
import ViewSiteButton from './ViewSiteButton.vue';
79
import UserDropdown from './UserDropdown.vue';
10+
11+
const layout = inject('layout', {});
12+
const isMaxWidthEnabled = layout.isMaxWidthEnabled;
13+
const toggleMaxWidth = layout.toggleMaxWidth;
814
</script>
915

1016
<template>
@@ -27,6 +33,14 @@ import UserDropdown from './UserDropdown.vue';
2733
<div class="flex items-center">
2834
<Search />
2935
</div>
36+
<button
37+
@click="toggleMaxWidth"
38+
:aria-label="isMaxWidthEnabled ? __('Expand Layout') : __('Constrain Layout')"
39+
v-tooltip="isMaxWidthEnabled ? __('Expand Layout') : __('Constrain Layout')"
40+
class="hidden [@media(min-width:1800px)]:inline-flex items-center justify-center whitespace-nowrap shrink-0 font-medium antialiased cursor-pointer no-underline disabled:text-white/60 dark:disabled:text-white/50 disabled:cursor-not-allowed [&_svg]:shrink-0 [&_svg]:text-gray-925 [&_svg]:opacity-60 dark:[&_svg]:text-white bg-transparent hover:bg-gray-400/10 text-gray-900 dark:text-gray-300 dark:hover:bg-white/15 dark:hover:text-gray-200 h-8 text-[0.8125rem] leading-tight rounded-lg px-0 gap-0 w-8 [&_svg]:size-4 -me-2 [&_svg]:text-white/85! will-change-transform"
41+
>
42+
<Icon :name="isMaxWidthEnabled ? 'zoom-fit-screen' : 'fit-screen'" class="animate-pulse-on-appearance" />
43+
</button>
3044
<ViewSiteButton />
3145
<UserDropdown />
3246
</div>

resources/js/components/roles/PublishForm.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<div class="max-w-5xl mx-auto">
2+
<div class="max-w-page mx-auto">
33
<Header :title="__(initialTitle) || __('Create Role')" icon="permissions">
44
<CommandPaletteItem
55
:category="$commandPalette.category.Actions"

resources/js/components/updater/Updater.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<div class="max-w-5xl mx-auto">
2+
<div class="max-w-page mx-auto">
33
<ui-header :title="__('Updates')" icon="updates">
44
<template v-if="!gettingChangelog" #actions>
55
<ui-badge :prepend="__('Statamic Version')" :text="currentVersion" color="green" size="lg" />

resources/js/components/user-groups/PublishForm.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ function save() {
3939
</script>
4040

4141
<template>
42-
<div class="max-w-5xl mx-auto">
42+
<div class="max-w-page mx-auto">
4343
<Header :title="__(title)" icon="groups">
4444
<Dropdown v-if="canEditBlueprint" class="me-2">
4545
<template #trigger>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { ref, watch } from 'vue';
2+
3+
const STORAGE_KEY = 'statamic.max-width-enabled';
4+
const isMaxWidthEnabled = ref(
5+
localStorage.getItem(STORAGE_KEY) !== 'false' // Default to true
6+
);
7+
8+
// Sync with localStorage
9+
watch(isMaxWidthEnabled, (value) => {
10+
localStorage.setItem(STORAGE_KEY, value.toString());
11+
});
12+
13+
export default function useMaxWidthToggle() {
14+
const toggle = () => {
15+
isMaxWidthEnabled.value = !isMaxWidthEnabled.value;
16+
};
17+
18+
return {
19+
isMaxWidthEnabled,
20+
toggle,
21+
};
22+
}

0 commit comments

Comments
 (0)