-
Notifications
You must be signed in to change notification settings - Fork 81
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: added link component #266
Changes from 7 commits
a1c02c1
db4b403
e624faa
963b48e
c700657
28dacc9
1ba6a76
952dd95
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<template> | ||
<div class="CoreLink"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since you're working on links, can you please check how the Markdown links are working, if everything is alright with them? I assume that with a Text component, markdown mode, I can There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Just checked and yes - you can. You can also There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So it's basically the same, only difference is that you can select page in component and define rel and target. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for checking! Yes they're quite similar, that's what kept me from creating this component. However, now that I think more about it:
By the way there's the possibility of opening URLs from the backend via backend actions too. |
||
<a | ||
:href="fields.url.value" | ||
:target="fields.target.value" | ||
:rel="fields.rel.value" | ||
> | ||
{{ displayText }} | ||
</a> | ||
</div> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import { FieldType, Core } from "../../streamsyncTypes"; | ||
import { cssClasses, primaryTextColor } from "../../renderer/sharedStyleFields"; | ||
import injectionKeys from "../../injectionKeys"; | ||
export default { | ||
streamsync: { | ||
name: "Link", | ||
description: "A component to create a hyperlink.", | ||
category: "Content", | ||
fields: { | ||
url: { | ||
name: "URL", | ||
type: FieldType.Text, | ||
default: "https://streamsync.cloud", | ||
desc: "Specify a URL or choose a page. Keep in mind that you can only link to pages for which a key has been specified.", | ||
options: (ss: Core) => { | ||
return Object.fromEntries( | ||
ss | ||
.getComponents("root", true) | ||
.map((page) => page.content.key) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Careful with this one. Like I was saying earlier not all pages will have keys. In fact I expect most pages to not have keys. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah sorry didn't see the next line There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. thats why there is filter in the next line |
||
.filter((key) => Boolean(key)) | ||
.map((key) => [`#${key}`, `Page with key: ${key}`]), | ||
); | ||
}, | ||
}, | ||
target: { | ||
name: "Target", | ||
type: FieldType.Text, | ||
options: { | ||
_self: "Self", | ||
_blank: "Blank", | ||
_parent: "Parent", | ||
_top: "Top", | ||
}, | ||
desc: "Specifies where to open the linked document.", | ||
default: "_self", | ||
}, | ||
rel: { | ||
name: "Rel", | ||
type: FieldType.Text, | ||
desc: "Specifies the relationship between the current document and the linked document.", | ||
}, | ||
text: { | ||
name: "Text", | ||
default: "", | ||
type: FieldType.Text, | ||
desc: "The text to display in the link.", | ||
}, | ||
primaryTextColor, | ||
cssClasses, | ||
}, | ||
}, | ||
}; | ||
</script> | ||
|
||
<script setup lang="ts"> | ||
import { inject, computed } from "vue"; | ||
const fields = inject(injectionKeys.evaluatedFields); | ||
|
||
const displayText = computed(() => { | ||
return fields.text.value || fields.url.value; | ||
}); | ||
</script> | ||
|
||
<style scoped> | ||
.CoreLink a { | ||
color: var(--primaryTextColor); | ||
} | ||
</style> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @FabienArcellier check this out
@raaymax worked on a dynamic list of options. You can pass it hardcoded options (as we do now), but you can also pass it a function to generate the options.
This was one of the challenges I saw for the Reuse Component component. So with this we're halfway there. I've asked him to work on Reuse Component.
@raaymax for your reference #215
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By the way I'm talking specifically about selecting the
id
of the component that we want to reuse.