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(NcRichText): make interactive widgets opt-in #6151

Merged
merged 3 commits into from
Oct 18, 2024
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
15 changes: 7 additions & 8 deletions src/components/NcRichText/NcReferenceList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@

<template>
<div v-if="isVisible" class="widgets--list" :class="{'icon-loading': loading }">
<div v-for="reference in displayedReferences" :key="reference?.openGraphObject?.id">
<NcReferenceWidget :reference="reference" :interactive="interactive" :interactive-opt-in="interactiveOptIn" />
</div>
<NcReferenceWidget v-for="reference in displayedReferences"
:key="reference?.openGraphObject?.id"
:reference="reference"
:interactive="interactive"
:interactive-opt-in="interactiveOptIn" />
</div>
</template>
<script>
Expand Down Expand Up @@ -146,11 +148,8 @@ export default {
}
</script>
<style lang="scss" scoped>
.widget--list {
width: var(--widget-full-width, 100%);
}

.widgets--list.icon-loading {
.widgets--list {
width: 100%;
min-height: var(--default-clickable-area);
}
</style>
14 changes: 3 additions & 11 deletions src/components/NcRichText/NcReferenceWidget.vue
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ export default {
margin-top: calc(var(--default-grid-baseline, 4px) * 3);
overflow: hidden;
border: 2px solid var(--color-border);
border-radius: var(--border-radius-large);
border-radius: var(--border-radius-container);
background-color: transparent;
display: flex;
}
Expand Down Expand Up @@ -317,17 +317,9 @@ export default {
position: relative;
.toggle-interactive--button {
position: absolute;
top: 50%;
bottom: var(--default-grid-baseline);
right: var(--default-grid-baseline);
Comment on lines +320 to +321
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO, it looks better, but it can overflow the content

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can consider:

  • make a button semi-transparent when not hovered;
  • make it icon button (and put text in title/aria-label

Don't see it moved outside of widget area

z-index: 10000;
left: 50%;
transform: translateX(-50%) translateY(-50%);
opacity: 0;
}

&:focus-within, &:hover {
.toggle-interactive--button {
opacity: 1;
}
}
}
</style>
6 changes: 6 additions & 0 deletions src/components/NcRichText/NcRichText.vue
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,10 @@ export default {
type: Boolean,
default: true,
},
referenceInteractiveOptIn: {
type: Boolean,
default: false,
},
/** Provide data upfront to avoid extra http request */
references: {
type: Object,
Expand Down Expand Up @@ -419,6 +423,7 @@ export default {
text: this.text,
referenceData: this.references,
interactive: this.referenceInteractive,
interactiveOptIn: this.referenceInteractiveOptIn,
},
}),
])
Expand Down Expand Up @@ -544,6 +549,7 @@ export default {
text: this.text,
referenceData: this.references,
interactive: this.referenceInteractive,
interactiveOptIn: this.referenceInteractiveOptIn,
},
}),
])
Expand Down
Loading