Skip to content

Commit 95fdc88

Browse files
Updated apply UX. Resolves #310. (#1170)
1 parent 918db70 commit 95fdc88

18 files changed

+171
-83
lines changed

spa/src/app/files/_ngrx/file.effects.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ describe("File Effects", () => {
140140
// Update selected tab to be samples
141141
store.setState(DEFAULT_SAMPLES_STATE);
142142

143-
// Dispatch the fetch file fileFacets action
143+
// Dispatch the fetch file facets action
144144
actions = hot("--a-", {
145145
a: new FetchFileFacetsRequestAction(true)
146146
});
@@ -163,7 +163,7 @@ describe("File Effects", () => {
163163
// Update search state to include a selected project search term
164164
store.setState(SAMPLES_STATE_WITH_SEARCH_TERM);
165165

166-
// Dispatch the fetch file fileFacets action
166+
// Dispatch the fetch file facets action
167167
actions = hot("--a-", {
168168
a: new FetchFileFacetsRequestAction(true)
169169
});
@@ -186,7 +186,7 @@ describe("File Effects", () => {
186186
// Update selected tab to be files
187187
store.setState(DEFAULT_FILES_STATE);
188188

189-
// Dispatch the fetch file fileFacets action
189+
// Dispatch the fetch file facets action
190190
actions = hot("--a-", {
191191
a: new FetchFileFacetsRequestAction(true)
192192
});

spa/src/app/files/_ngrx/file.effects.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Human Cell Atlas
33
* https://www.humancellatlas.org/
44
*
5-
* File-related effects, including fetching file summary (eg total counts), file fileFacets, terms etc.
5+
* File-related effects, including fetching file summary (eg total counts), file facets, terms etc.
66
*/
77

88
// Core dependencies

spa/src/app/files/_ngrx/search/select-file-facet-term.action.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* https://www.humancellatlas.org/
44
*
55
* Action that is triggered when file facet term is selected. Select can be dispatched from facet card itself or from
6-
* corresponding term menu displayed over facet card (this includes search fileFacets and their menus).
6+
* corresponding term menu displayed over facet card (this includes search facets and their menus).
77
*/
88

99
// Core dependencies
Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
/**
2+
* Human Cell Atlas
3+
* https://www.humancellatlas.org/
4+
*
25
* Pipe for formatting age in seconds to age unit.
36
*/
47

@@ -7,6 +10,7 @@ import { Pipe, PipeTransform } from "@angular/core";
710

811
// App dependencies
912
import { AgeUnit } from "../age-unit.model";
13+
import { TimeUnitInSeconds } from "../time-unit-in-seconds.model";
1014

1115
@Pipe({
1216
name: "ageInAgeUnit"
@@ -19,12 +23,6 @@ export class AgeInAgeUnit implements PipeTransform {
1923
return;
2024
}
2125

22-
const timeUnitInSeconds = {
23-
"week": 604800,
24-
"month": 2628000,
25-
"year": 31536000
26-
};
27-
28-
return age / timeUnitInSeconds[ageUnit];
26+
return age / TimeUnitInSeconds[ageUnit.toUpperCase()];
2927
}
3028
}

spa/src/app/files/facet/facet-age-range/facet-age-range-form/age-unit-in-age-unit.pipe.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
/**
2+
* Human Cell Atlas
3+
* https://www.humancellatlas.org/
4+
*
25
* Pipe for formatting age in one unit to another.
36
*/
47

@@ -7,6 +10,7 @@ import { Pipe, PipeTransform } from "@angular/core";
710

811
// App dependencies
912
import { AgeUnit } from "../age-unit.model";
13+
import { TimeUnitInSeconds } from "../time-unit-in-seconds.model";
1014

1115
@Pipe({
1216
name: "ageUnitInAgeUnit"
@@ -19,13 +23,8 @@ export class AgeUnitInAgeUnit implements PipeTransform {
1923
return;
2024
}
2125

22-
const timeUnitInSeconds = {
23-
"week": 604800,
24-
"month": 2628000,
25-
"year": 31536000
26-
};
27-
28-
const conversion = age * timeUnitInSeconds[prevAgeUnit] / timeUnitInSeconds[nextAgeUnit];
26+
const conversion =
27+
age * TimeUnitInSeconds[prevAgeUnit.toUpperCase()] / TimeUnitInSeconds[nextAgeUnit.toUpperCase()];
2928

3029
return Math.round(conversion);
3130
}
Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
/**
2+
* Human Cell Atlas
3+
* https://www.humancellatlas.org/
4+
*
25
* Pipe for formatting age unit to seconds.
36
*/
47

@@ -7,6 +10,7 @@ import { Pipe, PipeTransform } from "@angular/core";
710

811
// App dependencies
912
import { AgeUnit } from "../age-unit.model";
13+
import { TimeUnitInSeconds } from "../time-unit-in-seconds.model";
1014

1115
@Pipe({
1216
name: "ageUnitInSeconds"
@@ -15,12 +19,6 @@ export class AgeUnitInSeconds implements PipeTransform {
1519

1620
transform(age: number, ageUnit: AgeUnit): number {
1721

18-
const timeUnitInSeconds = {
19-
"week": 604800,
20-
"month": 2628000,
21-
"year": 31536000
22-
};
23-
24-
return age * timeUnitInSeconds[ageUnit];
22+
return age * TimeUnitInSeconds[ageUnit.toUpperCase()];
2523
}
2624
}

spa/src/app/files/facet/facet-age-range/facet-age-range-form/facet-age-range-form.component.html

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,13 @@
1717
<input type="number" placeholder="e.g. 2" formControlName="ageMax">
1818
</label>
1919
<div class="actions">
20-
<button class="apply" type="submit" [disabled]="!ageRangeGroup.valid">Apply</button>
21-
<button class="clear" type="button" (click)="onClearAgeRange(ageRangeGroup, ageRange)">Clear</button>
20+
<button class="apply"
21+
type="submit"
22+
[ngClass]="{'pristine': pristine}"
23+
[disabled]="!isSubmittable(ageRangeGroup)">Apply</button>
24+
<button class="clear"
25+
type="button"
26+
[disabled]="!isClearable(ageRange)"
27+
(click)="onClearAgeRange(ageRangeGroup, ageRange)">Clear</button>
2228
</div>
2329
</form>

spa/src/app/files/facet/facet-age-range/facet-age-range-form/facet-age-range-form.component.scss

Lines changed: 36 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -103,45 +103,67 @@ form {
103103

104104
/* Action - button */
105105
button {
106-
border: 1px solid $hca-gray-light;
106+
border: 1px solid $hca-gray-lightest;
107107
border-radius: 3px;
108108
font-family: "Montserrat", sans-serif;
109109
font-size: 12px;
110-
font-weight: 600;
111110
height: 28px;
112111
letter-spacing: 0.2px;
113112
line-height: 28px;
113+
overflow: hidden;
114114
padding: 0 12px;
115115
text-transform: capitalize;
116-
117-
/* Apply - valid */
116+
transition: background-color 400ms cubic-bezier(0.25, 0.8, 0.25, 1), border-color 400ms cubic-bezier(0.25, 0.8, 0.25, 1);
117+
118+
/* Apply - default */
119+
&.apply {
120+
font-weight: 600;
121+
min-width: 63px; // Maintain width during toggle between "Apply" and check mark
122+
}
123+
124+
/* Apply - valid or invalid/not submittable but maintain enabled UI during animation */
118125
&.apply:not([disabled]) {
119126
border-color: rgba(28, 124, 199, 0.12);
120127
background-color: rgba(28, 124, 199, 0.06);
121128
color: $hca-primary;
122129
}
123130

124-
/* Apply - invalid */
125-
&.apply[disabled] {
126-
background-color: rgba(0, 0, 0, 0.03);
127-
color: $hca-gray-medium;
128-
}
129-
130131
/* Apply - valid - hover */
131132
&.apply:not([disabled]):hover {
132133
background-color: rgba(28, 124, 199, 0.12);
133134
}
134135

135-
/* Clear */
136+
/* Apply - invalid, not submittable */
137+
&.apply[disabled] {
138+
background-color: rgba(0, 0, 0, 0.03);
139+
color: $hca-gray-medium;
140+
}
141+
142+
/** Apply - pristine but invalid, not submittable */
143+
&.apply[disabled]:not(.pristine) {
144+
font-size: 0;
145+
&:before {
146+
content: "\e5ca";
147+
font-family: "Material Icons";
148+
font-size: 16px;
149+
}
150+
}
151+
152+
/* Clear - default */
136153
&.clear {
137154
border-color: transparent;
138155
color: $hca-primary;
139-
font-weight: 400;
156+
padding: 0 8px;
140157
margin: 0 0 0 8px;
141-
transition: all 400ms cubic-bezier(0.25, 0.8, 0.25, 1);
142158
}
143159

144-
&.clear:hover {
160+
/* Clear = disabled */
161+
&.clear[disabled] {
162+
color: $hca-gray-light;
163+
}
164+
165+
/* Clear - hover */
166+
&.clear:not([disabled]):hover {
145167
border-color: rgba(0, 0, 0, 0.03);
146168
background-color: rgba(0, 0, 0, 0.03);
147169
}

0 commit comments

Comments
 (0)