Skip to content

Commit bd65830

Browse files
fix: arrow and hover fixes for EsNavCtaCard (#1766)
1 parent 76e1904 commit bd65830

4 files changed

Lines changed: 49 additions & 23 deletions

File tree

es-ds-components/app/components/es-nav-cta-card.vue

Lines changed: 33 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,17 @@ interface Props {
55
subtitle?: string;
66
target?: string;
77
}
8-
withDefaults(defineProps<Props>(), {
8+
const props = withDefaults(defineProps<Props>(), {
99
subtitle: '',
1010
target: '_self',
1111
});
12+
13+
const headingPartOne = computed(() => {
14+
const arr = props.heading.split(' ');
15+
arr.pop();
16+
return arr.join(' ');
17+
});
18+
const headingPartTwo = computed(() => props.heading.split(' ').pop());
1219
</script>
1320

1421
<template>
@@ -28,11 +35,14 @@ withDefaults(defineProps<Props>(), {
2835
</div>
2936
</div>
3037
<div>
31-
<p class="align-items-center d-flex font-weight-bold mb-0 text-blue-600">
32-
{{ heading }}
33-
<icon-arrow-right
34-
aria-hidden="true"
35-
class="es-nav-cta-card-arrow flex-shrink-0 ml-25" />
38+
<p class="font-weight-bold mb-0 text-blue-600">
39+
{{ headingPartOne }}
40+
<span class="text-nowrap">
41+
{{ headingPartTwo }}
42+
<icon-arrow-right
43+
aria-hidden="true"
44+
class="es-nav-cta-card-arrow flex-shrink-0 position-relative" />
45+
</span>
3646
</p>
3747
<p
3848
v-if="subtitle"
@@ -50,6 +60,12 @@ withDefaults(defineProps<Props>(), {
5060
.es-nav-cta-card {
5161
border-width: 1px;
5262
63+
/* override EsCard active state */
64+
&:active {
65+
border-color: variables.$blue-600;
66+
box-shadow: 0 0 0 1px variables.$blue-600;
67+
}
68+
5369
/* only apply a hover state if the device supports mouse hover */
5470
@media (hover) {
5571
&:hover {
@@ -63,12 +79,22 @@ withDefaults(defineProps<Props>(), {
6379
}
6480
}
6581
82+
/* move the arrow slightly to the right on hover */
6683
.es-nav-cta-card-arrow {
67-
margin-left: 0.75rem !important;
84+
transform: translateX(0.25rem);
6885
}
6986
}
7087
}
7188
89+
&-arrow {
90+
/* vertically center the icon relative to the text */
91+
top: -2px;
92+
93+
@media not (prefers-reduced-motion) {
94+
transition: variables.$transition-base;
95+
}
96+
}
97+
7298
&-icon {
7399
/* you cannot animate radial gradient backgrounds, so apply it to a pseudo element and fade it in on hover */
74100
&::after {
@@ -103,11 +129,5 @@ withDefaults(defineProps<Props>(), {
103129
transition: variables.$transition-base;
104130
}
105131
}
106-
107-
&-arrow {
108-
@media not (prefers-reduced-motion) {
109-
transition: variables.$transition-base;
110-
}
111-
}
112132
}
113133
</style>

es-ds-docs/app/pages/organisms/nav-cta-card.vue

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -70,22 +70,22 @@ onMounted(async () => {
7070
xxl="5">
7171
<es-nav-cta-card
7272
class="mb-100"
73-
heading="Get an instant quote"
73+
heading="Plan energy recommendations"
7474
href="https://www.energysage.com"
75-
subtitle="Free, personalized solar quotes that’ll save you thousands"
75+
subtitle="See energy recommendations for your home with just an address"
7676
target="_blank">
7777
<template #icon>
78-
<icon-solar aria-hidden="true" />
78+
<icon-house-line aria-hidden="true" />
7979
</template>
8080
</es-nav-cta-card>
8181

8282
<es-nav-cta-card
83-
heading="Plan energy recommendations"
83+
heading="Get solar quotes from trusted installers"
8484
href="https://www.energysage.com"
85-
subtitle="See energy recommendations for your home with just an address"
85+
subtitle="Free, personalized solar quotes that’ll save you thousands"
8686
target="_blank">
8787
<template #icon>
88-
<icon-house-line aria-hidden="true" />
88+
<icon-solar aria-hidden="true" />
8989
</template>
9090
</es-nav-cta-card>
9191
</es-col>

es-ds-styles/scss/_card.scss

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -294,9 +294,12 @@
294294
transition: color .2s ease-in-out, border-color .2s ease-in-out, box-shadow .2s ease-in-out, transform .2s ease-in-out;
295295
}
296296

297-
&:hover {
298-
border-color: variables.$card-interactive-hover-border-color;
299-
text-decoration: none;
297+
/* only apply a hover state if the device supports mouse hover */
298+
@media (hover) {
299+
&:hover {
300+
border-color: variables.$card-interactive-hover-border-color;
301+
text-decoration: none;
302+
}
300303
}
301304

302305
&:focus-visible {

es-ds-styles/scss/mixins/_hover.scss

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,10 @@
1010
// Issue: https://github.com/twbs/bootstrap/issues/25195
1111

1212
@mixin hover() {
13-
&:hover { @content; }
13+
/* only apply a hover state if the device supports mouse hover */
14+
@media (hover) {
15+
&:hover { @content; }
16+
}
1417
}
1518

1619
@mixin hover-focus() {

0 commit comments

Comments
 (0)