mirror of
https://github.com/mauriceboe/TREK.git
synced 2026-11-23 05:21:15 +00:00
bf00412863
In the touch shell the back, forward, disclosure, date-range and flow arrows kept pointing right in Arabic, so Settle up showed the debt the wrong way round and Vacay's year arrows pointed inward. The shell now mirrors lucide's direction arrows in right-to-left languages; an icon that names its own treatment keeps it, and the lightbox arrows stay on their physical sides. Latin user text in Arabic rows lost its beginning when cut and moved its punctuation to the wrong end. Names, titles, addresses and file names take their direction from their own text (dir=auto) and still line up with the row; markdown paragraphs, chat messages, poll options and journal stories are isolated; signed balances, amounts, sizes, rates and leg figures read as one left-to-right run; URL fields read left to right. Name pairs joined by an arrow isolate each name and point from the first to the second. The hero progress and poll result bars fill from the start edge. Arabic and Hebrew uppercase caption labels grow a step and take the muted ink, and a todo's due date in a notification is written in the reader's language instead of as YYYY-MM-DD.
71 lines
3.1 KiB
TypeScript
71 lines
3.1 KiB
TypeScript
import ReactMarkdown from 'react-markdown'
|
|
import remarkGfm from 'remark-gfm'
|
|
import remarkBreaks from 'remark-breaks'
|
|
|
|
interface Props {
|
|
text: string
|
|
dark?: boolean
|
|
}
|
|
|
|
export default function JournalBody({ text, dark }: Props) {
|
|
return (
|
|
<div className="journal-body" style={{
|
|
fontFamily: 'inherit',
|
|
fontSize: 'inherit',
|
|
lineHeight: 1.6,
|
|
color: 'inherit',
|
|
}}>
|
|
{/* Each paragraph in its own direction (bdi): a Latin story in the Arabic UI keeps its full stop at its end. */}
|
|
<ReactMarkdown
|
|
remarkPlugins={[remarkGfm, remarkBreaks]}
|
|
components={{
|
|
h1: ({ children }) => <p style={{ margin: '0 0 6px' }}><bdi>{children}</bdi></p>,
|
|
h2: ({ children }) => <p style={{ margin: '0 0 6px' }}><bdi>{children}</bdi></p>,
|
|
h3: ({ children }) => <p style={{ margin: '0 0 6px' }}><bdi>{children}</bdi></p>,
|
|
p: ({ children }) => <p style={{ margin: '0 0 6px' }}><bdi>{children}</bdi></p>,
|
|
blockquote: ({ children }) => (
|
|
<blockquote style={{
|
|
borderInlineStart: `3px solid var(--journal-accent)`,
|
|
paddingInlineStart: 16, margin: '12px 0',
|
|
fontStyle: 'italic', color: 'var(--journal-muted)',
|
|
}}>{children}</blockquote>
|
|
),
|
|
a: ({ href, children }) => (
|
|
<a href={href} target="_blank" rel="noopener noreferrer"
|
|
style={{ color: 'var(--journal-accent)', textDecoration: 'underline', textUnderlineOffset: 2 }}>
|
|
{children}
|
|
</a>
|
|
),
|
|
ul: ({ children }) => <ul style={{ paddingInlineStart: 20, margin: '8px 0' }}>{children}</ul>,
|
|
ol: ({ children }) => <ol style={{ paddingInlineStart: 20, margin: '8px 0' }}>{children}</ol>,
|
|
li: ({ children }) => <li style={{ margin: '4px 0' }}>{children}</li>,
|
|
strong: ({ children }) => <strong style={{ fontWeight: 600 }}>{children}</strong>,
|
|
em: ({ children }) => <em>{children}</em>,
|
|
hr: () => <hr style={{ border: 'none', borderTop: '1px solid var(--journal-border)', margin: '20px 0' }} />,
|
|
// react-markdown already wraps fenced code in a <pre>, so the block
|
|
// styling belongs here — the code renderer only handles inline code.
|
|
pre: ({ children }) => (
|
|
<pre style={{
|
|
background: dark ? 'rgba(255,255,255,0.05)' : 'rgba(0,0,0,0.04)',
|
|
borderRadius: 8, padding: 14, overflowX: 'auto',
|
|
fontSize: 'calc(13px * var(--fs-scale-body, 1))', fontFamily: 'monospace', margin: '12px 0',
|
|
}}>{children}</pre>
|
|
),
|
|
code: ({ children, className }) => {
|
|
const isBlock = className?.includes('language-')
|
|
if (isBlock) return <code>{children}</code>
|
|
return (
|
|
<code style={{
|
|
background: dark ? 'rgba(255,255,255,0.08)' : 'rgba(0,0,0,0.06)',
|
|
borderRadius: 4, padding: '2px 5px', fontSize: '0.9em', fontFamily: 'monospace',
|
|
}}>{children}</code>
|
|
)
|
|
},
|
|
}}
|
|
>
|
|
{text.replace(/^(.+)\n([-=]{3,})$/gm, '$1\n\n$2')}
|
|
</ReactMarkdown>
|
|
</div>
|
|
)
|
|
}
|