-
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.
feat: UILD-420: Compare Bib Resources | Linked
- Loading branch information
Showing
27 changed files
with
550 additions
and
171 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -63,10 +63,6 @@ h6 { | |
line-height: 1.1; | ||
} | ||
|
||
h3 { | ||
margin: 0; | ||
} | ||
|
||
select, | ||
input { | ||
&:disabled { | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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
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,86 @@ | ||
.comparison { | ||
display: flex; | ||
flex-direction: column; | ||
width: 700px; | ||
border-left: 1px solid rgba(0, 0, 0, 0.1); | ||
|
||
header { | ||
display: flex; | ||
flex-direction: column; | ||
|
||
h2 { | ||
display: flex; | ||
align-items: center; | ||
gap: 0.2rem; | ||
font-size: 0.875rem; | ||
line-height: normal; | ||
} | ||
|
||
.heading, | ||
.subheading { | ||
padding: 0.5rem 0.7rem; | ||
display: flex; | ||
flex-direction: row; | ||
justify-content: space-between; | ||
align-items: center; | ||
border-bottom: 1px solid rgba(0, 0, 0, 0.1); | ||
|
||
> * { | ||
font-size: 0.875rem; | ||
font-weight: 700; | ||
} | ||
} | ||
} | ||
|
||
&-contents { | ||
display: flex; | ||
flex-grow: 1; | ||
overflow: hidden; | ||
|
||
.entry { | ||
width: 100%; | ||
min-width: 50%; | ||
overflow-x: hidden; | ||
overflow-y: scroll; | ||
flex: 1; | ||
border-right: 1px solid rgba(0, 0, 0, 0.1); | ||
|
||
&-header { | ||
display: flex; | ||
flex-direction: column; | ||
gap: 0.2rem; | ||
padding: 0.938rem; | ||
|
||
&-controls { | ||
display: flex; | ||
flex-direction: row; | ||
align-items: center; | ||
justify-content: space-between; | ||
} | ||
} | ||
|
||
.preview-entity { | ||
border-right: none; | ||
} | ||
} | ||
|
||
.titled-preview { | ||
width: 100%; | ||
} | ||
|
||
.insufficient-resource-amt { | ||
text-align: center; | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
align-self: center; | ||
width: 100%; | ||
font-size: 1.138rem; | ||
color: rgba(0, 0, 0, 0.62); | ||
|
||
svg { | ||
width: 2.5rem; | ||
} | ||
} | ||
} | ||
} |
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,127 @@ | ||
import { FormattedMessage, useIntl } from 'react-intl'; | ||
import { Pagination } from '@components/Pagination'; | ||
import { useState } from 'react'; | ||
import { useInputsState, useSearchState, useUIState } from '@src/store'; | ||
import { Button, ButtonType } from '@components/Button'; | ||
import Times16 from '@src/assets/times-16.svg?react'; | ||
import TimesCircle12 from '@src/assets/times-circle-12.svg?react'; | ||
import Transfer16 from '@src/assets/transfer-16.svg?react'; | ||
import GeneralSearch from '@src/assets/general-search.svg?react'; | ||
import { Preview } from '@components/Preview'; | ||
import { PreviewActionsDropdown } from '@components/PreviewActionsDropdown'; | ||
import { ResourceType } from '@common/constants/record.constants'; | ||
import { generateEditResourceUrl } from '@common/helpers/navigation.helper'; | ||
import { useNavigateToEditPage } from '@common/hooks/useNavigateToEditPage'; | ||
import './Comparison.scss'; | ||
|
||
export const Comparison = () => { | ||
const { formatMessage } = useIntl(); | ||
const { previewContent, setPreviewContent, resetPreviewContent } = useInputsState(); | ||
const { resetSelectedInstances } = useSearchState(); | ||
const { resetFullDisplayComponentType } = useUIState(); | ||
const { navigateToEditPage } = useNavigateToEditPage(); | ||
const [currentPage, setCurrentPage] = useState(0); | ||
|
||
const handleCloseComparison = () => { | ||
resetPreviewContent(); | ||
resetFullDisplayComponentType(); | ||
resetSelectedInstances(); | ||
}; | ||
|
||
const handleRemoveComparisonItem = (id: string) => { | ||
setPreviewContent(prev => prev.filter(({ id: prevId }) => prevId !== id)); | ||
}; | ||
|
||
const handleNavigateToOwnEditPage = (id: string) => navigateToEditPage(generateEditResourceUrl(id)); | ||
const totalPages = (previewContent.length > 1 ? previewContent.length : 2) - 1; | ||
|
||
return ( | ||
<section className="comparison"> | ||
<header> | ||
<div className="heading"> | ||
<Button | ||
data-testid="close-comparison-section" | ||
type={ButtonType.Icon} | ||
onClick={handleCloseComparison} | ||
className="nav-close" | ||
ariaLabel={formatMessage({ id: 'ld.aria.comparison.close' })} | ||
> | ||
<Times16 /> | ||
</Button> | ||
<h2> | ||
<Transfer16 /> | ||
<FormattedMessage id="ld.compareResources" /> | ||
</h2> | ||
<span className="empty-block" /> | ||
</div> | ||
<div className="subheading"> | ||
<span> | ||
<FormattedMessage id="ld.nResourcesSelected" values={{ n: previewContent.length }} /> | ||
</span> | ||
<Button | ||
data-testid="clear-comparison-selections" | ||
type={ButtonType.Icon} | ||
onClick={resetPreviewContent} | ||
disabled={!previewContent.length} | ||
className="nav-close" | ||
> | ||
<TimesCircle12 /> | ||
<FormattedMessage id="ld.clearSelections" /> | ||
</Button> | ||
</div> | ||
</header> | ||
<div className="comparison-contents"> | ||
{previewContent | ||
.slice(currentPage, currentPage + 2) | ||
.map(({ initKey, base, userValues, id, title, referenceIds }) => ( | ||
<section key={id} className='entry'> | ||
<div className="entry-header"> | ||
<div className="entry-header-controls"> | ||
<Button | ||
data-testid="remove-comparison-entry" | ||
type={ButtonType.Icon} | ||
onClick={() => handleRemoveComparisonItem(id)} | ||
className="nav-close" | ||
ariaLabel={formatMessage({ id: 'ld.aria.comparison.removeEntry' })} | ||
> | ||
<Times16 /> | ||
</Button> | ||
<PreviewActionsDropdown | ||
ownId={id} | ||
referenceId={referenceIds?.[0]?.id as unknown as string} | ||
entityType={ResourceType.instance} | ||
handleNavigateToEditPage={() => handleNavigateToOwnEditPage(id)} | ||
/> | ||
</div> | ||
<h3>{title}</h3> | ||
</div> | ||
<Preview | ||
altInitKey={initKey} | ||
altSchema={base} | ||
altUserValues={userValues} | ||
forceRenderAllTopLevelEntities | ||
/> | ||
</section> | ||
))} | ||
{previewContent.length <= 1 && ( | ||
<div className="insufficient-resource-amt"> | ||
<GeneralSearch /> | ||
<FormattedMessage | ||
id={!previewContent.length ? 'ld.chooseTwoResourcesCompare' : 'ld.chooseOneResourceCompare'} | ||
/> | ||
</div> | ||
)} | ||
</div> | ||
<nav aria-label={formatMessage({ id: 'ld.selectedResources' })}> | ||
<Pagination | ||
currentPage={currentPage} | ||
onNextPageClick={() => setCurrentPage(prev => prev + 1)} | ||
onPrevPageClick={() => setCurrentPage(prev => prev - 1)} | ||
totalPages={totalPages} | ||
totalResultsCount={totalPages} | ||
showCount | ||
/> | ||
</nav> | ||
</section> | ||
); | ||
}; |
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 @@ | ||
export { Comparison } from './Comparison'; |
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
Oops, something went wrong.