@use 'sass:map'; // Shared styling of article images shown as background @mixin image-as-background { background-color: var(--newtab-element-secondary-color); background-position: center; background-repeat: no-repeat; background-size: cover; border-radius: var(--border-radius-small); box-shadow: $shadow-image-inset; } // Note: lineHeight and fontSize should be unitless but can be derived from pixel values // Bug 1550624 to clean up / remove this mixin to avoid duplicate styles @mixin limit-visible-lines($line-count, $line-height, $font-size) { font-size: $font-size; -webkit-line-clamp: $line-count; line-height: $line-height; } @mixin dark-theme-only { [lwt-newtab-brighttext] & { @content; } } @mixin ds-border-top { @content; @include dark-theme-only { border-block-start: 1px solid $grey-60; } border-block-start: 1px solid $grey-30; } @mixin ds-border-bottom { @content; @include dark-theme-only { border-block-end: 1px solid $grey-60; } border-block-end: 1px solid $grey-30; } @mixin ds-fade-in($halo-color: $blue-50-30) { box-shadow: 0 0 0 5px $halo-color; transition: box-shadow 150ms; border-radius: var(--border-radius-small); outline: none; } // Some wallpapers are light/dark, and may not match the user set contrast, // so some text, icons, etc that are displayed over the wallpaper need a contrast fix. @mixin wallpaper-contrast-fix { .lightWallpaper & { color-scheme: light; } .darkWallpaper & { color-scheme: dark; } } // Used to visualize the different breakpoints on an applied element // See variables.scss for $debug-breakpoints @mixin debug-breakpoints { @each $name, $value in $debug-breakpoints { $color: map.get($debug-breakpoint-colors, $name); @media (min-width: $value) { outline: 1px solid #{$color}; } } } // Bug 2020945 - CSS custom properties cannot be used in container queries, so these values // are stored as SCSS variables to be interpolated into calc() expressions. $col-width-px: 75px; $col-gap-px: 0.75rem; $side-col-width-px: $col-width-px * 2; // Use this mixin instead of static media query breakpoints. It applies styles // when the content grid has room for at least $cols columns, making layouts // adapt to the available column count rather than fixed viewport widths. // Usage: @include at-content-cols(6) { grid-column: span 6; } @mixin at-content-cols($cols) { $min-width: calc(#{$cols} * #{$col-width-px} + #{$cols - 1} * #{$col-gap-px}); @container content-grid (inline-size >= #{$min-width}) { @content; } } // Like at-content-cols but applies only within an exclusive column-count range. // $min-cols: lower bound (inclusive); use 0 to match from the smallest size. // $max-cols: upper bound (exclusive). // Usage: @include at-content-cols-range(8, 12) { … } @mixin at-content-cols-range($min-cols, $max-cols) { $max-width: calc(#{$max-cols} * #{$col-width-px} + #{$max-cols - 1} * #{$col-gap-px}); @if $min-cols == 0 { @container content-grid (inline-size < #{$max-width}) { @content; } } @else { $min-width: calc(#{$min-cols} * #{$col-width-px} + #{$min-cols - 1} * #{$col-gap-px}); @container content-grid ((inline-size >= #{$min-width}) and (inline-size < #{$max-width})) { @content; } } } // Use for elements outside .content (e.g. in .sidebar-inline-start). // Queries the outer .container when it is wide enough to give the content // area room for at least $cols columns. // Usage: @include at-outer-grid-cols(6) { display: inline-block; } @mixin at-outer-grid-cols($cols) { $min-width: calc(2 * #{$side-col-width-px} + #{$cols + 1} * #{$col-gap-px} + #{$cols} * #{$col-width-px}); @container outer-grid (inline-size >= #{$min-width}) { @content; } } // Adds transparency and a hover effect to card background. @mixin newtab-card-style { background: var(--newtab-background-card); transition: opacity 0.2s ease; &:hover { background: var(--newtab-background-color-secondary); } }