Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Wrap KvTooltip in kiva classic theme provider and use the mint … #3341

Merged
merged 2 commits into from
Oct 19, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/components/Checkout/CheckoutReceipt.vue
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@
:id="`print-card-${card.id}`"
class="loan__question-icon"
/>
<kv-tooltip :controller="`print-card-${card.id}`">
<kv-tooltip :controller="`print-card-${card.id}`" theme="mint">
You can print this card now. We'll also send it to
you in an email so you can print it later.
</kv-tooltip>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Checkout/DonateRepaymentsToggle.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
>
<span id="donate-repayments-tooltip">Donate loan repayments instead?</span>
</kv-checkbox>
<kv-tooltip controller="donate-repayments-tooltip">
<kv-tooltip controller="donate-repayments-tooltip" theme="mint">
<template #title>
Thanks for your support!
</template>
Expand Down
1 change: 1 addition & 0 deletions src/components/Checkout/OrderTotals.vue
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
<kv-tooltip
class="tooltip"
controller="promo_name"
theme="mint"
v-if="promoFundDisplayDescription"
>
{{ promoFundDisplayDescription }}
Expand Down
124 changes: 47 additions & 77 deletions src/components/Kv/KvTooltip.vue
Original file line number Diff line number Diff line change
@@ -1,93 +1,85 @@
<template>
<kv-popper
:controller="controller"
:popper-modifiers="popperModifiers"
popper-placement="top"
transition-type="kvfastfade"
class="tooltip-pane"
>
<div class="tooltip-content">
<div class="title-slot" v-if="this.$slots.title">
<slot name="title"></slot>
<kv-theme-provider :theme="themeStyle" class="kv-tailwind">
<kv-popper
:controller="controller"
:popper-modifiers="popperModifiers"
popper-placement="top"
transition-type="kvfastfade"
class="tooltip-pane tw-absolute tw-bg-primary tw-rounded tw-z-popover"
>
<div class="tw-p-2.5" style="max-width: 250px;">
<div class="tw-text-primary tw-font-medium tw-mb-1.5" v-if="this.$slots.title">
<slot name="title"></slot>
</div>
<div class="tw-text-primary">
<slot></slot>
</div>
</div>
<div class="default-slot">
<slot></slot>
</div>
</div>
<div class="tooltip-arrow" x-arrow="">
<div class="tooltip-inner-arrow"></div>
</div>
</kv-popper>
<div class="tooltip-arrow tw-absolute tw-w-0 tw-h-0 tw-border-solid" x-arrow=""></div>
</kv-popper>
</kv-theme-provider>
</template>

<script>
import KvPopper from '@/components/Kv/KvPopper';
import {
darkTheme,
mcstover marked this conversation as resolved.
Show resolved Hide resolved
mintTheme
} from '~/@kiva/kv-tokens/configs/kivaColors';
import KvThemeProvider from '~/@kiva/kv-components/vue/KvThemeProvider';

export default {
components: {
KvPopper
KvPopper,
KvThemeProvider
},
// TODO: Add prop for tooltip placement, Currently defaults to 'top' but will flip to bottom when constrained
props: {
controller: { type: String, required: true },
theme: {
type: String,
default: 'default',
validator(value) {
// The value must match one of these strings
return ['mint', 'dark'].indexOf(value) !== -1;
}
},
},
data() {
return {
darkTheme,
mintTheme,
popperModifiers: {
preventOverflow: {
padding: 10,
}
}
};
},
computed: {
themeStyle() {
const themeMapper = {
mint: mintTheme,
dark: darkTheme
};
return themeMapper[this.theme];
}
}
};
</script>

<style lang="scss" scoped>
@import 'settings';

$tooltip-border-width: 1;
$arrow-width: 14;
$arrow-width: 8;
$outer-arrow-width: rem-calc($arrow-width);
$inner-arrow-width: rem-calc($arrow-width - 2);
$inner-arrow-offset: rem-calc($arrow-width - 1);

.tooltip-pane {
position: absolute;
background: $aqua-light-green;
border-radius: rem-calc(3);
box-shadow: 0 2px 0 rgba(196, 231, 219, 0.8);
border: #{$tooltip-border-width}px solid $aqua-medium-green;
z-index: 1234;
}

.tooltip-content {
padding: 1rem;
max-width: rem-calc(250);
line-height: 1.4;
}

.tooltip-content .title-slot {
font-weight: 800;
margin-bottom: 0.75rem;
}
$border-color: var(--bg-primary);

.tooltip-arrow {
width: 0;
height: 0;
border-style: solid;
position: absolute;
margin: $outer-arrow-width;
border-color: $aqua-medium-green;
}

.tooltip-inner-arrow {
width: 0;
height: 0;
border-style: solid;
position: absolute;
margin: $outer-arrow-width;
border-color: $aqua-light-green;
border-color: rgba($border-color);
}

/* Top Tooltip Arrow appears on Bottom */
Expand All @@ -106,17 +98,6 @@ $inner-arrow-offset: rem-calc($arrow-width - 1);
margin-bottom: 0;
}

.tooltip-pane[x-placement^="top"] .tooltip-inner-arrow {
border-width: $inner-arrow-width $inner-arrow-width 0 $inner-arrow-width;
border-left-color: transparent;
border-right-color: transparent;
border-bottom-color: transparent;
bottom: calc(#{$tooltip-border-width} * 4px);
left: calc(-#{$inner-arrow-offset} * 2); /* stylelint-disable-line */
margin-top: 0;
margin-bottom: 0;
}

/* Bottom Tooltip Arrow appears on Top */
.tooltip-pane[x-placement^="bottom"] {
margin-top: $outer-arrow-width;
Expand All @@ -133,17 +114,6 @@ $inner-arrow-offset: rem-calc($arrow-width - 1);
margin-bottom: 0;
}

.tooltip-pane[x-placement^="bottom"] .tooltip-inner-arrow {
border-width: 0 $inner-arrow-width $inner-arrow-width $inner-arrow-width;
border-left-color: transparent;
border-right-color: transparent;
border-top-color: transparent;
top: calc(#{$tooltip-border-width} * 2px);
left: calc(-#{$inner-arrow-offset} * 2); /* stylelint-disable-line */
margin-top: 0;
margin-bottom: 0;
}

/* TODO: TWEAK Inner Arrow Styles for Left + Right Orientations */

/* Right Side Tooltip, Arrow appears on Left */
Expand Down