Skip to content

Commit c9a79f2

Browse files
authored
fix(tray): full width at portrait orientation (#2547)
* docs(tray): docs update and fix guidelines link Fix incorrect Tray guidelines link that was 404 not found. Update descriptions in docs to clarify viewport orientation differences. * fix(tray): full width at portrait The Tray was not appearing as 100% width in portrait orientation because of a max-inline-size declaration coming from the .spectrum-Modal class used with .spectrum-Tray * fix(tray): whcm use border on correct element to show rounding Rounded corners were not showing in forced-colors mode, because the border that was appearing on the nested Dialog element, which has padding. Moves the high contrast border from that element to the root Tray element. * fix(tray): storybook heading text control and unused import The Storybook "heading" control was previously not usable, due to how the arg was being passed through to the Dialog. This text string control will now change the heading. Replaces an "unused" import for Modal whose CSS is still necessary for the Tray to render correctly. The unused import would be deleted on save/fix, resulting in the wrong styles. Replaced the template import with an import of just the CSS for Modal.
1 parent 3f14a86 commit c9a79f2

File tree

5 files changed

+27
-26
lines changed

5 files changed

+27
-26
lines changed

components/tray/index.css

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,6 @@ governing permissions and limitations under the License.
2828
--spectrum-tray-background-color: var(--spectrum-background-layer-2-color);
2929
}
3030

31-
@media (forced-colors: active) {
32-
.spectrum-Tray {
33-
--highcontrast-tray-background-color: Background;
34-
}
35-
}
36-
3731
.spectrum-Tray-wrapper {
3832
inset-inline-start: 0;
3933
/* Positioned at the bottom of the window */
@@ -45,20 +39,19 @@ governing permissions and limitations under the License.
4539
}
4640

4741
.spectrum-Tray {
48-
/* Default to full width when the viewport is in portrait orientation
49-
* (height is greater than width)
50-
*/
42+
/* Default to full width when the viewport is in portrait orientation */
5143
inline-size: 100%;
44+
--mod-modal-max-width: 100%;
45+
max-inline-size: 100%;
46+
5247
max-block-size: calc(100vh - var(--mod-tray-spacing-edge-to-tray-safe-zone, var(--spectrum-tray-spacing-edge-to-tray-safe-zone)));
5348
margin-block-start: var(--mod-tray-spacing-edge-to-tray-safe-zone, var(--spectrum-tray-spacing-edge-to-tray-safe-zone));
5449
padding-block-start: var(--mod-tray-top-to-content-area, var(--spectrum-tray-top-to-content-area));
5550
padding-block-end: var(--mod-tray-bottom-to-content-area, var(--spectrum-tray-top-to-content-area));
5651
box-sizing: border-box;
5752
overflow: auto;
5853
outline: none;
59-
60-
/* Unset spectrum-Modal border-radius */
61-
border-radius: unset;
54+
border-radius: var(--mod-tray-corner-radius-portrait, 0) var(--mod-tray-corner-radius-portrait, 0) 0 0;
6255

6356
/* Start offset by the animation distance */
6457
transform: translateY(100%);
@@ -91,14 +84,21 @@ governing permissions and limitations under the License.
9184
}
9285
}
9386

94-
/* https://developer.mozilla.org/en-US/docs/Web/CSS/@media/orientation
95-
* Limit Tray width to 375px and round corners when the viewport is in landscape orientation
96-
* (width is greater than height)
97-
*/
9887
@media screen and (orientation: landscape) {
9988
.spectrum-Tray {
10089
border-start-start-radius: var(--mod-tray-corner-radius, var(--spectrum-tray-corner-radius));
10190
border-start-end-radius: var(--mod-tray-corner-radius, var(--spectrum-tray-corner-radius));
10291
max-inline-size: var(--mod-tray-max-inline-size, var(--spectrum-tray-max-inline-size));
10392
}
10493
}
94+
95+
@media (forced-colors: active) {
96+
.spectrum-Tray {
97+
--highcontrast-tray-background-color: Canvas;
98+
99+
border: solid;
100+
& .spectrum-Dialog {
101+
border: none;
102+
}
103+
}
104+
}

components/tray/metadata/mods.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
| `--mod-tray-background-color` |
44
| `--mod-tray-bottom-to-content-area` |
55
| `--mod-tray-corner-radius` |
6+
| `--mod-tray-corner-radius-portrait` |
67
| `--mod-tray-entry-animation-delay` |
78
| `--mod-tray-entry-animation-duration` |
89
| `--mod-tray-exit-animation-delay` |

components/tray/metadata/tray.yml

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
name: Tray
22
description: |
3-
Tray Dialogs are typically used to portray information on mobile device or
4-
smaller screens.
3+
The Tray component is typically used to portray information on mobile devices or smaller screens.
4+
55
sections:
66
- name: Custom Properties API
77
description: |
88
This component can be modified via its `--mod-*` prefixed custom properties. A list of those prefixed custom properties can be found <a class="spectrum-Link" href="https://github.com/adobe/spectrum-css/tree/main/components/tray/metadata/mods.md">here</a>.
9-
SpectrumSiteSlug: https://spectrum.adobe.com/page/trays/
9+
SpectrumSiteSlug: https://spectrum.adobe.com/page/tray/
1010
examples:
1111
- id: tray
12-
name: Tray
12+
name: Standard
13+
description: The following example displays differently depending on the orientation of the viewport, using the `orientation` CSS media feature. In portrait orientation, a Tray is displayed at the bottom of the screen and takes up the full width of the view. In landscape orientation, it keeps its portrait width, is centered horizontally, and has rounded upper corners.
1314
markup: |
1415
<div class="spectrum-Tray-wrapper spectrum-CSSExample-dialog" style="background: rgba(0,0,0,0.4);">
1516
<div class="spectrum-Modal spectrum-Tray is-open">

components/tray/stories/template.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@ import { classMap } from "lit/directives/class-map.js";
33
import { ifDefined } from "lit/directives/if-defined.js";
44
import { styleMap } from "lit/directives/style-map.js";
55

6-
import { Template as Modal } from "@spectrum-css/modal/stories/template.js";
7-
6+
import "@spectrum-css/modal/index.css";
87
import "../index.css";
98

109
export const Template = ({

components/tray/stories/tray.stories.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ export default {
2929
rootClass: "spectrum-Tray",
3030
customClasses: ["spectrum-Modal"],
3131
isOpen: true,
32+
heading: "New Messages",
3233
},
3334
parameters: {
3435
actions: {
@@ -43,15 +44,16 @@ export default {
4344
};
4445

4546
export const Default = ({
47+
heading,
4648
...args
4749
}) => {
4850
return html`
4951
<div>
5052
${Template({
51-
heading: "Tray Dialog",
53+
...args,
5254
content: [
5355
() => Dialog({
54-
heading: "New Messages",
56+
heading,
5557
content: ["You have 5 new messages!"],
5658
isDismissable: false,
5759
})
@@ -62,7 +64,6 @@ export const Default = ({
6264
window.isChromatic() ?
6365
Template({
6466
...args,
65-
heading: "Tray Dialog",
6667
content: [
6768
() => Dialog({
6869
heading: "You have new messages waiting in your inbox",
@@ -79,4 +80,3 @@ export const Default = ({
7980
</div>
8081
`;
8182
};
82-
Default.args = {};

0 commit comments

Comments
 (0)