feat: standarize titles

This commit is contained in:
Jean-Philippe Sirois
2019-09-17 02:40:12 -04:00
parent 3d0b733df4
commit edac103a42
4 changed files with 42 additions and 28 deletions
+8 -23
View File
@@ -1,8 +1,7 @@
import pipe from "ramda/es/pipe"
import React from "react"
import ChevronUp from "../../icons/chevron-up.svg"
import { traversePaths } from "../../utils"
import { humanize, traversePaths } from "../../utils"
import { IFileOrFolder } from "../ResourcesSidebar/index"
import * as SC from "./styles"
@@ -10,24 +9,6 @@ interface IResourceBreadcrumbProps {
relativePath: any
}
function capitalize(str: string): string {
return str
.split(" ")
.map(word => `${word.charAt(0).toUpperCase()}${word.substring(1)}`)
.join(" ")
}
function dashToSpace(str: string): string {
return str.replace("-", " ")
}
function humanize(str: string): string {
return pipe(
dashToSpace,
capitalize
)(str)
}
function Link({ item }: { item: IFileOrFolder }) {
return <SC.StyledLink to={item.path}>{humanize(item.title)}</SC.StyledLink>
}
@@ -51,7 +32,7 @@ export function ResourceBreadcrumb({ relativePath }: IResourceBreadcrumbProps) {
<SC.ResourceBreadcrumbWrapper>
<SC.LinkWrapper>
<Link
item={{ path: "/", title: "Home", type: "folder", children: [] }}
item={{ path: "/", title: "home", type: "folder", children: [] }}
/>
<ChevronUp />
</SC.LinkWrapper>
@@ -59,7 +40,7 @@ export function ResourceBreadcrumb({ relativePath }: IResourceBreadcrumbProps) {
<Link
item={{
path: "/resources",
title: "Resources",
title: "resources",
type: "folder",
children: [],
}}
@@ -76,7 +57,11 @@ export function ResourceBreadcrumb({ relativePath }: IResourceBreadcrumbProps) {
)
}
return <SC.CurrentPage key={item.path}>{item.title}</SC.CurrentPage>
return (
<SC.CurrentPage key={item.path}>
{humanize(item.title)}
</SC.CurrentPage>
)
})}
</SC.ResourceBreadcrumbWrapper>
)