From a73bc491dfe17b3612820b988b75349129121dba Mon Sep 17 00:00:00 2001
From: Yousef Javaherian
Date: Fri, 11 Mar 2022 02:40:03 +0330
Subject: [PATCH] title & snippet in card component now respect source text dir
attribute
---
package-lock.json | 10 +++++-----
src/components/cards/compact-card.tsx | 7 ++++++-
src/components/cards/default-card.tsx | 13 +++++++++++--
src/components/cards/highlights.tsx | 19 ++++++++++++++++++-
src/components/cards/list-card.tsx | 2 ++
src/components/cards/magazine-card.tsx | 2 ++
6 files changed, 44 insertions(+), 9 deletions(-)
diff --git a/package-lock.json b/package-lock.json
index 69ad249..6e9cf5c 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -8,9 +8,6 @@
"name": "fluent-reader",
"version": "1.1.0",
"license": "BSD-3-Clause",
- "dependencies": {
- "font-list": "^1.4.2"
- },
"devDependencies": {
"@fluentui/react": "^7.126.2",
"@types/lovefield": "^2.1.3",
@@ -24,6 +21,7 @@
"electron-react-devtools": "^0.5.3",
"electron-store": "^5.2.0",
"electron-window-state": "^5.0.3",
+ "font-list": "^1.4.2",
"hard-source-webpack-plugin": "^0.13.1",
"html-webpack-plugin": "^4.3.0",
"js-md5": "^0.7.3",
@@ -4192,7 +4190,8 @@
"node_modules/font-list": {
"version": "1.4.2",
"resolved": "https://registry.npmjs.org/font-list/-/font-list-1.4.2.tgz",
- "integrity": "sha512-vPekA+sinAymEkNHwnOse0D75phwNvH/E0z/mJSgGoCBVKy+rLZzd3HziYVwlII34bb0ZYOKBbM36s2bfCaR1A=="
+ "integrity": "sha512-vPekA+sinAymEkNHwnOse0D75phwNvH/E0z/mJSgGoCBVKy+rLZzd3HziYVwlII34bb0ZYOKBbM36s2bfCaR1A==",
+ "dev": true
},
"node_modules/for-in": {
"version": "1.0.2",
@@ -12739,7 +12738,8 @@
"font-list": {
"version": "1.4.2",
"resolved": "https://registry.npmjs.org/font-list/-/font-list-1.4.2.tgz",
- "integrity": "sha512-vPekA+sinAymEkNHwnOse0D75phwNvH/E0z/mJSgGoCBVKy+rLZzd3HziYVwlII34bb0ZYOKBbM36s2bfCaR1A=="
+ "integrity": "sha512-vPekA+sinAymEkNHwnOse0D75phwNvH/E0z/mJSgGoCBVKy+rLZzd3HziYVwlII34bb0ZYOKBbM36s2bfCaR1A==",
+ "dev": true
},
"for-in": {
"version": "1.0.2",
diff --git a/src/components/cards/compact-card.tsx b/src/components/cards/compact-card.tsx
index 566bfdc..e7eb594 100644
--- a/src/components/cards/compact-card.tsx
+++ b/src/components/cards/compact-card.tsx
@@ -23,10 +23,15 @@ const CompactCard: React.FunctionComponent = props => (
text={props.item.title}
filter={props.filter}
title
+ dir={props.source.textDir}
/>
-
+
diff --git a/src/components/cards/default-card.tsx b/src/components/cards/default-card.tsx
index c4d08a8..9edb85f 100644
--- a/src/components/cards/default-card.tsx
+++ b/src/components/cards/default-card.tsx
@@ -25,10 +25,19 @@ const DefaultCard: React.FunctionComponent = props => (
) : null}
-
+
-
+
)
diff --git a/src/components/cards/highlights.tsx b/src/components/cards/highlights.tsx
index e790519..6be11f3 100644
--- a/src/components/cards/highlights.tsx
+++ b/src/components/cards/highlights.tsx
@@ -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 = props => {
@@ -57,10 +59,25 @@ const Highlights: React.FunctionComponent = 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 ? {text} : text
+ flag ? (
+
+ {text}
+
+ ) : (
+ {text}
+ )
)}
>
)
diff --git a/src/components/cards/list-card.tsx b/src/components/cards/list-card.tsx
index 5afa8e1..5707226 100644
--- a/src/components/cards/list-card.tsx
+++ b/src/components/cards/list-card.tsx
@@ -31,6 +31,7 @@ const ListCard: React.FunctionComponent = props => (
text={props.item.title}
filter={props.filter}
title
+ dir={props.source.textDir}
/>
{Boolean(props.viewConfigs & ViewConfigs.ShowSnippet) && (
@@ -38,6 +39,7 @@ const ListCard: React.FunctionComponent = props => (
)}
diff --git a/src/components/cards/magazine-card.tsx b/src/components/cards/magazine-card.tsx
index d38f675..7ecc3d9 100644
--- a/src/components/cards/magazine-card.tsx
+++ b/src/components/cards/magazine-card.tsx
@@ -28,12 +28,14 @@ const MagazineCard: React.FunctionComponent = props => (
text={props.item.title}
filter={props.filter}
title
+ dir={props.source.textDir}
/>