discourse/app/assets/stylesheets/common/components/d-icon-grid-picker.scss
Kris e547c6acb1
UX: various mondernized foundation style adjustments (#40808)
Various style fixes for the modernized foundation upcoming change. Also
noticed we have some unused button classes in the review queue in
general.


Before/After
<img width="700" alt="image"
src="https://github.com/user-attachments/assets/547c49ee-5d7c-42e5-be60-de06218b3329"
/>

<img width="700" alt="image"
src="https://github.com/user-attachments/assets/54f5e698-00db-4855-86e0-74053c49408a"
/>


Before/After
<img width="350" alt="image"
src="https://github.com/user-attachments/assets/24881ca3-d10b-40e4-b6a6-b55eb507642f"
/>
<img width="350" alt="image"
src="https://github.com/user-attachments/assets/320aaa5b-6493-4bc0-bd72-8c1f4391134b"
/>

Before/After:
<img width="800" alt="image"
src="https://github.com/user-attachments/assets/5b719e1e-24d5-434d-a370-de2477d13219"
/>

<img width="800" alt="image"
src="https://github.com/user-attachments/assets/de39de34-c393-4ee1-b560-70622b2dd245"
/>



Before/After:
<img width="333" alt="image"
src="https://github.com/user-attachments/assets/b87107bd-1484-4716-96f1-b8a227a5d59f"
/>

<img width="220" alt="image"
src="https://github.com/user-attachments/assets/8123f817-4b21-453b-bfb7-e934cd2d5e99"
/>
2026-06-11 17:53:39 -04:00

241 lines
5.4 KiB
SCSS
Vendored

// Custom properties for the grid layout, set on the DMenu/modal container.
// The DMenu identifier generates `.fk-d-menu.d-icon-grid-picker-content`
// which doesn't follow the BEM `__` pattern, so it stays outside the block.
.fk-d-menu.d-icon-grid-picker-content,
.fk-d-menu-modal.d-icon-grid-picker-content {
z-index: z("modal", "dialog");
--icon-grid-columns: 12;
--icon-grid-cell: 36px;
--icon-grid-gap: 2px;
--icon-grid-h-padding: 0.5rem;
}
.d-icon-grid-picker {
/* Apply icon color to the trigger icon when --icon-color is set */
.fk-d-menu__trigger > .d-icon:not(.d-icon-grid-picker__caret) {
color: var(--icon-color, currentColor);
}
.d-icon-grid-picker-trigger {
gap: var(--space-1);
}
/* Split-button layout: DMenu trigger + clear button side by side */
&.--has-clear {
display: inline-flex;
.fk-d-menu__trigger {
border-top-right-radius: 0;
border-bottom-right-radius: 0;
border-right-color: transparent;
}
.d-icon-grid-picker__clear {
border-top-left-radius: 0;
border-bottom-left-radius: 0;
border-left-color: transparent;
margin-left: 0.1em;
padding: 0.25em;
min-width: 0;
.d-icon {
font-size: var(--font-down-2);
}
}
}
&__caret {
font-size: var(--font-down-2);
}
&__content {
display: flex;
flex-direction: column;
width: calc(
var(--icon-grid-columns) * var(--icon-grid-cell) +
(var(--icon-grid-columns) - 1) * var(--icon-grid-gap) +
var(--icon-grid-h-padding) * 2 + 8px
);
max-height: 380px;
}
// Mirrors emoji-picker__filter-container
&__filter-container {
background: var(--primary-very-low);
display: flex;
height: 50px;
}
// Mirrors emoji-picker__filter
&__filter {
width: 100%;
margin: 0.5rem;
border-radius: var(--d-border-radius);
box-sizing: border-box;
input {
background-color: transparent !important;
width: 100%;
}
.d-icon {
color: var(--primary-medium);
}
&.filter-input-container {
border-color: transparent;
background: var(--secondary);
}
}
// Parent grid that both favorites and icon grid share
&__grid-wrapper {
display: grid;
grid-template-columns: repeat(
var(--icon-grid-columns),
var(--icon-grid-cell)
);
gap: var(--icon-grid-gap);
padding: var(--icon-grid-h-padding);
overflow-x: hidden;
overflow-y: auto;
max-height: 300px;
scrollbar-width: thin;
box-sizing: border-box;
}
// Favorites row inherits parent columns via subgrid
&__favorites {
display: grid;
grid-template-columns: subgrid;
grid-column: 1 / -1;
padding-bottom: 0.25rem;
}
&__selected-name {
font-size: var(--font-down-1);
white-space: nowrap;
padding-left: 0.3em;
padding-right: 0.5em;
}
// Main icon grid inherits parent columns via subgrid
&__grid {
display: grid;
grid-template-columns: subgrid;
grid-column: 1 / -1;
}
&__icon {
display: flex;
align-items: center;
justify-content: center;
width: var(--icon-grid-cell);
height: var(--icon-grid-cell);
cursor: pointer;
color: var(--icon-color, var(--primary-high));
border: none;
background: none;
padding: 0;
font: inherit;
@media (prefers-reduced-motion: no-preference) {
transition: transform 0.15s ease;
}
&:hover,
&:focus {
background: var(--primary-very-low);
border-radius: var(--d-border-radius);
@media (prefers-reduced-motion: no-preference) {
transform: scale(1.25);
}
}
&.--selected {
background: var(--tertiary-low);
color: var(--tertiary);
border-radius: var(--d-border-radius);
}
// Inner grid so the chip icon aligns with the first grid column
&.d-icon-grid-picker__selected-chip {
display: grid;
grid-template-columns: var(--icon-grid-cell) 1fr;
align-items: center;
text-align: left;
padding: 0;
// The chip spans multiple columns, so transform: scale() on the
// whole element would overlap neighbouring cells without triggering
// a grid reflow. Scale only the inner icon instead.
&:hover,
&:focus {
transform: none;
@media (prefers-reduced-motion: no-preference) {
.d-icon {
transform: scale(1.25);
}
}
}
.d-icon {
justify-self: center;
@media (prefers-reduced-motion: no-preference) {
transition: transform 0.15s ease;
}
}
}
.d-icon {
font-size: var(--font-up-2);
}
}
&__loading {
display: flex;
align-items: center;
justify-content: center;
min-height: 150px;
grid-column: 1 / -1;
}
&__empty {
padding: 1em;
text-align: center;
color: var(--primary-medium);
grid-column: 1 / -1;
}
}
// Mobile overrides
@media screen and (width <= 767px) {
.fk-d-menu-modal.d-icon-grid-picker-content {
.d-modal__body {
padding: 0;
}
.d-icon-grid-picker {
&__content {
width: 100%;
}
&__filter-container {
width: 100%;
}
&__grid-wrapper {
width: 100%;
grid-template-columns: repeat(auto-fill, var(--icon-grid-cell));
justify-content: center;
max-height: calc(
var(--composer-vh, 1dvh) * 100 - 50px - env(safe-area-inset-bottom)
);
}
}
}
}