feat(resources): capitalize breadcrumbs + add home

Fixed linting errors

Fix linting errors again
This commit is contained in:
Hayden Young
2019-08-19 00:13:59 -04:00
committed by Jean-Philippe Sirois
parent adb2a925ba
commit e53ed690df
+27 -1
View File
@@ -9,8 +9,17 @@ interface IResourceBreadcrumbProps {
relativePath: any
}
function capitalize(str: string): string {
const split = str.split(" ")
const reconstruct = []
for (const substr of split) {
reconstruct.push(`${substr.charAt(0).toUpperCase()}${substr.substring(1)}`)
}
return reconstruct.join(" ")
}
function Link({ item }: { item: IFileOrFolder }) {
return <SC.StyledLink to={item.path}>{item.title}</SC.StyledLink>
return <SC.StyledLink to={item.path}>{capitalize(item.title)}</SC.StyledLink>
}
function flatten([
@@ -30,6 +39,23 @@ export function ResourceBreadcrumb({ relativePath }: IResourceBreadcrumbProps) {
return (
<SC.ResourceBreadcrumbWrapper>
<SC.LinkWrapper>
<Link
item={{ path: "/", title: "Home", type: "folder", children: [] }}
/>
<ChevronUp />
</SC.LinkWrapper>
<SC.LinkWrapper>
<Link
item={{
path: "/resources",
title: "Resources",
type: "folder",
children: [],
}}
/>
<ChevronUp />
</SC.LinkWrapper>
{breadcrumbItems.map(item => {
if (item.type === "folder") {
return (