From b9ee8f1f219cc8615eb3bf01e674e9c99131eb33 Mon Sep 17 00:00:00 2001 From: Yugay Vasiliy <31739813+Vas9ka@users.noreply.github.com> Date: Wed, 15 May 2024 14:22:25 +0200 Subject: [PATCH] Adjusting view of ordered signs (#479) * * Added space between lines * Signs are aligned by KWIC * Added space after similar text * Underline restored for signs' links * Fixed gradient * Reduced complexity * Refactoring --- src/signs/ui/search/Signs.sass | 16 ++++++- src/signs/ui/search/SignsSearch.tsx | 66 ++++++++++++++++++++++------- 2 files changed, 65 insertions(+), 17 deletions(-) diff --git a/src/signs/ui/search/Signs.sass b/src/signs/ui/search/Signs.sass index cf4918f1f..7cbdce13e 100644 --- a/src/signs/ui/search/Signs.sass +++ b/src/signs/ui/search/Signs.sass @@ -48,8 +48,8 @@ font-family: Assurbanipal, Junicode, serif .Neo-Babylonian - font-size: 125% - font-family: 'Esagil' + font-size: 150% + font-family: Neo-Babylonian,'Adobe Blank', Junicode, serif .beginning background: linear-gradient(to left, grey 50%, blue 50%) @@ -57,7 +57,19 @@ .ending background: linear-gradient(to right, grey 50%, blue 50%) +.similar_text + padding-right: 5px .secondary -webkit-background-clip: text -webkit-text-fill-color: transparent padding: 0.3em 0 + margin-left: 5px + +.before + text-align: right +.after + text-align: left + +span a:hover + text-decoration: underline + -webkit-text-fill-color: #0056b3 \ No newline at end of file diff --git a/src/signs/ui/search/SignsSearch.tsx b/src/signs/ui/search/SignsSearch.tsx index 3572eba23..ae549f0b3 100644 --- a/src/signs/ui/search/SignsSearch.tsx +++ b/src/signs/ui/search/SignsSearch.tsx @@ -10,7 +10,6 @@ import 'dictionary/ui/search/Word.css' import { compareCleanedAkkadianString } from 'dictionary/domain/compareAkkadianStrings' import './Signs.sass' import MesZL from 'signs/ui/search/MesZL' -import classnames from 'classnames' interface Props { signs: Sign[] @@ -28,6 +27,38 @@ function displayUnicode(unicode: readonly number[]): string { return unicode.map((unicode) => String.fromCodePoint(unicode)).join('') } +const renderSignColumn = ( + data, + startIndex, + endIndex, + label, + direction, + language +) => ( + <> + {label === 'before' && ( + {`Similar ${direction} (${language}): `} + )} + + {data.slice(startIndex, endIndex).map((item, index) => ( + + {label === 'center' ? ( + displayUnicode(item.unicode) + ) : ( + + {displayUnicode(item.unicode)} + + )} + + ))} + + +) const SignLists = withData< { sign: Sign; sortEra: string }, { signService: SignService }, @@ -38,22 +69,27 @@ const SignLists = withData< const language = sortEra.includes('Babylonian') ? 'Neo-Babylonian' : 'Neo-Assyrian' + const signIndex = data.findIndex((item) => item.name === sign.name) + return _.isEmpty(data) ? null : ( <> - {`Similar ${direction} (${language}): `} - {data.map((item, index) => ( - - {item.name === sign.name ? ( - {displayUnicode(item.unicode)} - ) : ( - - - {displayUnicode(item.unicode)} - - - )} - - ))} + {renderSignColumn(data, 0, signIndex, 'before', direction, language)} + {renderSignColumn( + data, + signIndex, + signIndex + 1, + 'center', + direction, + language + )} + {renderSignColumn( + data, + signIndex + 1, + data.length, + 'after', + direction, + language + )} ) },