Skip to content

Commit 89ba23e

Browse files
committed
Polish Breadcrumbs styles
1 parent 00fd9f3 commit 89ba23e

File tree

3 files changed

+68
-25
lines changed

3 files changed

+68
-25
lines changed

src/vscode-breadcrumb-item/vscode-breadcrumb-item.styles.ts

Lines changed: 37 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,17 @@ const styles: CSSResultGroup = [
55
defaultStyles,
66
css`
77
:host {
8-
display: inline-flex;
9-
align-items: center;
10-
gap: 6px;
11-
color: var(--vscode-breadcrumb-foreground, inherit);
12-
outline: none;
13-
cursor: default;
8+
display: inline-block;
149
}
1510
1611
:host(:focus) {
17-
color: var(
18-
--vscode-breadcrumb-focusForeground,
19-
var(--vscode-breadcrumb-foreground, inherit)
20-
);
12+
outline: none;
13+
}
14+
15+
:host(:focus) .root {
16+
color: var(--vscode-breadcrumb-focusForeground, #e0e0e0);
17+
outline: 1px solid var(--vscode-focusBorder, #0078d4);
18+
text-decoration: underline;
2119
}
2220
2321
:host(.selected) {
@@ -27,21 +25,45 @@ const styles: CSSResultGroup = [
2725
);
2826
}
2927
28+
.root {
29+
display: flex;
30+
align-items: center;
31+
color: var(--vscode-breadcrumb-foreground, inherit);
32+
outline: none;
33+
cursor: pointer;
34+
}
35+
36+
:host(:hover) .root {
37+
color: var(--vscode-breadcrumb-focusForeground, #e0e0e0);
38+
}
39+
40+
.icon {
41+
height: 16px;
42+
width: 16px;
43+
}
44+
45+
.icon.has-icon {
46+
margin-right: 6px;
47+
}
48+
3049
.separator {
3150
user-select: none;
3251
color: var(--vscode-breadcrumb-foreground, inherit);
52+
height: 16px;
3353
opacity: 0.7;
54+
width: 16px;
3455
}
3556
3657
:host(:first-child) .separator {
3758
display: none;
3859
}
3960
40-
.icon::slotted(*) {
41-
display: inline-flex;
42-
align-items: center;
43-
font-size: 12px;
44-
line-height: 1;
61+
:host(:first-child) .root {
62+
margin-left: 16px;
63+
}
64+
65+
:host(:last-child) .root {
66+
margin-right: 8px;
4567
}
4668
`,
4769
];

src/vscode-breadcrumb-item/vscode-breadcrumb-item.ts

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
import {TemplateResult, html} from 'lit';
22
import {customElement, VscElement} from '../includes/VscElement.js';
33
import styles from './vscode-breadcrumb-item.styles.js';
4+
import {chevronRightIcon} from '../includes/icons.js';
5+
import {state} from 'lit/decorators.js';
6+
import {classMap} from 'lit/directives/class-map.js';
47

58
/**
69
* @tag vscode-breadcrumb-item
@@ -23,12 +26,30 @@ export class VscodeBreadcrumbItem extends VscElement {
2326
this.setAttribute('role', 'listitem');
2427
}
2528

29+
@state()
30+
_hasIcon = false;
31+
32+
private _handleSlotChange(ev: Event) {
33+
const slot = ev.target as HTMLSlotElement;
34+
35+
this._hasIcon = slot.assignedElements().length > 0;
36+
}
37+
2638
override render(): TemplateResult {
27-
return html`<span class="separator" aria-hidden="true" part="separator"
28-
></span
29-
>
30-
<span class="icon" part="icon"><slot name="icon"></slot></span>
31-
<span class="content" part="content"><slot></slot></span>`;
39+
return html`
40+
<div class="root">
41+
<div class="separator" aria-hidden="true" part="separator">
42+
<slot name="icon-separator">${chevronRightIcon}</slot>
43+
</div>
44+
<div
45+
class=${classMap({icon: true, 'has-icon': this._hasIcon})}
46+
part="icon"
47+
>
48+
<slot name="icon" @slotchange=${this._handleSlotChange}></slot>
49+
</div>
50+
<div class="content" part="content"><slot></slot></div>
51+
</div>
52+
`;
3253
}
3354
}
3455

src/vscode-breadcrumbs/vscode-breadcrumbs.styles.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,15 @@ const styles: CSSResultGroup = [
1111
}
1212
1313
.container {
14-
position: relative;
15-
display: flex;
14+
-ms-overflow-style: none; /* IE 10+ */
1615
align-items: center;
17-
gap: 6px;
16+
background: var(--vscode-breadcrumb-background, transparent);
17+
display: flex;
18+
height: 22px;
1819
overflow-x: auto;
1920
overflow-y: hidden;
21+
position: relative;
2022
scrollbar-width: none; /* Firefox */
21-
-ms-overflow-style: none; /* IE 10+ */
22-
background: var(--vscode-breadcrumb-background, transparent);
2323
}
2424
2525
.container::-webkit-scrollbar {

0 commit comments

Comments
 (0)