Skip to content

Commit e97df0c

Browse files
committed
Redo of focus style handling. Redo of animation state handling.
1 parent 8040396 commit e97df0c

4 files changed

Lines changed: 35 additions & 49 deletions

File tree

angular.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@
7272
"budgets": [
7373
{
7474
"type": "initial",
75-
"maximumWarning": "500kb",
76-
"maximumError": "1mb"
75+
"maximumWarning": "1.5mb",
76+
"maximumError": "2mb"
7777
},
7878
{
7979
"type": "anyComponentStyle",

projects/tubular-ng-widgets/src/lib/digit-sequence-editor/digit-sequence-editor.directive.html

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,12 @@
1717
</span>
1818
</div>
1919
<div #wrapper class="tbw-dse-wrapper"
20+
[class.tbw-normal-background]="!disabled && !viewOnly"
21+
[class.tbw-disabled-background]="disabled"
22+
[class.tbw-view-only-background]="viewOnly"
2023
[class.tbw-dse-no-focus]="disabled"
21-
[class.tbw-dse-explicit-focus-outline]="addFocusOutline && hasFocus && !floating"
22-
[class.tbw-dse-clear-focus-outline]="addFocusOutline && !hasFocus"
24+
[class.tbw-dse-explicit-focus-outline]="hasFocus && !floating"
25+
[class.tbw-dse-clear-focus-outline]="!hasFocus"
2326
[class.tbw-dse-dse-rtl]="rtl"
2427
[class.tbw-dse-floating]="floating"
2528
[tabindex]="inputOff || hasHiddenInput ? '-1' : tabindex"
@@ -29,11 +32,11 @@
2932
(keydown)="onKeyDown($event)" (keyup)="onKeyUp()" (keypress)="onKeyPress($event)"
3033
(focus)="onFocus(true, $event)" (blur)="onFocus(false, $event)"
3134
[ngClass]="getStaticBackgroundColor()"
32-
[@displayState]="displayState"
3335
(mouseleave)="onMouseLeave()"
3436
(mouseup)="onMouseUp($event)"
3537
(touchmove)="onTouchMove($event)"
3638
(touchend)="onTouchEnd($event)">
39+
<div class="tbw-dse-state-indicator" [@displayState]="displayState">&nbsp;</div>
3740
<div *ngFor="let item of displayItems"
3841
class="tbw-dse-digit dse-item-{{item.index}}"
3942
[ngClass]="(getClassForItem(item) || '') + ' ' + (getColorForItem(item) || '')"

projects/tubular-ng-widgets/src/lib/digit-sequence-editor/digit-sequence-editor.directive.ts

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,6 @@ const NO_SELECTION = -1;
6464
const SPIN_UP = -2;
6565
const SPIN_DOWN = -3;
6666

67-
const addFocusOutline = isEdge() || isIOS();
6867
const alternateClipboard = navigator.clipboard == null || isAndroid() || isChromeOS() || isIOS() || isSamsung();
6968
const checkForRepeatedKeyTimestamps = isIOS();
7069
const disableContentEditable = isEdge();
@@ -147,12 +146,10 @@ class DynamicColor {
147146

148147
export const BACKGROUND_ANIMATIONS = trigger('displayState', [
149148
state('error', style({ backgroundColor: new DynamicColor(ERROR_BACKGROUND, '#F67') as unknown as string })),
150-
state('normal', style({ backgroundColor: new DynamicColor(NORMAL_BACKGROUND, 'white') as unknown as string })),
151-
state('refresh', style({ backgroundColor: 'gray' })),
149+
state('normal', style({ backgroundColor: 'transparent' })),
150+
state('refresh', style({ backgroundColor: 'rgba(0, 0, 0, 0.01)' })),
152151
state('confirm', style({ backgroundColor: new DynamicColor(CONFIRM_BACKGROUND, '#6C6') as unknown as string })),
153152
state('warning', style({ backgroundColor: new DynamicColor(WARNING_BACKGROUND, '#FC6') as unknown as string })),
154-
state('view-only', style({ backgroundColor: new DynamicColor(VIEW_ONLY_BACKGROUND, 'black') as unknown as string })),
155-
state('disabled', style({ backgroundColor: new DynamicColor(DISABLED_BACKGROUND, '#CCC') as unknown as string })),
156153
transition('normal => error', animate(FLASH_DURATION)),
157154
transition('error => normal', animate(FLASH_DURATION)),
158155
transition('normal => confirm', animate(FLASH_DURATION)),
@@ -181,7 +178,6 @@ export abstract class DigitSequenceEditorDirective<T> implements
181178
AfterViewInit, ControlValueAccessor, OnInit, OnDestroy, Validator {
182179
// Template accessibility
183180

184-
addFocusOutline = addFocusOutline;
185181
disableContentEditable = disableContentEditable;
186182
htmlEscape = htmlEscape;
187183
SPIN_DOWN = SPIN_DOWN;
@@ -490,10 +486,7 @@ export abstract class DigitSequenceEditorDirective<T> implements
490486
if (isString(newValue))
491487
newValue = toBoolean(newValue, false, true);
492488

493-
if (this._floating !== newValue) {
494-
this._floating = newValue;
495-
this.adjustState();
496-
}
489+
this._floating = newValue;
497490
}
498491

499492
get tabindex(): string { return this._tabindex; }
@@ -1192,11 +1185,6 @@ export abstract class DigitSequenceEditorDirective<T> implements
11921185
this.lostFocus();
11931186
}
11941187
}
1195-
1196-
if (this.hiddenInput && !this.disabled)
1197-
this.wrapper.style.outline = getCssValue(this.hiddenInput, 'outline');
1198-
else if (addFocusOutline)
1199-
this.wrapper.style.outline = (newFocus && !this.disabled ? 'rgb(59, 153, 252) solid 1px' : 'black none 0px');
12001188
}
12011189

12021190
protected gainedFocus(): void {}
@@ -1537,11 +1525,8 @@ export abstract class DigitSequenceEditorDirective<T> implements
15371525

15381526
if (this.darkMode !== lastMode) {
15391527
DynamicColor.update(ERROR_BACKGROUND, this.darkMode);
1540-
DynamicColor.update(NORMAL_BACKGROUND, this.darkMode);
15411528
DynamicColor.update(CONFIRM_BACKGROUND, this.darkMode);
15421529
DynamicColor.update(WARNING_BACKGROUND, this.darkMode);
1543-
DynamicColor.update(VIEW_ONLY_BACKGROUND, this.darkMode);
1544-
DynamicColor.update(DISABLED_BACKGROUND, this.darkMode);
15451530

15461531
const currentState = this.displayState;
15471532

@@ -1553,8 +1538,6 @@ export abstract class DigitSequenceEditorDirective<T> implements
15531538
}
15541539

15551540
protected adjustState(): void {
1556-
this.displayState = (this._viewOnly ? 'view-only' : (this._disabled ? 'disabled' : 'normal'));
1557-
15581541
if (this.hiddenInput) {
15591542
const disabled = (this._floating || this._disabled || this._viewOnly);
15601543
this.hiddenInput.setAttribute('tabindex', this.disabled ? '-1' : this.tabindex);

projects/tubular-ng-widgets/src/styles.scss

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,11 @@
2929
// DigitSequenceEditor
3030

3131
.tbw-dse-palette {
32+
border-radius: max(4px, 0.2em);
3233
display: inline-flex;
3334
flex-direction: column;
35+
margin: 2px;
36+
overflow: visible;
3437
touch-action: manipulation;
3538

3639
&.tbw-dse-floating {
@@ -49,7 +52,6 @@
4952
display: flex;
5053
height: 0.9em;
5154
justify-content: flex-end;
52-
margin: 2px 2px 0 2px;
5355
overflow: hidden;
5456
padding-right: 0.25em;
5557
position: relative;
@@ -83,7 +85,6 @@
8385
font-size: max(14px, 0.6em);
8486
height: 1.8em;
8587
justify-content: center;
86-
margin: 0 2px 2px 2px;
8788
overflow: hidden;
8889
padding: 0 0.25em;
8990
position: relative;
@@ -149,28 +150,29 @@
149150

150151
.tbw-dse-wrapper {
151152
align-items: baseline;
152-
background-color: white;
153-
border: #A6A6A6 solid max(1px, 0.0836em) !important;
153+
border: #A6A6A6 solid max(1px, 0.0836em);
154154
border-radius: max(4px, 0.2em);
155155
caret-color: transparent;
156156
cursor: default;
157157
direction: ltr;
158158
display: inline-flex;
159-
margin: 2px;
160159
overflow: hidden;
161160
padding: max(1px, 0.0836em) 0.2em;
162161
position: relative;
163162
touch-action: manipulation;
164163
user-select: none;
165164

165+
&.tbw-dse-explicit-focus-outline {
166+
box-shadow: 0 0 2px 2px #3B99FC;
167+
outline: none;
168+
}
169+
166170
&.tbw-dse-floating {
167171
border-bottom: 0 !important;
168172
border-radius: 0 !important;
169173
border-top: 0 !important;
170174
box-shadow: none !important;
171175
outline: none !important;
172-
margin-bottom: 0;
173-
margin-top: 0;
174176

175177
&:focus {
176178
border-color: #A6A6A6 !important;
@@ -181,19 +183,22 @@
181183
}
182184
}
183185

184-
.tbw-dse-focus-indicator {
186+
.tbw-dse-state-indicator, .tbw-dse-focus-indicator{
185187
bottom: 0;
186-
box-sizing: border-box;
187-
border: 2px solid transparent;
188188
background-color: transparent;
189189
left: 0;
190190
pointer-events: none;
191191
position: absolute;
192192
right: 0;
193193
top: 0;
194+
}
195+
196+
.tbw-dse-focus-indicator {
197+
border: 2px solid transparent;
198+
box-sizing: border-box;
194199

195200
&.tbw-dse-show-focus {
196-
border: 2px solid #007AFF;
201+
border-color: #007AFF;
197202
}
198203
}
199204

@@ -266,11 +271,8 @@
266271
font-size: 0.8em;
267272
}
268273

269-
.tbw-dse-explicit-focus-outline {
270-
outline: #3B99FC solid 1px;
271-
}
272-
273274
.tbw-dse-clear-focus-outline {
275+
box-shadow: none;
274276
outline: 0;
275277
}
276278

@@ -290,10 +292,6 @@
290292
}
291293

292294
.tbw-dark-mode {
293-
.tbw-dse-wrapper {
294-
background-color: #333;
295-
}
296-
297295
.tbw-dse-palette.tbw-dse-floating {
298296
filter: drop-shadow(4px 4px 2px black);
299297
}
@@ -311,10 +309,16 @@
311309
background-color: #444;
312310
}
313311

314-
.tbw-dse-wrapper {
312+
.tbw-dse-wrapper:not(.tbw-dse-explicit-focus-outline) {
315313
border-color: #A6A6A6;
316314
}
317315

316+
.tbw-dse-wrapper.tbw-dse-explicit-focus-outline {
317+
border-color: #7E97B2;
318+
box-shadow: 0 0 2px 2px #2F7ACA;
319+
outline: none;
320+
}
321+
318322
.tbw-dse-divider {
319323
background-color: #A6A6A6;
320324
}
@@ -323,10 +327,6 @@
323327
color: #C00 !important;
324328
}
325329

326-
.tbw-dse-explicit-focus-outline {
327-
outline-color: #3B99FC;
328-
}
329-
330330
.tbw-disabled-arrow-color { color: #060; stroke: #060; }
331331
.tbw-disabled-background { background-color: #444; fill: #444; }
332332
.tbw-disabled-text { color: #777; stroke: #777; }

0 commit comments

Comments
 (0)