Skip to content
This repository was archived by the owner on Jan 13, 2025. It is now read-only.

Commit fe13dd1

Browse files
sayriscopybara-github
authored andcommitted
feat(tooltip): Define styling to set the full-screen dialog size depending on the viewport size.
In particular: * x-small screens (< 600px x 960px [vertical] OR < 720px x 400px [horizontal]) * dialog is full-screen * small screens (<720px x 1024px) * size of dialog is fluid (with a max height/width of 560px) , but has a minimum vertical margin of 80px and minimum horizontal margin of 56px. * medium screens (< 960px x 1440px) * size of dialog is fixed (560px width and height), horizontal and vertical margins are fluid * large and x-large screens (> 960px x 1440px) * size of dialog is fluid, vertical margin is fluid, but has a minimum horizontal margin of 200px Full-screen dialog is still in development and not yet suitable for use. PiperOrigin-RevId: 351692795
1 parent 772cc10 commit fe13dd1

File tree

1 file changed

+96
-0
lines changed

1 file changed

+96
-0
lines changed

packages/mdc-dialog/_mixins.scss

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,10 @@
8888
);
8989
@include theme.property(z-index, $z-index);
9090
}
91+
92+
&.mdc-dialog--fullscreen {
93+
@include _fullscreen-dialog-size($query: $query);
94+
}
9195
}
9296

9397
.mdc-dialog__scrim {
@@ -579,3 +583,95 @@
579583
}
580584
}
581585
}
586+
587+
@mixin _fullscreen-dialog-size($query: feature-targeting.all()) {
588+
$feat-structure: feature-targeting.create-target($query, structure);
589+
.mdc-dialog__surface {
590+
// Medium screens
591+
@media (max-width: 960px) and (max-height: 1440px) {
592+
@include feature-targeting.targets($feat-structure) {
593+
max-height: 560px;
594+
max-width: 560px;
595+
}
596+
}
597+
598+
// Small screens
599+
@media (max-width: 720px) and (max-height: 1023px) {
600+
@include feature-targeting.targets($feat-structure) {
601+
$max-small-height: 560px;
602+
$max-small-width: 560px;
603+
$min-horizontal-small-margin: 56px;
604+
$min-vertical-small-margin: 80px;
605+
@include _fluid-size-calc(
606+
$vertical-margin: $min-vertical-small-margin,
607+
$max-height: $max-small-height,
608+
$horizontal-margin: $min-horizontal-small-margin,
609+
$max-width: $max-small-width
610+
);
611+
}
612+
}
613+
614+
// X-Small Screens (horizontal)
615+
@media (max-width: 720px) and (max-height: 400px) {
616+
@include feature-targeting.targets($feat-structure) {
617+
max-width: 100vw;
618+
width: 100vw;
619+
max-height: 100vh;
620+
height: 100vh;
621+
}
622+
@include shape-mixins.radius(0, $query: $query);
623+
}
624+
625+
// X-Small Screens (vertical)
626+
@media (max-width: 600px) and (max-height: 960px) {
627+
@include feature-targeting.targets($feat-structure) {
628+
max-width: 100vw;
629+
width: 100vw;
630+
max-height: 100vh;
631+
height: 100vh;
632+
}
633+
@include shape-mixins.radius(0, $query: $query);
634+
}
635+
636+
// Large to X-Large screens
637+
@media (min-width: 960px) and (min-height: 1440px) {
638+
@include feature-targeting.targets($feat-structure) {
639+
$min-horizontal-margin: 200px;
640+
max-width: calc(100vw - #{$min-horizontal-margin * 2});
641+
}
642+
}
643+
}
644+
}
645+
646+
/// Defines styling to specify a fluid dialog size while maintaining a specific
647+
/// vertical and horizontal margin.
648+
/// @param {Number} $vertical-margin
649+
/// @param {Number} $max-height
650+
/// @param {Number} $horizontal-margin
651+
/// @param {Number} $max-width
652+
@mixin _fluid-size-calc(
653+
$vertical-margin,
654+
$max-height,
655+
$horizontal-margin,
656+
$max-width
657+
) {
658+
$max-width-calc-expr: calc(100vw - #{$horizontal-margin * 2});
659+
$max-width-breakpoint: $max-width + ($horizontal-margin * 2);
660+
661+
@media (max-width: $max-width-breakpoint) {
662+
max-width: $max-width-calc-expr;
663+
}
664+
@media (min-width: $max-width-breakpoint) {
665+
max-width: $max-width;
666+
}
667+
668+
$max-height-calc-expr: calc(100vh - #{$vertical-margin * 2});
669+
$max-height-breakpoint: $max-height + ($vertical-margin * 2);
670+
671+
@media (max-height: $max-height-breakpoint) {
672+
max-height: $max-height-calc-expr;
673+
}
674+
@media (min-height: $max-height-breakpoint) {
675+
max-height: $max-height;
676+
}
677+
}

0 commit comments

Comments
 (0)