_chooser.scss 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. @use 'sass:math';
  2. $preview-size: 2.625rem; // 42px
  3. .chooser {
  4. &.blank .chosen {
  5. display: none;
  6. }
  7. &:not(.blank) .unchosen {
  8. display: none;
  9. }
  10. }
  11. // Very subdued button style specifically for choosers, as there can be a lot of
  12. // chooser fields left unused on a page editing form.
  13. .button.chooser__choose-button {
  14. @include more-contrast-interactive();
  15. @apply w-label-3;
  16. display: flex;
  17. align-items: center;
  18. color: theme('colors.text-button-outline-default');
  19. border-color: transparent;
  20. padding: theme('spacing.[1.5]');
  21. .icon {
  22. @include svg-icon(theme('spacing.4'), initial);
  23. color: inherit;
  24. margin-inline-end: 5px;
  25. }
  26. &:hover,
  27. &:focus {
  28. color: theme('colors.text-link-hover');
  29. background-color: theme('colors.surface-page');
  30. }
  31. }
  32. .chosen {
  33. display: flex;
  34. gap: theme('spacing.4');
  35. align-items: center;
  36. }
  37. .chooser__preview {
  38. display: grid;
  39. align-items: center;
  40. justify-content: center;
  41. width: $preview-size;
  42. height: $preview-size;
  43. // Prevent this item from getting smaller if the title is long.
  44. flex-shrink: 0;
  45. background-color: theme('colors.border-button-small-outline-default');
  46. color: theme('colors.text-button');
  47. border-radius: theme('borderRadius.sm');
  48. @media (forced-colors: active) {
  49. border: 1px solid transparent;
  50. }
  51. }
  52. .chooser__title {
  53. @apply w-body-text-large;
  54. }
  55. .chooser__image {
  56. $max-width: 165px;
  57. $max-height: 125px;
  58. // Adjust thumbnail size based on UI density, with safe minimums and maximums.
  59. max-width: clamp(
  60. math.div($max-width, 2),
  61. calc($max-width * var(--w-density-factor)),
  62. $max-width
  63. );
  64. max-height: clamp(
  65. math.div($max-height, 2),
  66. calc($max-height * var(--w-density-factor)),
  67. $max-height
  68. );
  69. height: auto;
  70. width: auto;
  71. }
  72. // Display these as inline block so that action icons such as comments can appear as close as possible
  73. .w-field--admin_task_chooser,
  74. .w-field--admin_page_chooser,
  75. .w-field--document_chooser_widget,
  76. .w-field--admin_image_chooser,
  77. .w-field--admin_snippet_chooser {
  78. display: inline-block;
  79. }