-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: syntax highlight, foldable text, sanitised, markdown support
- Loading branch information
1 parent
a99b8e0
commit 8cb9ca4
Showing
5 changed files
with
123 additions
and
7 deletions.
There are no files selected for viewing
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,63 @@ | ||
<template> | ||
<span | ||
class="text-wrapper" | ||
ref="textWrapper" | ||
> | ||
<span | ||
class="text-content" | ||
:style="contentStyle" | ||
> | ||
<slot></slot> | ||
</span> | ||
<VBtn | ||
v-if="isTruncated" | ||
class="text-none" | ||
variant="text" | ||
density="compact" | ||
text="read more…" | ||
small | ||
slim | ||
@click="isTruncated = false" | ||
/> | ||
</span> | ||
</template> | ||
|
||
<script> | ||
export default { | ||
name: 'TruncatableText', | ||
props: { | ||
maxHeight: { | ||
type: Number, | ||
default: 100 // Approximately 4 lines of text with default line height | ||
} | ||
}, | ||
data() { | ||
return { | ||
isTruncated: true, | ||
originalHeight: 0 | ||
} | ||
}, | ||
computed: { | ||
contentStyle() { | ||
if (!this.isTruncated) { | ||
return {} | ||
} | ||
return { | ||
maxHeight: `${this.maxHeight}px`, | ||
overflow: 'hidden' | ||
} | ||
} | ||
} | ||
} | ||
</script> | ||
|
||
<style scoped> | ||
.text-wrapper { | ||
position: relative; | ||
} | ||
.text-content { | ||
display: inline-block; | ||
transition: max-height 1s ease-out; | ||
} | ||
</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
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