Skip to content

Commit a55479b

Browse files
committed
Refactor usage of built-in icons
1 parent 9879ea5 commit a55479b

File tree

8 files changed

+35
-52
lines changed

8 files changed

+35
-52
lines changed

src/includes/vscode-select/template-elements.ts renamed to src/includes/icons.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import {html, svg} from 'lit';
1+
import {svg} from 'lit';
22

3-
export const chevronDownIcon = html`
3+
export const chevronDownIcon = svg`
44
<span class="icon">
55
<svg
66
width="16"
@@ -18,6 +18,20 @@ export const chevronDownIcon = html`
1818
</span>
1919
`;
2020

21+
export const chevronRightIcon = svg`<svg
22+
width="16"
23+
height="16"
24+
viewBox="0 0 16 16"
25+
xmlns="http://www.w3.org/2000/svg"
26+
fill="currentColor"
27+
>
28+
<path
29+
fill-rule="evenodd"
30+
clip-rule="evenodd"
31+
d="M10.072 8.024L5.715 3.667l.618-.62L11 7.716v.618L6.333 13l-.618-.619 4.357-4.357z"
32+
/>
33+
</svg>`;
34+
2135
export const checkIcon = svg`<svg
2236
width="16"
2337
height="16"

src/includes/vscode-select/vscode-select-base.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import {VscElement} from '../VscElement.js';
1212
import {filterOptionsByPattern, highlightRanges} from './helpers.js';
1313
import type {InternalOption, Option, FilterMethod} from './types.js';
1414
import {OptionListController} from './OptionListController.js';
15-
import {checkIcon} from './template-elements.js';
15+
import {checkIcon} from '../icons.js';
1616
import '../../vscode-scrollable/vscode-scrollable.js';
1717

1818
export const VISIBLE_OPTS = 10;

src/vscode-checkbox/vscode-checkbox.ts

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {ifDefined} from 'lit/directives/if-defined.js';
33
import {property, query} from 'lit/decorators.js';
44
import {classMap} from 'lit/directives/class-map.js';
55
import {customElement} from '../includes/VscElement.js';
6+
import {checkIcon} from '../includes/icons.js';
67
import {FormButtonWidgetBase} from '../includes/form-button-widget/FormButtonWidgetBase.js';
78
import {LabelledCheckboxOrRadioMixin} from '../includes/form-button-widget/LabelledCheckboxOrRadio.js';
89
import styles from './vscode-checkbox.styles.js';
@@ -270,21 +271,7 @@ export class VscodeCheckbox
270271
'label-inner': true,
271272
});
272273

273-
const icon = html`<svg
274-
width="16"
275-
height="16"
276-
viewBox="0 0 16 16"
277-
xmlns="http://www.w3.org/2000/svg"
278-
fill="currentColor"
279-
class="check-icon"
280-
>
281-
<path
282-
fill-rule="evenodd"
283-
clip-rule="evenodd"
284-
d="M14.431 3.323l-8.47 10-.79-.036-3.35-4.77.818-.574 2.978 4.24 8.051-9.506.764.646z"
285-
/>
286-
</svg>`;
287-
const check = this.checked && !this.indeterminate ? icon : nothing;
274+
const check = this.checked && !this.indeterminate ? checkIcon : nothing;
288275
const indeterminate = this.indeterminate
289276
? html`<span class="indeterminate-icon"></span>`
290277
: nothing;

src/vscode-collapsible/vscode-collapsible.styles.ts

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,21 @@ const styles: CSSResultGroup = [
4747
}
4848
4949
.header-icon {
50+
display: block;
51+
height: 16px;
52+
margin: 0 3px;
53+
width: 16px;
54+
}
55+
56+
.header-icon svg {
5057
color: var(--vscode-icon-foreground, #cccccc);
5158
display: block;
5259
flex-shrink: 0;
53-
margin: 0 3px;
60+
height: 100%;
61+
width: 100%;
5462
}
5563
56-
.collapsible.open .header-icon {
64+
.collapsible.open .header-icon svg {
5765
transform: rotate(90deg);
5866
}
5967

src/vscode-collapsible/vscode-collapsible.ts

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import {html, nothing, TemplateResult} from 'lit';
22
import {property} from 'lit/decorators.js';
33
import {classMap} from 'lit/directives/class-map.js';
4+
import {chevronRightIcon} from '../includes/icons.js';
45
import {customElement, VscElement} from '../includes/VscElement.js';
56
import styles from './vscode-collapsible.styles.js';
67

@@ -92,21 +93,6 @@ export class VscodeCollapsible extends VscElement {
9293
};
9394
const heading = this.heading ? this.heading : this.title;
9495

95-
const icon = html`<svg
96-
width="16"
97-
height="16"
98-
viewBox="0 0 16 16"
99-
xmlns="http://www.w3.org/2000/svg"
100-
fill="currentColor"
101-
class="header-icon"
102-
>
103-
<path
104-
fill-rule="evenodd"
105-
clip-rule="evenodd"
106-
d="M10.072 8.024L5.715 3.667l.618-.62L11 7.716v.618L6.333 13l-.618-.619 4.357-4.357z"
107-
/>
108-
</svg>`;
109-
11096
const descriptionMarkup = this.description
11197
? html`<span class="description">${this.description}</span>`
11298
: nothing;
@@ -119,7 +105,7 @@ export class VscodeCollapsible extends VscElement {
119105
@click=${this._onHeaderClick}
120106
@keydown=${this._onHeaderKeyDown}
121107
>
122-
${icon}
108+
<div class="header-icon">${chevronRightIcon}</div>
123109
<h3 class="title">${heading}${descriptionMarkup}</h3>
124110
<div class="header-slots">
125111
<div class=${classMap(actionsClasses)}>

src/vscode-multi-select/vscode-multi-select.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {html, LitElement, nothing, TemplateResult} from 'lit';
22
import {property, query} from 'lit/decorators.js';
33
import {ifDefined} from 'lit/directives/if-defined.js';
44
import {customElement} from '../includes/VscElement.js';
5-
import {chevronDownIcon} from '../includes/vscode-select/template-elements.js';
5+
import {chevronDownIcon} from '../includes/icons.js';
66
import {VscodeSelectBase} from '../includes/vscode-select/vscode-select-base.js';
77
import styles from './vscode-multi-select.styles.js';
88
import {AssociatedFormControl} from '../includes/AssociatedFormControl.js';

src/vscode-single-select/vscode-single-select.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import {html, LitElement, TemplateResult} from 'lit';
22
import {property, query} from 'lit/decorators.js';
33
import {ifDefined} from 'lit/directives/if-defined.js';
44
import {customElement} from '../includes/VscElement.js';
5-
import {chevronDownIcon} from '../includes/vscode-select/template-elements.js';
5+
import {chevronDownIcon} from '../includes/icons.js';
66
import {VscodeSelectBase} from '../includes/vscode-select/vscode-select-base.js';
77
import {AssociatedFormControl} from '../includes/AssociatedFormControl.js';
88
import styles from './vscode-single-select.styles.js';

src/vscode-tree-item/vscode-tree-item.ts

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {property, queryAssignedElements, state} from 'lit/decorators.js';
44
import {classMap} from 'lit/directives/class-map.js';
55
import {customElement, VscElement} from '../includes/VscElement';
66
import {stylePropertyMap} from '../includes/style-property-map';
7+
import {chevronRightIcon} from '../includes/icons';
78
import {
89
ConfigContext,
910
configContext,
@@ -17,19 +18,6 @@ import {ExpandMode, IndentGuides} from '../vscode-tree/vscode-tree.js';
1718
const BASE_INDENT = 3;
1819
const ARROW_CONTAINER_WIDTH = 30;
1920

20-
const arrowIcon = html`<svg
21-
width="16"
22-
height="16"
23-
viewBox="0 0 16 16"
24-
xmlns="http://www.w3.org/2000/svg"
25-
>
26-
<path
27-
fill-rule="evenodd"
28-
clip-rule="evenodd"
29-
d="M10.072 8.024L5.715 3.667l.618-.62L11 7.716v.618L6.333 13l-.618-.619 4.357-4.357z"
30-
/>
31-
</svg>`;
32-
3321
function getParentItem(childItem: VscodeTreeItem) {
3422
if (!childItem.parentElement) {
3523
return null;
@@ -429,7 +417,7 @@ export class VscodeTreeItem extends VscElement {
429417
'icon-rotated': this.open,
430418
})}
431419
>
432-
${arrowIcon}
420+
${chevronRightIcon}
433421
</div>`
434422
: nothing}
435423
<div class=${classMap(iconContainerClasses)}>

0 commit comments

Comments
 (0)