BringingAnyone.vue
1 month ago
DescriptionItem.vue
1 month ago
EmptyState.vue
1 month ago
EventCard.vue
1 month ago
EventEmployee.vue
1 month ago
EventTicket.vue
1 month ago
GalleryCarousel.vue
1 month ago
DescriptionItem.vue
155 lines
| 1 | <template> |
| 2 | <div |
| 3 | v-if="useDescriptionVisibility(props.description)" |
| 4 | class="am-eli__description" |
| 5 | :aria-labelledby="props.title ? titleId : undefined" |
| 6 | > |
| 7 | <p v-if="props.title" :id="titleId" class="am-eli__description-title"> |
| 8 | {{ props.title }} |
| 9 | </p> |
| 10 | <p |
| 11 | v-if="showMore && props.description.replace(/<[^>]*>?/gm, '').length > props.limit" |
| 12 | :id="descriptionId" |
| 13 | class="am-eli__description-text ql-description" |
| 14 | v-html="props.description.slice(0, props.limit) + '...'" |
| 15 | ></p> |
| 16 | <p |
| 17 | v-else |
| 18 | :id="descriptionId" |
| 19 | class="am-eli__description-text ql-description" |
| 20 | v-html="props.description" |
| 21 | ></p> |
| 22 | <button |
| 23 | v-if="props.description.replace(/<[^>]*>?/gm, '').length > props.limit" |
| 24 | type="button" |
| 25 | class="am-eli__description-btn" |
| 26 | :aria-expanded="!showMore" |
| 27 | :aria-controls="descriptionId" |
| 28 | @click="showMore = !showMore" |
| 29 | > |
| 30 | {{ showMore ? displayLabels('show_more') : displayLabels('show_less') }} |
| 31 | </button> |
| 32 | </div> |
| 33 | </template> |
| 34 | |
| 35 | <script setup> |
| 36 | // * Import from Vue |
| 37 | import { ref, inject, computed, onMounted } from 'vue' |
| 38 | |
| 39 | // * Composables |
| 40 | import { useDescriptionVisibility } from '../../../../../assets/js/common/helper' |
| 41 | |
| 42 | // * Component props |
| 43 | let props = defineProps({ |
| 44 | customizedLabels: { |
| 45 | type: Object, |
| 46 | default: () => { |
| 47 | return {} |
| 48 | }, |
| 49 | }, |
| 50 | title: { |
| 51 | type: String, |
| 52 | default: '', |
| 53 | }, |
| 54 | description: { |
| 55 | type: String, |
| 56 | default: '', |
| 57 | }, |
| 58 | limit: { |
| 59 | type: Number, |
| 60 | default: 100, |
| 61 | }, |
| 62 | initState: { |
| 63 | type: Boolean, |
| 64 | default: true, |
| 65 | }, |
| 66 | }) |
| 67 | |
| 68 | let showMore = ref(false) |
| 69 | |
| 70 | let amLabels = inject('labels') |
| 71 | |
| 72 | // * Unique IDs for ARIA linkage |
| 73 | const uid = Math.random().toString(36).slice(2, 8) |
| 74 | const titleId = computed(() => `am-eli-title-${uid}`) |
| 75 | const descriptionId = computed(() => `am-eli-desc-${uid}`) |
| 76 | |
| 77 | function displayLabels(label) { |
| 78 | return Object.keys(props.customizedLabels).length && props.customizedLabels[label] |
| 79 | ? props.customizedLabels[label] |
| 80 | : amLabels[label] |
| 81 | } |
| 82 | |
| 83 | onMounted(() => { |
| 84 | showMore.value = props.initState |
| 85 | }) |
| 86 | </script> |
| 87 | |
| 88 | <script> |
| 89 | export default { |
| 90 | name: 'TextItem', |
| 91 | } |
| 92 | </script> |
| 93 | |
| 94 | <style lang="scss"> |
| 95 | @import '../../../../../assets/scss/common/quill/_quill-mixin.scss'; |
| 96 | |
| 97 | @mixin event-description { |
| 98 | .am-eli { |
| 99 | &__description { |
| 100 | &-title { |
| 101 | font-size: 14px; |
| 102 | font-weight: 500; |
| 103 | line-height: 1.42857; |
| 104 | color: var(--am-c-eli-text-op70); |
| 105 | margin: 0 0 8px; |
| 106 | } |
| 107 | |
| 108 | &-text { |
| 109 | font-size: 15px; |
| 110 | font-weight: 400; |
| 111 | line-height: 1.6; |
| 112 | color: var(--am-c-eli-text-op80); |
| 113 | margin: 0; |
| 114 | |
| 115 | &.ql-description { |
| 116 | @include quill-styles; |
| 117 | } |
| 118 | } |
| 119 | |
| 120 | &-btn { |
| 121 | display: inline-block; |
| 122 | font-size: 15px; |
| 123 | font-weight: 400; |
| 124 | line-height: 1.6; |
| 125 | color: var(--am-c-primary); |
| 126 | cursor: pointer; |
| 127 | |
| 128 | // Reset native button styles |
| 129 | background: none; |
| 130 | border: none; |
| 131 | padding: 0; |
| 132 | font-family: inherit; |
| 133 | text-align: left; |
| 134 | |
| 135 | &:focus-visible { |
| 136 | outline: 2px solid var(--am-c-primary); |
| 137 | outline-offset: 2px; |
| 138 | border-radius: 2px; |
| 139 | } |
| 140 | } |
| 141 | } |
| 142 | } |
| 143 | } |
| 144 | |
| 145 | // Public |
| 146 | .amelia-v2-booking #amelia-container { |
| 147 | @include event-description; |
| 148 | } |
| 149 | |
| 150 | // Admin |
| 151 | #amelia-app-backend-new { |
| 152 | @include event-description; |
| 153 | } |
| 154 | </style> |
| 155 |