Merge branch 'hangman1998-master' into 1.1.1

This commit is contained in:
Bruce Liu 2022-06-08 11:12:48 -07:00
commit 34971eac80
5 changed files with 39 additions and 4 deletions

View File

@ -23,10 +23,15 @@ const CompactCard: React.FunctionComponent<Card.Props> = props => (
text={props.item.title}
filter={props.filter}
title
dir={props.source.textDir}
/>
</span>
<span className="snippet">
<Highlights text={props.item.snippet} filter={props.filter} />
<Highlights
text={props.item.snippet}
filter={props.filter}
dir={props.source.textDir}
/>
</span>
</div>
<Time date={props.item.date} />

View File

@ -25,10 +25,19 @@ const DefaultCard: React.FunctionComponent<Card.Props> = props => (
) : null}
<CardInfo source={props.source} item={props.item} />
<h3 className="title">
<Highlights text={props.item.title} filter={props.filter} title />
<Highlights
text={props.item.title}
filter={props.filter}
title
dir={props.source.textDir}
/>
</h3>
<p className={"snippet" + (props.item.thumb ? "" : " show")}>
<Highlights text={props.item.snippet} filter={props.filter} />
<Highlights
text={props.item.snippet}
filter={props.filter}
dir={props.source.textDir}
/>
</p>
</div>
)

View File

@ -1,11 +1,13 @@
import * as React from "react"
import { validateRegex } from "../../scripts/utils"
import { FeedFilter, FilterType } from "../../scripts/models/feed"
import { SourceTextDirection } from "../../scripts/models/source"
type HighlightsProps = {
text: string
filter: FeedFilter
title?: boolean
dir: SourceTextDirection
}
const Highlights: React.FunctionComponent<HighlightsProps> = props => {
@ -57,10 +59,25 @@ const Highlights: React.FunctionComponent<HighlightsProps> = props => {
}
}
const testStyle = {
direction: "inherit",
writingMode: "inherit",
} as React.CSSProperties
if (props.dir === SourceTextDirection.RTL) {
testStyle.direction = "rtl"
} else if (props.dir === SourceTextDirection.Vertical) {
testStyle.writingMode = "vertical-rl"
}
return (
<>
{spans.map(([text, flag]) =>
flag ? <span className="h">{text}</span> : text
flag ? (
<div className="h" style={testStyle}>
{text}
</div>
) : (
<div style={testStyle}>{text}</div>
)
)}
</>
)

View File

@ -31,6 +31,7 @@ const ListCard: React.FunctionComponent<Card.Props> = props => (
text={props.item.title}
filter={props.filter}
title
dir={props.source.textDir}
/>
</h3>
{Boolean(props.viewConfigs & ViewConfigs.ShowSnippet) && (
@ -38,6 +39,7 @@ const ListCard: React.FunctionComponent<Card.Props> = props => (
<Highlights
text={props.item.snippet}
filter={props.filter}
dir={props.source.textDir}
/>
</p>
)}

View File

@ -28,12 +28,14 @@ const MagazineCard: React.FunctionComponent<Card.Props> = props => (
text={props.item.title}
filter={props.filter}
title
dir={props.source.textDir}
/>
</h3>
<p className="snippet">
<Highlights
text={props.item.snippet}
filter={props.filter}
dir={props.source.textDir}
/>
</p>
</div>