_preview-panel.scss 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179
  1. .preview-panel {
  2. height: 100%;
  3. display: flex;
  4. flex-direction: column;
  5. --preview-width-ratio: min(
  6. 1,
  7. var(--preview-panel-width, 450) / var(--preview-device-width, 375)
  8. );
  9. --preview-iframe-width: calc(1px * var(--preview-device-width, 375));
  10. &__area {
  11. height: 100%;
  12. display: flex;
  13. flex-direction: column-reverse;
  14. justify-content: space-between;
  15. // Needed for the warning message when the data is not valid.
  16. overflow: hidden;
  17. }
  18. &__wrapper {
  19. position: relative;
  20. width: calc(var(--preview-iframe-width) * var(--preview-width-ratio));
  21. height: 100%;
  22. margin-inline-start: auto;
  23. margin-inline-end: auto;
  24. }
  25. &__iframe {
  26. transform-origin: top left;
  27. width: var(--preview-iframe-width);
  28. height: calc(100% / var(--preview-width-ratio));
  29. transform: scale(var(--preview-width-ratio));
  30. display: block;
  31. [dir='rtl'] & {
  32. // Transform with the top-right physical corner as the origin since the layout is reversed.
  33. transform-origin: top right;
  34. }
  35. }
  36. &__sizes {
  37. @apply w-border-border-furniture w-border-b;
  38. display: flex;
  39. align-items: center;
  40. justify-content: center;
  41. gap: 0.75rem;
  42. padding-bottom: 1rem;
  43. margin-bottom: 1rem;
  44. }
  45. &__size-button {
  46. @apply w-text-text-meta w-transition hover:w-transform hover:w-scale-110 hover:w-text-text-label focus:w-text-text-label;
  47. width: 2rem;
  48. height: 2rem;
  49. background: transparent;
  50. padding: 0;
  51. border-radius: 5px;
  52. display: grid;
  53. place-items: center;
  54. cursor: pointer;
  55. &:focus-within {
  56. @include focus-outline;
  57. }
  58. .icon {
  59. @include svg-icon(1rem);
  60. &.icon-tablet-alt,
  61. &.icon-desktop {
  62. @include svg-icon(1.25rem);
  63. }
  64. &.icon-link-external {
  65. @include svg-icon(0.9rem);
  66. }
  67. }
  68. input[type='radio'] {
  69. position: absolute;
  70. width: 0;
  71. height: 0;
  72. opacity: 0;
  73. }
  74. }
  75. &__refresh-button.button--icon {
  76. display: flex;
  77. align-items: center;
  78. gap: 0.5rem;
  79. position: absolute;
  80. top: 1.25rem;
  81. inset-inline-end: 1.5rem;
  82. .icon {
  83. @include svg-icon(0.9rem);
  84. }
  85. }
  86. &__spinner {
  87. position: absolute;
  88. top: 1.25rem;
  89. inset-inline-end: 1.5rem;
  90. }
  91. &--mobile &__size-button--mobile,
  92. &--tablet &__size-button--tablet,
  93. &--desktop &__size-button--desktop {
  94. @apply w-bg-surface-menus w-text-text-button w-transform-none w-border w-border-transparent;
  95. }
  96. &__controls {
  97. @apply w-border-t w-border-transparent w-duration-500 w-ease-in-out;
  98. transition-property: border-color, margin-top, padding-top;
  99. margin-top: 0;
  100. padding-top: 0;
  101. // Show the border only if there's an error,
  102. // but always show it if there are multiple preview modes
  103. .preview-panel--has-errors &:not(&--multiple),
  104. &--multiple {
  105. @apply w-border-border-furniture w-border-t;
  106. padding-top: 1rem;
  107. margin-top: 1rem;
  108. }
  109. }
  110. &__error-banner {
  111. @apply w-text-text-context w-duration-1000 w-ease-in-out w-translate-y-20;
  112. transition-property: max-height, transform, visibility;
  113. visibility: hidden;
  114. max-height: 0;
  115. display: flex;
  116. align-items: center;
  117. gap: 1rem;
  118. position: relative;
  119. z-index: -1;
  120. .icon {
  121. @apply w-text-warning-100;
  122. }
  123. }
  124. &--has-errors &__error-banner {
  125. @apply w-translate-y-0;
  126. visibility: visible;
  127. max-height: 6rem;
  128. }
  129. &__error-title {
  130. @apply w-label-2;
  131. color: inherit;
  132. margin-top: 0;
  133. margin-bottom: 0.25rem;
  134. }
  135. &__error-details {
  136. color: inherit;
  137. }
  138. &__modes {
  139. display: flex;
  140. align-items: center;
  141. justify-content: center;
  142. gap: 1rem;
  143. margin-bottom: 0;
  144. background-color: theme('colors.surface-page');
  145. .w-field__label {
  146. margin-bottom: 0;
  147. }
  148. }
  149. &__mode-select {
  150. @apply w-outline-offset-inside;
  151. }
  152. }