2
0

_preview-panel.scss 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. .w-preview {
  2. --w-preview-background-color: var(--w-color-white);
  3. --preview-width-ratio: min(
  4. 1,
  5. var(--preview-panel-width, 450) / var(--preview-device-width, 375)
  6. );
  7. --preview-iframe-width: calc(1px * var(--preview-device-width, 375));
  8. height: 100%;
  9. display: flex;
  10. flex-direction: column;
  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. padding-inline: 1rem;
  55. @include more-contrast() {
  56. border-color: theme('colors.border-furniture-more-contrast');
  57. }
  58. }
  59. &__size-button {
  60. @apply w-text-text-meta w-transition hover:w-transform hover:w-scale-110 hover:w-text-text-label focus:w-text-text-label;
  61. width: 2rem;
  62. height: 2rem;
  63. background: transparent;
  64. padding: 0;
  65. border-radius: 5px;
  66. display: grid;
  67. place-items: center;
  68. cursor: pointer;
  69. &--selected,
  70. &--selected:hover {
  71. @apply w-bg-surface-menus w-text-text-button w-transform-none w-border w-border-transparent;
  72. }
  73. &:focus-within:has(:focus-visible) {
  74. @include focus-outline;
  75. }
  76. .icon {
  77. @include svg-icon(1rem);
  78. &.icon-tablet-alt,
  79. &.icon-desktop {
  80. @include svg-icon(1.25rem);
  81. }
  82. &.icon-link-external {
  83. @include svg-icon(0.9rem);
  84. }
  85. }
  86. }
  87. &__refresh-button.button--icon {
  88. display: flex;
  89. align-items: center;
  90. justify-content: center;
  91. position: absolute;
  92. top: 1rem;
  93. width: 2rem;
  94. height: 2rem;
  95. padding: 0;
  96. inset-inline-end: 1.5rem;
  97. // Use element and class selectors to beat .button-longrunning specificity
  98. svg.icon,
  99. svg.icon-spinner {
  100. margin-inline-end: 0;
  101. width: 1rem;
  102. height: 1rem;
  103. }
  104. }
  105. &__spinner {
  106. position: absolute;
  107. top: 1.25rem;
  108. inset-inline-end: 1.5rem;
  109. }
  110. &__controls {
  111. @apply w-border-t w-border-transparent w-duration-500 w-ease-in-out;
  112. transition-property: border-color, margin-top, padding-top;
  113. margin-top: 0;
  114. padding-top: 0;
  115. // Show the border only if there's an error,
  116. // but always show it if there are multiple preview modes
  117. .w-preview--has-errors &:not(&--multiple),
  118. &--multiple {
  119. @apply w-border-border-furniture w-border-t;
  120. padding-top: 1rem;
  121. margin-top: 1rem;
  122. }
  123. }
  124. &__error-banner {
  125. @apply w-text-text-context w-duration-1000 w-ease-in-out w-translate-y-20;
  126. transition-property: max-height, transform, visibility;
  127. visibility: hidden;
  128. max-height: 0;
  129. display: flex;
  130. align-items: center;
  131. gap: 1rem;
  132. position: relative;
  133. z-index: -1;
  134. .icon {
  135. @apply w-text-warning-100;
  136. }
  137. }
  138. &--has-errors &__error-banner {
  139. @apply w-translate-y-0;
  140. visibility: visible;
  141. max-height: 6rem;
  142. }
  143. &__error-title {
  144. @apply w-label-2;
  145. color: inherit;
  146. margin-top: 0;
  147. margin-bottom: 0.25rem;
  148. }
  149. &__error-details {
  150. color: inherit;
  151. }
  152. &__modes {
  153. margin-bottom: 0;
  154. background-color: theme('colors.surface-page');
  155. .w-field__input {
  156. padding-inline-end: 0;
  157. }
  158. }
  159. &__mode-select {
  160. @apply w-outline-offset-inside;
  161. }
  162. // A hidden element that is only rendered for functionality purposes,
  163. // but is not visible to the user. Used by radio inputs for preview sizes and
  164. // the iframe while it's loading. We nest the selector rather than suffixing
  165. // the parent selector to beat the specificity of input[type="radio"] styles
  166. .w-preview__proxy {
  167. position: absolute;
  168. width: 0;
  169. height: 0;
  170. opacity: 0;
  171. // Remove mask-image from radio inputs to avoid loading the default icon,
  172. // use extra specificity to beat the default styles
  173. &:is(input[type='radio'])::before {
  174. content: none;
  175. mask-image: none;
  176. }
  177. }
  178. }