_chooser.scss 2.0 KB

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