improved breadcrum
This commit is contained in:
parent
d4ff2d9480
commit
f872bec629
@ -1,45 +1,55 @@
|
|||||||
import React from "react"
|
import React from "react"
|
||||||
import ObjID from "../types/ObjID"
|
import ObjID from "../types/ObjID"
|
||||||
import { ReactComponent as BreadcrumImage } from "./../assets/breadcrum.svg"
|
import { ReactComponent as BreadcrumImage } from "./../assets/breadcrum.svg"
|
||||||
|
import { Link } from "react-router-dom"
|
||||||
|
|
||||||
interface Props{
|
interface Props{
|
||||||
path: ObjID
|
path?: ObjID
|
||||||
onDirClick?: (path: ObjID) => void
|
onDirClick?: (path: ObjID) => void
|
||||||
}
|
}
|
||||||
|
|
||||||
const Breadcrum: React.FC<Props> = (props) => {
|
const Breadcrum: React.FC<Props> = ({path,onDirClick}) => {
|
||||||
const keyParts = props.path.key.split("/").filter(e=>e.length > 0)
|
|
||||||
|
if (!path){
|
||||||
|
return <ul className="flex text-gray-500 dark:text-gray-400 text-lg ">
|
||||||
|
<div className="breadcrum-item text-blue-500">
|
||||||
|
<Link to="/f/">
|
||||||
|
Home
|
||||||
|
</Link>
|
||||||
|
</div>
|
||||||
|
</ul>
|
||||||
|
}
|
||||||
|
|
||||||
|
const keyParts = path.key.split("/").filter(e=>e.length > 0)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ul className="flex text-gray-500 dark:text-gray-400 text-lg ">
|
<ul className="flex text-gray-500 dark:text-gray-400 text-lg ">
|
||||||
<div className="inline-flex items-center cursor-pointer">
|
<div className="breadcrum-item">
|
||||||
<li>
|
<Link to="/f/">
|
||||||
<a>
|
Home
|
||||||
{props.path.bucket}
|
</Link>
|
||||||
</a>
|
|
||||||
</li>
|
|
||||||
</div>
|
</div>
|
||||||
<div className="inline-flex items-center cursor-pointer">
|
<div className="breadcrum-item">
|
||||||
<BreadcrumImage className="h-5 w-auto text-gray-400" />
|
<BreadcrumImage className="h-5 w-auto text-gray-400" />
|
||||||
<li>
|
<li>
|
||||||
<a onClick={()=>{
|
<a className={!keyParts.length?"text-blue-500":""} onClick={()=>{
|
||||||
props.onDirClick?.(new ObjID(props.path.bucket,"/"))
|
onDirClick?.(new ObjID(path.bucket,"/"))
|
||||||
}}>
|
}}>
|
||||||
root
|
{path.bucket}
|
||||||
</a>
|
</a>
|
||||||
</li>
|
</li>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{keyParts.map((e,i,arr)=>{
|
{keyParts.map((e,i,arr)=>{
|
||||||
const last = i == arr.length - 1
|
const last = i == arr.length - 1
|
||||||
return <div key={e} className="inline-flex items-center cursor-pointer">
|
return <div key={e} className="breadcrum-item">
|
||||||
<BreadcrumImage className="h-5 w-auto text-gray-400" />
|
<BreadcrumImage className="h-5 w-auto text-gray-400" />
|
||||||
<li>
|
<li>
|
||||||
<a
|
<a
|
||||||
className={`${last?"text-blue-500":""}`}
|
className={`${last?"text-blue-500":""}`}
|
||||||
onClick={()=>{
|
onClick={()=>{
|
||||||
if (!last){
|
if (!last){
|
||||||
props.onDirClick?.(new ObjID(props.path.bucket,"/"+arr.slice(0,i-1).join("/")))
|
onDirClick?.(new ObjID(path.bucket,"/"+arr.slice(0,i-1).join("/")))
|
||||||
}
|
}
|
||||||
}}>{e}</a>
|
}}>{e}</a>
|
||||||
</li>
|
</li>
|
||||||
|
@ -7,3 +7,7 @@
|
|||||||
.text-input{
|
.text-input{
|
||||||
@apply bg-transparent border-gray-900 dark:border-gray-300 dark:text-gray-300 outline-none border-b
|
@apply bg-transparent border-gray-900 dark:border-gray-300 dark:text-gray-300 outline-none border-b
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.breadcrum-item{
|
||||||
|
@apply inline-flex items-center cursor-pointer
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user