Skip to content

Commit

Permalink
Added slots to EmbeddableFooter
Browse files Browse the repository at this point in the history
  • Loading branch information
pirhoo committed Apr 24, 2020
1 parent 59e3d15 commit c440d3e
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 5 deletions.
43 changes: 43 additions & 0 deletions docs/pages/components/embeddable-footer/doc.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,47 @@
</div>
:::

Main slot is displayed as "lead" text:

::: sample-card
<div class="p-4">
<embeddable-footer class="position-relative card">
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
</embeddable-footer>
</div>
:::

This can be used for more complex structures:

::: sample-card
<div class="p-4">
<embeddable-footer class="position-relative card">
<div class="d-flex align-items-center">
<div class="flew-grow-1 mr-2">
This is an helpful text.
</div>
<b-button variant="info" pill size="sm" class="ml-auto mr-2">
Help
</b-button>
</div>
</embeddable-footer>
</div>
:::

Finally, you can overide the "sharing-button" slot to use your own:

::: sample-card
<div class="p-4">
<embeddable-footer class="position-relative card" :sharing-options-values="{ url: 'https://www.reddit.com/submit?url=https%3A%2F%2Ficij.org' }">
<template #sharing-button="{ sharingOptionsValues }">
<b-button variant="primary" pill size="sm" class="ml-auto mr-2" :href="sharingOptionsValues.url" target="_blank">
Share on Reddit
</b-button>
</template>
</embeddable-footer>
</div>
:::



::: api-table components/EmbeddableFooter.vue :::
18 changes: 13 additions & 5 deletions lib/components/EmbeddableFooter.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,19 @@
<brand :size="40" no-border class="mr-2" color="white" />
{{ title }}
</a>
<div class="embeddable-footer__lead small text-truncate" v-html="lead"></div>
<button class="btn btn-link text-white btn-sm py-0 embeddable-footer__share-btn" @click="showShareOptions = !showShareOptions" :class="{ active: showShareOptions }">
<fa icon="share-alt" />
<span class="sr-only">{{ $t('embeddable-footer.share') }}</span>
</button>
<div class="embeddable-footer__lead small text-truncate">
<!-- @slot Main slot to redefine lead text display -->
<slot v-bind:lead="lead">
<span v-html="lead"></span>
</slot>
</div>
<!-- @slot Overide the sharing button -->
<slot name="sharing-button" v-bind="{ sharingOptionsValues }">
<button class="btn btn-link text-white btn-sm py-0 embeddable-footer__share-btn" @click="showShareOptions = !showShareOptions" :class="{ active: showShareOptions }">
<fa icon="share-alt" />
<span class="sr-only">{{ $t('embeddable-footer.share') }}</span>
</button>
</slot>
<sharing-options :values="sharingOptionsValues" v-if="showShareOptions" direction="column-reverse" :iframe-min-height="iframeMinHeight" :iframe-min-width="iframeMinWidth"></sharing-options>
</div>
</template>
Expand Down

0 comments on commit c440d3e

Please sign in to comment.