improved breadcrum

This commit is contained in:
Niklas 2021-08-18 00:36:28 +02:00
parent ecffd9e9fe
commit b8f9fbf73a
2 changed files with 31 additions and 13 deletions

11
src/assets/breadcrum.svg Normal file
View File

@ -0,0 +1,11 @@
<svg
class="h-5 w-auto text-gray-400"
fill="currentColor"
viewBox="0 0 20 20"
>
<path
fillRule="evenodd"
d="M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 011.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z"
clipRule="evenodd"
></path>
</svg>

After

Width:  |  Height:  |  Size: 302 B

View File

@ -1,5 +1,6 @@
import React from "react" import React from "react"
import PropTypes from "prop-types" import PropTypes from "prop-types"
import { ReactComponent as BreadcrumImage } from "./../assets/breadcrum.svg"
interface Props{ interface Props{
path: string path: string
@ -10,25 +11,31 @@ const Breadcrum: React.FC<Props> = (props) => {
const parts = props.path.split("/").filter(e=>e.length > 0) const parts = props.path.split("/").filter(e=>e.length > 0)
return ( return (
<ul> <ul className="flex text-gray-500 text-lg">
<li className="inline mr-1"> <li className="inline-flex items-center">
<a onClick={()=>{ <a onClick={()=>{
props.onDirClick?.("/") props.onDirClick?.("/")
}}> }}>
Root Root
</a> </a>
</li> </li>
{parts.map((e,i,arr)=>( {parts.map((e,i,arr)=>{
<> const last = i == arr.length - 1
<li className="inline mx-1">/</li> return (<>
<li key={e} className="inline mx-1"> <BreadcrumImage />
<a onClick={()=>{ <li key={e} className="inline-flex items-center">
if (i != arr.length - 1){ <a
className={last?"text-blue-500":""}
onClick={()=>{
if (!last){
props.onDirClick?.("/"+arr.slice(0,i-1).join("/")) props.onDirClick?.("/"+arr.slice(0,i-1).join("/"))
} }
}}>{e}</a> }}>{e}</a>
</li></>))} </li>
</>)
})}
</ul> </ul>
) )
} }