Skip to content

Commit 86c955e

Browse files
committed
release: v0.3.0
1 parent 2f44f1b commit 86c955e

6 files changed

Lines changed: 21 additions & 5 deletions

File tree

index.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@
129129
"react": true,
130130
"install": true,
131131
"dependencies": ["data-grid", "icon-list"],
132-
"version": "0.5.5",
132+
"version": "0.5.6",
133133
"style": true,
134134
"icon": false,
135135
"test": true
@@ -327,7 +327,7 @@
327327
"path-bar": {
328328
"icon": true,
329329
"react": true,
330-
"version": "0.2.2",
330+
"version": "0.3.0",
331331
"style": true,
332332
"test": true,
333333
"install": false,

src/path-bar/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,4 @@ pathBar.on('change', (path) => {
3939
## Configuration
4040

4141
* path(string): File path.
42+
* rootLabel(string): Root label.

src/path-bar/index.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ import isStrBlank from 'licia/isStrBlank'
1313
export interface IOptions extends IComponentOptions {
1414
/** File path. */
1515
path: string
16+
/** Root label. */
17+
rootLabel: string
1618
}
1719

1820
/**
@@ -51,6 +53,14 @@ export default class PathBar extends Component {
5153

5254
const paths: string[] = []
5355
this.$address.html('')
56+
57+
const rootEl = toEl(
58+
`<div class="${c('item')}" data-path="">${escape(
59+
this.options.rootLabel
60+
)}<span class="${c('icon-right')}"></span></div>`
61+
)
62+
this.$address.append(rootEl)
63+
5464
const parts = filter(path.split('/'), (part) => !isStrBlank(part))
5565
each(parts, (part) => {
5666
paths.push(part)
@@ -104,6 +114,7 @@ export default class PathBar extends Component {
104114

105115
this.on('changeOption', (name) => {
106116
switch (name) {
117+
case 'rootLabel':
107118
case 'path':
108119
this.render()
109120
break

src/path-bar/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "path-bar",
3-
"version": "0.2.2",
3+
"version": "0.3.0",
44
"description": "File explorer path bar",
55
"luna": {
66
"icon": true,

src/path-bar/react.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,13 @@ const LunaPathBar: FC<IPathBarProps> = (props) => {
1818
pathBarRef.current = new PathBar(containerRef.current!, {
1919
theme: props.theme,
2020
path: props.path,
21+
rootLabel: props.rootLabel,
2122
})
2223

2324
return () => pathBarRef.current?.destroy()
2425
}, [])
2526

26-
each(['theme', 'path'], (key: keyof IPathBarProps) => {
27+
each(['theme', 'path', 'rootLabel'], (key: keyof IPathBarProps) => {
2728
useOption<PathBar, IPathBarProps>(pathBarRef, key, props[key])
2829
})
2930

src/path-bar/story.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,10 @@ import { text } from '@storybook/addon-knobs'
88
const def = story(
99
'path-bar',
1010
(container) => {
11-
const { path } = createKnobs()
11+
const { path, rootLabel } = createKnobs()
1212

1313
const pathBar = new PathBar(container, {
14+
rootLabel,
1415
path,
1516
})
1617

@@ -38,9 +39,11 @@ const def = story(
3839
)
3940

4041
function createKnobs() {
42+
const rootLabel = text('Root Label', 'disk')
4143
const path = text('Initial Path', '/home/user')
4244

4345
return {
46+
rootLabel,
4447
path,
4548
}
4649
}

0 commit comments

Comments
 (0)