Skip to content

Commit fda0fe4

Browse files
committed
remove all references to label module
1 parent 4a729fd commit fda0fe4

7 files changed

Lines changed: 84 additions & 200 deletions

File tree

dist/acc-components.js

Lines changed: 46 additions & 106 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/abstract-select.ts

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import { NodeObserver, NodeObservation } from './types';
1818
import { OptgroupElement } from './optgroup';
1919
import { isElement } from '../utils';
2020
import { property } from "./decorators";
21-
import {getLabelTemplate} from "./label";
2221

2322
//@ts-ignore
2423
const { FlattenedNodesObserver } = require('@polymer/polymer/lib/utils/flattened-nodes-observer.js');
@@ -49,9 +48,6 @@ export class AbstractSelectLitElement extends AbstractUIElement {
4948
@property({ type: Boolean })
5049
public hideLabel: boolean = false;
5150

52-
@property({ type: String })
53-
public id:string;
54-
5551
protected _nodeChildSelector = 'acc-item';
5652

5753
/**
@@ -68,17 +64,9 @@ export class AbstractSelectLitElement extends AbstractUIElement {
6864
* this map is flattened to include all items nested in a group
6965
*/
7066
protected _nodes:SelectableElement[] = [];
71-
protected labelHtml:any;
7267

7368
private __nodesObserver: NodeObserver;
7469

75-
_propertiesChanged(props:any, changed:any, prev:any){
76-
super._propertiesChanged(props, changed, prev);
77-
if (changed && changed.label) {
78-
this.labelHtml = getLabelTemplate(changed.label, this.id);
79-
}
80-
}
81-
8270
connectedCallback(){
8371
super.connectedCallback();
8472
this.__nodesObserver = new FlattenedNodesObserver(this, this._handleNodesObserverUpdate);

src/components/abstract-ui.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import autobind from 'autobind-decorator';
22
import { setBooleanAttribute } from './../utils';
33
import { KeyboardShortcutObserver } from './../keyboard-shortcut-observer';
4-
import { html, LitElement } from '@polymer/lit-element';
4+
import { LitElement } from '@polymer/lit-element';
55
import { property } from './decorators';
66

77

@@ -11,7 +11,6 @@ export interface UIProperties {
1111
shortcut: string;
1212
}
1313

14-
1514
export class AbstractUIElement extends LitElement {
1615
/**
1716
* the label for the element, useful for display as well as screen readers

src/components/input-mode-select.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,10 @@
1212
// See the License for the specific language governing permissions and
1313
// limitations under the License.
1414

15-
import { backgroundColor, bodyFontFamily, labelColor } from './styles';
16-
import { isAbstractInputElement, AbstractInputElement } from './abstract-input';
15+
import { backgroundColor, bodyFontFamily, labelColor, labelStyleChunk } from './styles';
1716
import { html } from '@polymer/lit-element';
1817
import { SelectableElement, AbstractSelectLitElement } from './abstract-select';
19-
import { isElement } from '../utils';
2018
import { property } from './decorators';
21-
import {getLabelTemplate} from "./label";
2219

2320

2421
interface InputModeElement extends SelectableElement {
@@ -146,6 +143,8 @@ export class InputModeSelectElement extends AbstractSelectLitElement {
146143

147144
return html`
148145
<style>
146+
${labelStyleChunk()}
147+
149148
:host select, button {
150149
font-size: 18px;
151150
}
@@ -214,7 +213,7 @@ export class InputModeSelectElement extends AbstractSelectLitElement {
214213
}
215214
216215
</style>
217-
${getLabelTemplate('Tracking', 'select')}
216+
<label for="select">Tracking</label>
218217
<div class="select-style">
219218
<select class="accessibility-selector" on-input="${onSelectInput}" id="select">
220219
${this.items.map((node,i)=>{

src/components/label.ts

Lines changed: 0 additions & 38 deletions
This file was deleted.

src/components/range.ts

Lines changed: 18 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { labelStyleChunk } from './styles';
12
// Copyright 2018 Google LLC
23
//
34
// Licensed under the Apache License, Version 2.0 (the "License");
@@ -18,7 +19,6 @@ import { accentColor, labelColor } from './styles';
1819
import { AbstractUIElement } from './abstract-ui';
1920
import { html } from '@polymer/lit-element';
2021
import { property } from './decorators';
21-
import { getLabelTemplate } from "./label";
2222

2323
const normalizeValue = (min:number, max:number, value:number) => {
2424
// console.log('calling normalize values for', name);
@@ -62,13 +62,6 @@ class RangeElement extends AbstractUIElement {
6262
@property({ type: Boolean })
6363
public inlineLabel:boolean = false;
6464

65-
protected labelHtml:any;
66-
67-
68-
constructor(){
69-
super();
70-
this.labelHtml = html`0`;
71-
}
7265

7366
changeGradient(e:any) {
7467
this.value = e.currentTarget.value;
@@ -100,38 +93,30 @@ class RangeElement extends AbstractUIElement {
10093
super._handleShortcut();
10194
}
10295

103-
_propertiesChanged(props:any, changed:any, prev:any){
104-
if(!changed){
105-
return;
106-
}
107-
if (changed && changed.label) {
108-
this.labelHtml = getLabelTemplate(changed.label, this.id);
109-
this.requestRender();
110-
}
111-
super._propertiesChanged(props, changed, prev);
112-
}
113-
114-
_render({ name, min, max, step, value }: RangeProperties){
96+
_render({ label, name, min, max, step, value }: RangeProperties){
11597

11698
const [minf, maxf, valuef] = [min, max, value].map(parseFloat);
11799

118100
const inputHtml = html`
119-
<input class="range-slider__range"
120-
on-input=${(e:any) => this.changeGradient(e)}
121-
id="${this.id}"
122-
name="${name}"
123-
type="range"
124-
min="${min}"
125-
max="${max}"
126-
step="${step}"
127-
disabled?="${this.disabled}"
128-
aria-label="${name}"
129-
value="${value}"></input>
130-
`
101+
<input
102+
id="range-slider"
103+
class="range-slider__range"
104+
on-input=${(e:any) => this.changeGradient(e)}
105+
name="${name}"
106+
type="range"
107+
min="${min}"
108+
max="${max}"
109+
step="${step}"
110+
disabled?="${this.disabled}"
111+
aria-label="${name}"
112+
value="${value}"></input>
113+
`;
131114

132115
return html`
133116
<style>
134117
118+
${labelStyleChunk()}
119+
135120
:host([inline]), [inline] {
136121
display: inline-block;
137122
}
@@ -154,9 +139,6 @@ class RangeElement extends AbstractUIElement {
154139
align-self: flex-start;
155140
}
156141
157-
158-
159-
160142
input[type="range"]{
161143
-webkit-appearance: none;
162144
-moz-apperance: none;
@@ -234,7 +216,7 @@ class RangeElement extends AbstractUIElement {
234216
</style>
235217
236218
<div class="range-slider">
237-
${this.labelHtml}
219+
<label for="range-slider">${label}</label>
238220
${this.inlineLabel ? html`<span id="input-container">${inputHtml}</span>` : inputHtml}
239221
</div>
240222
`;

src/components/styles.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,18 @@ export const iconSize = applyVariable('iconSize');
7575

7676
export const fillColor = applyVariable('fillColor');
7777

78-
export const outlineBorderColor = applyVariable('outlineBorderColor')
78+
export const outlineBorderColor = applyVariable('outlineBorderColor')
79+
80+
81+
82+
export const labelStyleChunk = (selector: string= 'label') => `
83+
${selector} {
84+
font-family: ${bodyFontFamily};
85+
font-size: 18px;
86+
padding: 0px 0px 20px 0px;
87+
font-weight: 700;
88+
text-transform: capitalize;
89+
display: block;
90+
cursor: pointer;
91+
color: ${labelColor};
92+
}`;

0 commit comments

Comments
 (0)