generated from spatie/package-skeleton-php
-
-
Notifications
You must be signed in to change notification settings - Fork 56
/
Copy pathFilePath.tsx
29 lines (26 loc) · 832 Bytes
/
FilePath.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import React from 'react';
type Props = {
path: string;
className?: string;
style?: React.CSSProperties;
};
export default function FilePath({ path, className = '', ...props }: Props) {
const segments = path.replace(/^\/Users/, '~').split('/');
const file = segments.pop() || '';
const fileSegments = file.split('.');
return (
<span className={`ui-path ${className}`} {...props}>
{segments.map((segment, i) => (
<span key={i}>
{segment}/<wbr />
</span>
))}
{fileSegments.map((fileSegment, i) => (
<span key={i} className={i === 0 ? 'font-semibold' : ''}>
{i > 0 && '.'}
{fileSegment}
</span>
))}
</span>
);
}