|
| 1 | +<template> |
| 2 | + <div class="ion-padding-top ion-padding-start ion-padding-end"> |
| 3 | + <div class="callout" :class="{ ['_'+type]: true }"> |
| 4 | + <ion-icon class="callout-illu" aria-hidden="true" :icon="icon" /> |
| 5 | + <div class="callout-content"> |
| 6 | + <span class="callout-content-title">{{title}}</span> |
| 7 | + <ion-text class="callout-content-description"> |
| 8 | + <slot></slot> |
| 9 | + </ion-text> |
| 10 | + </div> |
| 11 | + </div> |
| 12 | + </div> |
| 13 | +</template> |
| 14 | + |
| 15 | +<script setup lang="ts"> |
| 16 | +import {IonText} from "@ionic/vue"; |
| 17 | +import {computed, PropType, Ref} from "vue"; |
| 18 | +import {checkmarkCircle, closeCircle, informationCircle, warningSharp} from "ionicons/icons"; |
| 19 | +import {match} from "ts-pattern"; |
| 20 | +
|
| 21 | +const props = defineProps({ |
| 22 | + type: { |
| 23 | + required: true, |
| 24 | + type: String as PropType<"info"|"success"|"warning"|"error">, |
| 25 | + }, |
| 26 | + title: { |
| 27 | + required: true, |
| 28 | + type: String, |
| 29 | + }, |
| 30 | +}) |
| 31 | +
|
| 32 | +const icon = computed(() => match([props.type]) |
| 33 | + .with(["info"], () => informationCircle) |
| 34 | + .with(["warning"], () => warningSharp) |
| 35 | + .with(["error"], () => closeCircle) |
| 36 | + .with(["success"], () => checkmarkCircle) |
| 37 | + .otherwise(() => undefined) |
| 38 | +) as Ref<string|undefined>; |
| 39 | +
|
| 40 | +</script> |
| 41 | + |
| 42 | +<style lang="scss" scoped> |
| 43 | +.callout { |
| 44 | + position: relative; |
| 45 | + display: flex; |
| 46 | + flex-direction: row; |
| 47 | + column-gap: 16px; |
| 48 | + background-color: rgba(white, 0.5); |
| 49 | + border: 1px solid var(--app-beige-line); |
| 50 | + border-left-width: 4px; |
| 51 | + backdrop-filter: blur(5px); |
| 52 | + padding: 16px; |
| 53 | + border-radius: 12px; |
| 54 | + overflow: hidden; |
| 55 | +
|
| 56 | + &:before { |
| 57 | + position: absolute; |
| 58 | + width: 20%; |
| 59 | + height: 40%; |
| 60 | + left: 0; |
| 61 | + bottom: 0; |
| 62 | + transform: scale(1); |
| 63 | + opacity: 1; |
| 64 | + filter: blur(32px); |
| 65 | + z-index: 0; |
| 66 | + content: ''; |
| 67 | + } |
| 68 | +
|
| 69 | + .callout-illu { |
| 70 | + flex: 0 0 auto; |
| 71 | + font-size: 44px; |
| 72 | + } |
| 73 | +
|
| 74 | + &-content { |
| 75 | + flex: 1; |
| 76 | + display: flex; |
| 77 | + flex-direction: column; |
| 78 | + row-gap: 4px; |
| 79 | +
|
| 80 | + &-title { |
| 81 | + font-size: 16px; |
| 82 | + font-weight: 900; |
| 83 | + } |
| 84 | +
|
| 85 | + &-description { |
| 86 | + font-size: 12px; |
| 87 | + } |
| 88 | + } |
| 89 | +
|
| 90 | + /* Callout Type */ |
| 91 | + $callout-color: ( |
| 92 | + info: var(--app-voxxrin-rgb), |
| 93 | + success: var(--app-green-rgb), |
| 94 | + warning: var(--app-yellow-rgb), |
| 95 | + error: var(--app-red-rgb) |
| 96 | + ); |
| 97 | +
|
| 98 | + @each $cssClass, $callout-context in $callout-color { |
| 99 | + &._#{$cssClass} { |
| 100 | + border-left-color: rgba($callout-context, 1); |
| 101 | +
|
| 102 | + .callout-illu { color: rgba($callout-context, 1);} |
| 103 | + .callout-content-title { color: rgba($callout-context, 1);} |
| 104 | +
|
| 105 | + &:before { |
| 106 | + background: linear-gradient(331deg, rgba($callout-context, 0.6) 30%, rgba($callout-context, 0.6) 80%); |
| 107 | + } |
| 108 | + } |
| 109 | + } |
| 110 | +} |
| 111 | +</style> |
0 commit comments