-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #266 from raaymax/link-component
feat: added link component
- Loading branch information
Showing
6 changed files
with
106 additions
and
4 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
<template> | ||
<div class="CoreLink"> | ||
<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) | ||
.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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters