Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Correct behavior of the link closing isolated view (#1627)
Fixes #1479
- Loading branch information
Barthélémy Ledoux
committed
Jul 22, 2020
1 parent
967ba9e
commit 9b6b6f6
Showing
25 changed files
with
192 additions
and
763 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
35 changes: 3 additions & 32 deletions
35
src/client/rsg-components/ComponentsList/ComponentsList.tsx
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 |
---|---|---|
@@ -1,49 +1,20 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import ComponentsListRenderer from 'rsg-components/ComponentsList/ComponentsListRenderer'; | ||
import getUrl from '../../utils/getUrl'; | ||
import * as Rsg from '../../../typings'; | ||
|
||
interface ComponentsListProps { | ||
items: Rsg.TOCItem[]; | ||
hashPath?: string[]; | ||
useRouterLinks?: boolean; | ||
useHashId?: boolean; | ||
} | ||
|
||
const ComponentsList: React.FunctionComponent<ComponentsListProps> = ({ | ||
items, | ||
useRouterLinks = false, | ||
useHashId, | ||
hashPath, | ||
}) => { | ||
const mappedItems = items | ||
.map(item => { | ||
const href = item.href | ||
? item.href | ||
: getUrl({ | ||
name: item.name, | ||
slug: item.slug, | ||
anchor: !useRouterLinks, | ||
hashPath: useRouterLinks ? hashPath : false, | ||
id: useRouterLinks ? useHashId : false, | ||
}); | ||
const ComponentsList: React.FunctionComponent<ComponentsListProps> = ({ items }) => { | ||
const visibleItems = items.filter(item => item.visibleName); | ||
|
||
return { | ||
...item, | ||
href, | ||
}; | ||
}) | ||
.filter(item => item.visibleName); | ||
|
||
return mappedItems.length > 0 ? <ComponentsListRenderer items={mappedItems} /> : null; | ||
return visibleItems.length > 0 ? <ComponentsListRenderer items={visibleItems} /> : null; | ||
}; | ||
|
||
ComponentsList.propTypes = { | ||
items: PropTypes.array.isRequired, | ||
hashPath: PropTypes.array, | ||
useRouterLinks: PropTypes.bool, | ||
useHashId: PropTypes.bool, | ||
}; | ||
|
||
export default ComponentsList; |
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
Oops, something went wrong.