Skip to content

Commit 59cc729

Browse files
committed
fix search with rtl
1 parent d5ab8bf commit 59cc729

File tree

8 files changed

+684
-366
lines changed

8 files changed

+684
-366
lines changed

dist/styles/cards.css

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,10 @@
9191
.card span.h {
9292
background: #fce10080;
9393
}
94+
.card.rtl .snippet,
95+
.card.rtl .title {
96+
direction: rtl;
97+
}
9498

9599
.default-card {
96100
display: inline-block;

package-lock.json

Lines changed: 667 additions & 330 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
"@types/react-redux": "^7.1.9",
2828
"@yang991178/rss-parser": "^3.8.1",
2929
"electron": "^19.0.0",
30-
"electron-builder": "^22.11.3",
30+
"electron-builder": "^23.0.3",
3131
"electron-react-devtools": "^0.5.3",
3232
"electron-store": "^5.2.0",
3333
"electron-window-state": "^5.0.3",

src/components/cards/compact-card.tsx

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@ import { Card } from "./card"
33
import CardInfo from "./info"
44
import Time from "../utils/time"
55
import Highlights from "./highlights"
6+
import { SourceTextDirection } from "../../scripts/models/source"
67

78
const className = (props: Card.Props) => {
89
let cn = ["card", "compact-card"]
910
if (props.item.hidden) cn.push("hidden")
11+
if (props.source.textDir === SourceTextDirection.RTL) cn.push("rtl")
1012
return cn.join(" ")
1113
}
1214

@@ -23,15 +25,10 @@ const CompactCard: React.FunctionComponent<Card.Props> = props => (
2325
text={props.item.title}
2426
filter={props.filter}
2527
title
26-
dir={props.source.textDir}
2728
/>
2829
</span>
2930
<span className="snippet">
30-
<Highlights
31-
text={props.item.snippet}
32-
filter={props.filter}
33-
dir={props.source.textDir}
34-
/>
31+
<Highlights text={props.item.snippet} filter={props.filter} />
3532
</span>
3633
</div>
3734
<Time date={props.item.date} />

src/components/cards/default-card.tsx

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ import * as React from "react"
22
import { Card } from "./card"
33
import CardInfo from "./info"
44
import Highlights from "./highlights"
5+
import { SourceTextDirection } from "../../scripts/models/source"
56

67
const className = (props: Card.Props) => {
78
let cn = ["card", "default-card"]
89
if (props.item.snippet && props.item.thumb) cn.push("transform")
910
if (props.item.hidden) cn.push("hidden")
11+
if (props.source.textDir === SourceTextDirection.RTL) cn.push("rtl")
1012
return cn.join(" ")
1113
}
1214

@@ -25,19 +27,10 @@ const DefaultCard: React.FunctionComponent<Card.Props> = props => (
2527
) : null}
2628
<CardInfo source={props.source} item={props.item} />
2729
<h3 className="title">
28-
<Highlights
29-
text={props.item.title}
30-
filter={props.filter}
31-
title
32-
dir={props.source.textDir}
33-
/>
30+
<Highlights text={props.item.title} filter={props.filter} title />
3431
</h3>
3532
<p className={"snippet" + (props.item.thumb ? "" : " show")}>
36-
<Highlights
37-
text={props.item.snippet}
38-
filter={props.filter}
39-
dir={props.source.textDir}
40-
/>
33+
<Highlights text={props.item.snippet} filter={props.filter} />
4134
</p>
4235
</div>
4336
)

src/components/cards/highlights.tsx

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ type HighlightsProps = {
77
text: string
88
filter: FeedFilter
99
title?: boolean
10-
dir?: SourceTextDirection
1110
}
1211

1312
const Highlights: React.FunctionComponent<HighlightsProps> = props => {
@@ -59,22 +58,10 @@ const Highlights: React.FunctionComponent<HighlightsProps> = props => {
5958
}
6059
}
6160

62-
const testStyle = {
63-
direction: "inherit",
64-
} as React.CSSProperties
65-
if (props.dir === SourceTextDirection.RTL) {
66-
testStyle.direction = "rtl"
67-
}
6861
return (
6962
<>
7063
{spans.map(([text, flag]) =>
71-
flag ? (
72-
<div className="h" style={testStyle}>
73-
{text}
74-
</div>
75-
) : (
76-
<div style={testStyle}>{text}</div>
77-
)
64+
flag ? <span className="h">{text}</span> : text
7865
)}
7966
</>
8067
)

src/components/cards/list-card.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@ import { Card } from "./card"
33
import CardInfo from "./info"
44
import Highlights from "./highlights"
55
import { ViewConfigs } from "../../schema-types"
6+
import { SourceTextDirection } from "../../scripts/models/source"
67

78
const className = (props: Card.Props) => {
89
let cn = ["card", "list-card"]
910
if (props.item.hidden) cn.push("hidden")
1011
if (props.selected) cn.push("selected")
1112
if (props.viewConfigs & ViewConfigs.FadeRead && props.item.hasRead)
1213
cn.push("read")
14+
if (props.source.textDir === SourceTextDirection.RTL) cn.push("rtl")
1315
return cn.join(" ")
1416
}
1517

@@ -31,15 +33,13 @@ const ListCard: React.FunctionComponent<Card.Props> = props => (
3133
text={props.item.title}
3234
filter={props.filter}
3335
title
34-
dir={props.source.textDir}
3536
/>
3637
</h3>
3738
{Boolean(props.viewConfigs & ViewConfigs.ShowSnippet) && (
3839
<p className="snippet">
3940
<Highlights
4041
text={props.item.snippet}
4142
filter={props.filter}
42-
dir={props.source.textDir}
4343
/>
4444
</p>
4545
)}

src/components/cards/magazine-card.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@ import * as React from "react"
22
import { Card } from "./card"
33
import CardInfo from "./info"
44
import Highlights from "./highlights"
5+
import { SourceTextDirection } from "../../scripts/models/source"
56

67
const className = (props: Card.Props) => {
78
let cn = ["card", "magazine-card"]
89
if (props.item.hasRead) cn.push("read")
910
if (props.item.hidden) cn.push("hidden")
11+
if (props.source.textDir === SourceTextDirection.RTL) cn.push("rtl")
1012
return cn.join(" ")
1113
}
1214

@@ -28,14 +30,12 @@ const MagazineCard: React.FunctionComponent<Card.Props> = props => (
2830
text={props.item.title}
2931
filter={props.filter}
3032
title
31-
dir={props.source.textDir}
3233
/>
3334
</h3>
3435
<p className="snippet">
3536
<Highlights
3637
text={props.item.snippet}
3738
filter={props.filter}
38-
dir={props.source.textDir}
3939
/>
4040
</p>
4141
</div>

0 commit comments

Comments
 (0)