docs: hide colon when a note's title has a punctuation (#12205)
This commit is contained in:
1 parent
d98b560f26
commit
6c59d3fe6f
1 file changed
+10
-1
@@ -10,6 +10,8 @@ type StringInfo = {
|
|||||||
|
|
||||||
type NoteLayoutProps = NoteProps
|
type NoteLayoutProps = NoteProps
|
||||||
|
|
||||||
|
const PUNCTIONATIONS = [".", ":", ";", ",", "!", "?"]
|
||||||
|
|
||||||
export const NoteLayout = ({
|
export const NoteLayout = ({
|
||||||
type,
|
type,
|
||||||
title,
|
title,
|
||||||
@@ -84,6 +86,12 @@ export const NoteLayout = ({
|
|||||||
}
|
}
|
||||||
}, [children, forceMultiline])
|
}, [children, forceMultiline])
|
||||||
|
|
||||||
|
const showColon = useMemo(() => {
|
||||||
|
const lastChar = title?.charAt(title.length - 1) || ""
|
||||||
|
|
||||||
|
return !PUNCTIONATIONS.includes(lastChar)
|
||||||
|
}, [title])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={clsx(
|
className={clsx(
|
||||||
@@ -107,7 +115,8 @@ export const NoteLayout = ({
|
|||||||
<div className="flex-1">
|
<div className="flex-1">
|
||||||
<div className="text-small text-medusa-fg-subtle [&_ol]:!mb-0 [&_ul]:!mb-0">
|
<div className="text-small text-medusa-fg-subtle [&_ol]:!mb-0 [&_ul]:!mb-0">
|
||||||
<span className={clsx("text-small-plus text-medusa-fg-base")}>
|
<span className={clsx("text-small-plus text-medusa-fg-base")}>
|
||||||
{title}:
|
{title}
|
||||||
|
{showColon ? ":" : ""}
|
||||||
</span>
|
</span>
|
||||||
{allStringChildren && (
|
{allStringChildren && (
|
||||||
<MarkdownContent
|
<MarkdownContent
|
||||||
|
|||||||
Reference in new issue
Block a user