Skip to content

Commit

Permalink
SWED-2503 switch :is for :where for specificity in cards
Browse files Browse the repository at this point in the history
  • Loading branch information
goldenraphti committed Jun 21, 2024
1 parent 2dfc165 commit 4801807
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions src/less/components/card.less
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,8 @@
padding-inline-end: var(--padding-outer);
}

&:not(.cards-wide):has(> :is(img, picture, .illustration):first-child) .h4 {
&:not(.cards-wide):has(> :where(img, picture, .illustration):first-child)
.h4 {
padding-block-start: 0;
}

Expand All @@ -69,7 +70,7 @@
padding-block-end: var(--padding-outer);
}

&.cards-wide:has(> :is(img, picture, .illustration):first-child)
&.cards-wide:has(> :where(img, picture, .illustration):first-child)
:is(.h4, .cards-icon, .cards-content, .cards-cta) {
padding-inline-start: 0;

Expand All @@ -95,15 +96,15 @@
margin-inline-end: 0.5rem;
}

&:has(> :is(img, picture, .illustration):first-child) {
&:has(> :where(img, picture, .illustration):first-child) {
grid-template-areas:
"image"
"title"
"text-content"
"cta";
grid-template-columns: 1fr;

&:is(button) :is(img, picture, .illustration) {
&:is(button) :where(img, picture, .illustration) {
max-width: 100%;
}

Expand All @@ -115,15 +116,15 @@
grid-area: image;
}

&:has(> :is(img, picture, .illustration):first-child.ratio-1-1):before {
&:has(> :where(img, picture, .illustration):first-child.ratio-1-1):before {
aspect-ratio: 1 / 1;
}

&:has(> :is(img, picture, .illustration):first-child.ratio-4-3):before {
&:has(> :where(img, picture, .illustration):first-child.ratio-4-3):before {
aspect-ratio: 4 / 3;
}

& > :is(img, picture, .illustration):first-child {
& > :where(img, picture, .illustration):first-child {
width: 100%;
aspect-ratio: 16 / 9;
grid-area: image;
Expand Down Expand Up @@ -200,15 +201,17 @@
}
}

&:not(:has(> :is(img, picture, .illustration):first-child)) {
&:not(:has(> :where(img, picture, .illustration):first-child)) {
grid-template-rows: auto auto;

& .cards-cta {
padding-block-end: 0;
}
}

&:not(:has(> :is(img, picture, .illustration):first-child)):not(:has(.h4)) {
&:not(:has(> :where(img, picture, .illustration):first-child)):not(
:has(.h4)
) {
grid-template-areas: "icon text-content cta";
grid-template-columns: auto 1fr min-content;
grid-template-rows: auto;
Expand All @@ -219,7 +222,7 @@
}
}

&:not(:has(> :is(img, picture, .illustration):first-child)):not(
&:not(:has(> :where(img, picture, .illustration):first-child)):not(
:has(.cards-content)
) {
grid-template-areas: "icon title cta";
Expand All @@ -233,7 +236,7 @@
}
}

&:not(:has(> :is(img, picture, .illustration):first-child)):not(
&:not(:has(> :where(img, picture, .illustration):first-child)):not(
:has(.cards-icon)
):not(:has(.cards-content)) {
grid-template-areas: "title cta";
Expand All @@ -246,7 +249,7 @@
}
}

&:has(> :is(img, picture, .illustration):first-child) {
&:has(> :where(img, picture, .illustration):first-child) {
grid-template-areas:
"image title"
"image text-content"
Expand Down Expand Up @@ -275,7 +278,7 @@
aspect-ratio: 1;
}

& > :is(img, picture, .illustration):first-child {
& > :where(img, picture, .illustration):first-child {
max-width: 100%;
object-fit: cover;
width: auto;
Expand Down

0 comments on commit 4801807

Please sign in to comment.