2
0

_preview-panel.scss 4.2 KB

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