-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fafa09d
commit 1cb2f88
Showing
3 changed files
with
67 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
.fragment-annotator__markable-token | ||
flex-grow: 0 | ||
padding-left: 0 | ||
padding-right: 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
import React from 'react' | ||
import { Fragment } from 'fragmentarium/domain/fragment' | ||
import { Col, Container, Row } from 'react-bootstrap' | ||
import { Token } from 'transliteration/domain/token' | ||
import { isShift, isTextLine } from 'transliteration/domain/type-guards' | ||
import './FragmentAnnotator.sass' | ||
import { TextLine } from 'transliteration/domain/text-line' | ||
import { AbstractLine } from 'transliteration/domain/abstract-line' | ||
|
||
function isMarkable(token: Token): boolean { | ||
return !isShift(token) | ||
} | ||
|
||
function DisplayMarkableRow({ line }: { line: TextLine }): JSX.Element { | ||
return ( | ||
<Row> | ||
{line.content.map((token, index) => ( | ||
<React.Fragment key={index}> | ||
{index !== 0 && <> </>} | ||
{isMarkable(token) && ( | ||
<Col className={'fragment-annotator__markable-token'}> | ||
{token.cleanValue} | ||
</Col> | ||
)} | ||
</React.Fragment> | ||
))} | ||
</Row> | ||
) | ||
} | ||
|
||
function DisplayUnmarkableRow({ line }: { line: AbstractLine }): JSX.Element { | ||
return <Row>{`(${line.prefix}A ${line.type})`}</Row> | ||
} | ||
|
||
export default function FragmentAnnotator({ | ||
fragment, | ||
}: { | ||
fragment: Fragment | ||
}): JSX.Element { | ||
console.log(fragment.text) | ||
return ( | ||
<> | ||
{fragment.text.lines.map((line, index) => ( | ||
<Container key={index}> | ||
{isTextLine(line) ? ( | ||
<DisplayMarkableRow line={line} /> | ||
) : ( | ||
<DisplayUnmarkableRow line={line} /> | ||
)} | ||
</Container> | ||
))} | ||
</> | ||
) | ||
} |