Skip to content

Commit

Permalink
🔨 move selection to top of entities column
Browse files Browse the repository at this point in the history
  • Loading branch information
samizdatco committed Nov 21, 2023
1 parent 3cb2565 commit f2585b8
Showing 1 changed file with 30 additions and 18 deletions.
48 changes: 30 additions & 18 deletions packages/@ourworldindata/grapher/src/modal/EntitySelectorModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,16 @@ export class EntitySelectorModal extends React.Component<{
}

render(): JSX.Element {
const { selectionArray, searchResults, searchInput, isMulti, manager } =
this
const {
selectionArray,
searchResults,
searchInput,
isMulti,
manager: { entityTypePlural, entitiesAreCountryLike },
} = this

const title = isMulti
? `Add/remove ${manager.entityTypePlural}`
? `Add/remove ${entityTypePlural}`
: `Choose ${a(this.entityType)}`

return (
Expand Down Expand Up @@ -235,31 +240,38 @@ export class EntitySelectorModal extends React.Component<{
</div>
</div>
<div className="entities">
{this.renderSelectedData()}
<div className="searchResults">
{searchResults.length > 0 ? (
<ul>
{searchResults.map((result) => (
<EntitySearchResult
key={result.name}
result={result}
isMulti={this.isMulti}
isChecked={selectionArray.selectedSet.has(
result.name
)}
onSelect={this.onSelect}
/>
))}
</ul>
<>
<div className="searchResultsLabel">
{entitiesAreCountryLike
? "Countries, regions, and groups"
: entityTypePlural}
</div>
<ul>
{searchResults.map((result) => (
<EntitySearchResult
key={result.name}
result={result}
isMulti={this.isMulti}
isChecked={selectionArray.selectedSet.has(
result.name
)}
onSelect={this.onSelect}
/>
))}
</ul>
</>
) : (
<div className="empty">
{this.manager.entitiesAreCountryLike &&
{entitiesAreCountryLike &&
isCountryName(this.searchInput)
? "There is no data for the country, region or group you are looking for."
: "Nothing turned up. You may want to try using different keywords or checking for typos."}
</div>
)}
</div>
{this.renderSelectedData()}
</div>
</div>
</Modal>
Expand Down

0 comments on commit f2585b8

Please sign in to comment.