@quran.ws/tajwid-react 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +66 -0
- package/package.json +26 -0
package/README.md
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# @quran.ws/tajwid-react
|
|
2
|
+
|
|
3
|
+
```bash
|
|
4
|
+
npm install @quran.ws/tajwid-react @quran.ws/tajwid-rules @quran.ws/tajwid-annotations
|
|
5
|
+
```
|
|
6
|
+
|
|
7
|
+
```tsx
|
|
8
|
+
import corpus from '@quran.ws/tajwid-rules'
|
|
9
|
+
import annotations from '@quran.ws/tajwid-annotations'
|
|
10
|
+
import { TajweedText, TajweedLegend } from '@quran.ws/tajwid-react'
|
|
11
|
+
import { unpack } from '@quran.ws/tajwid'
|
|
12
|
+
|
|
13
|
+
<TajweedText text={ayahText} corpus={corpus} spans={unpack(annotations, corpus, '2:255')} />
|
|
14
|
+
<TajweedLegend corpus={corpus} />
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Pass `spans` in production. The Quran is a fixed text, so there is no reason to
|
|
18
|
+
run a matching engine in the browser — look the ayah up in
|
|
19
|
+
[`@quran.ws/tajwid-annotations`](../annotations) instead. If you leave `spans` out, the
|
|
20
|
+
component analyses the text itself, which is what a playground or an arbitrary
|
|
21
|
+
passage needs.
|
|
22
|
+
|
|
23
|
+
## What it does that `dangerouslySetInnerHTML` would not
|
|
24
|
+
|
|
25
|
+
**The text is never altered.** Characters are emitted exactly as given, and
|
|
26
|
+
React escapes them on output, so what reaches the DOM is what you passed in.
|
|
27
|
+
|
|
28
|
+
**The word does not come apart where the colour changes.** A browser shapes
|
|
29
|
+
each element on its own, so a coloured stretch is drawn without seeing its
|
|
30
|
+
neighbours: `عَلَيۡهِمۡ` becomes `عَ` `لَيۡهِ` `مۡ`. Every cut is bridged with a
|
|
31
|
+
zero-width joiner where the letters either side join, and pushed past the marks
|
|
32
|
+
written on the letter it lands on. Both belong to the drawing: nothing reaches
|
|
33
|
+
the offsets or the text. `clusterEnd` and `bridgeJoins` are exported from
|
|
34
|
+
[`@quran.ws/tajwid`](../core) for anyone rendering this some other way — see
|
|
35
|
+
[docs/rendering.md](../../docs/rendering.md).
|
|
36
|
+
|
|
37
|
+
**Waqf marks keep the colour around them.** They tell the reciter where to
|
|
38
|
+
pause; they are not part of the letter the ruling is about.
|
|
39
|
+
|
|
40
|
+
**Every coloured stretch carries its ruling in `aria-label`.** Colour alone
|
|
41
|
+
says nothing to a reader who cannot see it — a serious flaw in something meant
|
|
42
|
+
to teach recitation.
|
|
43
|
+
|
|
44
|
+
**Colour is keyed by topic, not by hukum.** There are an order of magnitude more
|
|
45
|
+
ahkam than topics, and past roughly a dozen colours readers stop being able to
|
|
46
|
+
tell them apart. `TOPIC_COLORS` therefore carries one colour per topic, and a
|
|
47
|
+
test holds it equal to the corpus's topic list.
|
|
48
|
+
|
|
49
|
+
Render `<TajweedLegend />`. It iterates the corpus, so it is right whatever the
|
|
50
|
+
topics are. The corpus says nothing outside them; colour without a legend
|
|
51
|
+
suggests the colouring is complete when it is not — see
|
|
52
|
+
[docs/coverage.md](../../docs/coverage.md).
|
|
53
|
+
|
|
54
|
+
## Props
|
|
55
|
+
|
|
56
|
+
| Prop | |
|
|
57
|
+
|---|---|
|
|
58
|
+
| `text` | the ayah text, unmodified |
|
|
59
|
+
| `corpus` | pass `@quran.ws/tajwid-rules` |
|
|
60
|
+
| `spans` | precomputed spans; leave out to analyse on the fly |
|
|
61
|
+
| `options` | engine options when `spans` is left out (`only`, `school`) |
|
|
62
|
+
| `colors` | override the palette, keyed by topic id |
|
|
63
|
+
| `overlapping` | show every ruling rather than only the topmost |
|
|
64
|
+
| `onSpanClick` | called with the span; makes each mark focusable |
|
|
65
|
+
|
|
66
|
+
MIT.
|
package/package.json
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@quran.ws/tajwid-react",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "React components for rendering Quranic text with its tajweed rulings marked.",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"access": "public"
|
|
8
|
+
},
|
|
9
|
+
"type": "module",
|
|
10
|
+
"main": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": { "types": "./dist/index.d.ts", "default": "./dist/index.js" }
|
|
14
|
+
},
|
|
15
|
+
"files": ["dist/", "README.md"],
|
|
16
|
+
"scripts": { "build": "tsc -p tsconfig.json" },
|
|
17
|
+
"peerDependencies": { "react": ">=18" },
|
|
18
|
+
"dependencies": { "@quran.ws/tajwid": "workspace:*" },
|
|
19
|
+
"devDependencies": { "@types/react": "^19.0.1", "react": "^19.0.0" },
|
|
20
|
+
"repository": {
|
|
21
|
+
"type": "git",
|
|
22
|
+
"url": "git+https://github.com/quran-ws/quran-tajweed.git",
|
|
23
|
+
"directory": "packages/react"
|
|
24
|
+
},
|
|
25
|
+
"keywords": ["quran", "tajweed", "react"]
|
|
26
|
+
}
|