One solution to make the code more DRY is to extract the common styles outside of the media queries and use variables to store the values that change between the media queries. Here's an example:
$label-font-size: 16px;
$p-font-size: 15px;
$span-font-size: 16px;
.ui-field {
display: flex;
flex-direction: column;
width: 100%;
& label {
color: c.$lead;
@include s.font($label-font-size, 600);
}
& p {
color: c.$red;
@include s.font($p-font-size);
}
& select {
appearance: auto;
}
& span {
color: c.$dark-gray;
@include s.font($span-font-size);
text-align: end;
}
@include m.desktop-down {
& label {
@include s.font(14, 600);
}
& p {
@include s.font(14, 600);
}
& span {
@include s.font(14);
}
}
}
In this example, we define variables for the font sizes that change between the media queries. Then, we extract the common styles outside of the media queries and use the variables to set the font sizes. Finally, we apply the media queries to the entire block of styles, instead of repeating them for each child element.
This approach makes the code more DRY and easier to maintain, as we only need to change the values of the variables to update the styles for all the media queries.