@@ -3,14 +3,13 @@ import * as Model from 'models';
3
3
import * as styles from 'styles' ;
4
4
import styled from 'styled-components' ;
5
5
import { wait } from 'utilities/utilities' ;
6
- import { memoizeLast } from 'utilities/memoize-last' ;
7
6
import { searchList } from 'utilities/search-list' ;
8
7
9
8
import { View } from 'components/view' ;
10
9
import { Text , TextProps } from 'components/text' ;
11
10
import { GiantAutosuggest } from 'components/giant-autosuggest' ;
12
11
import { PrimaryButton } from 'components/button' ;
13
- import { Fa as _Fa } from 'components/fa' ;
12
+ import { Fa } from 'components/fa' ;
14
13
import { Paragraph } from 'components/paragraph' ;
15
14
import { createInfoModal } from 'components/info-modal' ;
16
15
@@ -27,7 +26,8 @@ const Slide = styled(View)`
27
26
` ;
28
27
const Box = styled ( View ) `
29
28
margin: auto;
30
- max-width: 64rem;
29
+ width: 64rem;
30
+ max-width: 100vw;
31
31
align-items: flex-start;
32
32
` ;
33
33
const Title = styled ( Text ) `
@@ -46,7 +46,7 @@ const Description = styled(Text)`
46
46
font-size: ${ styles . space ( 2 ) } ;
47
47
margin-bottom: ${ styles . space ( 0 ) } ;
48
48
` ;
49
- const Fa = styled ( _Fa ) `
49
+ const Arrow = styled ( Fa ) `
50
50
margin-left: ${ styles . space ( 0 ) } ;
51
51
` ;
52
52
const YearInfo = styled ( Text ) `
@@ -92,6 +92,27 @@ const NotPart = styled(Text)`
92
92
color: ${ styles . active ( styles . beeKeeper ) } ;
93
93
}
94
94
` ;
95
+ const SelectedDegree = styled ( View ) `
96
+ flex-direction: row;
97
+ align-items: center;
98
+ margin-bottom: ${ styles . space ( 0 ) } ;
99
+ ` ;
100
+ const SelectedDegreeName = styled ( Text ) `
101
+ font-size: ${ styles . space ( 3 ) } ;
102
+ font-weight: bold;
103
+ color: ${ styles . turbo } ;
104
+ flex: 1 1 auto;
105
+ ` ;
106
+ const Times = styled ( Fa ) `
107
+ margin-left: ${ styles . space ( 2 ) } ;
108
+ color: ${ styles . white } ;
109
+ &:hover {
110
+ color: ${ styles . hover ( styles . white ) } ;
111
+ }
112
+ &:active {
113
+ color: ${ styles . active ( styles . white ) } ;
114
+ }
115
+ ` ;
95
116
96
117
interface WelcomeProps {
97
118
degrees : Model . MasteredDegree . Model [ ] ;
@@ -119,11 +140,17 @@ export class Welcome extends React.PureComponent<WelcomeProps, WelcomeState> {
119
140
notPartInfoModal = createInfoModal ( ) ;
120
141
121
142
get degrees ( ) {
122
- return this . _getOrCalculateDegrees ( this . props . degrees , this . state . search ) ;
143
+ return searchList ( this . props . degrees , getDisplayText , this . state . search ) ;
144
+ }
145
+
146
+ get selectedDegreeName ( ) {
147
+ const { selectedDegreeId } = this . state ;
148
+ const { degrees } = this . props ;
149
+ if ( ! selectedDegreeId ) return undefined ;
150
+ const selectedDegree = degrees . find ( degree => degree . id === selectedDegreeId ) ;
151
+ if ( ! selectedDegree ) return undefined ;
152
+ return selectedDegree . name ;
123
153
}
124
- _getOrCalculateDegrees = memoizeLast ( ( degrees : Model . MasteredDegree . Model [ ] , search : string ) => {
125
- return searchList ( degrees , getDisplayText , search ) ;
126
- } ) ;
127
154
128
155
componentDidMount ( ) {
129
156
const buttonElement = this . buttonRef . current ;
@@ -151,8 +178,9 @@ export class Welcome extends React.PureComponent<WelcomeProps, WelcomeState> {
151
178
handleSelectDegree = ( selectedDegreeId : string ) => {
152
179
this . setState ( { selectedDegreeId } ) ;
153
180
} ;
154
- handleFocus = ( e : React . FocusEvent < HTMLInputElement > ) => { } ;
155
- handleBlur = ( e : React . FocusEvent < HTMLInputElement > ) => { } ;
181
+ handleUnselectDegree = ( ) => {
182
+ this . setState ( { selectedDegreeId : undefined } ) ;
183
+ } ;
156
184
157
185
renderSuggestion = ( degree : Model . MasteredDegree . Model , selected : boolean ) => {
158
186
return < Suggestion selected = { selected } > { degree . name } </ Suggestion > ;
@@ -175,7 +203,7 @@ export class Welcome extends React.PureComponent<WelcomeProps, WelcomeState> {
175
203
for your future.
176
204
</ Description >
177
205
< PrimaryButton innerRef = { this . buttonRef } onClick = { this . handleGetStarted } >
178
- Get Started < Fa icon = "chevronRight" />
206
+ Get Started < Arrow icon = "chevronRight" />
179
207
</ PrimaryButton >
180
208
</ Box >
181
209
</ Slide >
@@ -188,20 +216,26 @@ export class Welcome extends React.PureComponent<WelcomeProps, WelcomeState> {
188
216
or ask your < Mail href = "mailto:umd-cecs-undergrad@umich.edu" > CECS advisor</ Mail > if
189
217
you need additional assistance.
190
218
</ YearInfo >
191
- < GiantAutosuggest
192
- focus = { gotStarted }
193
- items = { this . degrees }
194
- getDisplayText = { getDisplayText }
195
- getKey = { getKey }
196
- onSelectSuggestion = { this . handleSelectDegree }
197
- renderSuggestion = { this . renderSuggestion }
198
- onSearch = { this . handleSearch }
199
- onFocus = { this . handleFocus }
200
- onBlur = { this . handleBlur }
201
- onClickDontSee = { this . infoModal . open }
202
- />
219
+ { this . selectedDegreeName ? (
220
+ < SelectedDegree >
221
+ < SelectedDegreeName > { this . selectedDegreeName } </ SelectedDegreeName >
222
+ < Times icon = "times" size = "4x" onClick = { this . handleUnselectDegree } />
223
+ </ SelectedDegree >
224
+ ) : (
225
+ < GiantAutosuggest
226
+ focus = { gotStarted }
227
+ items = { this . degrees }
228
+ getDisplayText = { getDisplayText }
229
+ getKey = { getKey }
230
+ onSelectSuggestion = { this . handleSelectDegree }
231
+ renderSuggestion = { this . renderSuggestion }
232
+ onSearch = { this . handleSearch }
233
+ onClickDontSee = { this . infoModal . open }
234
+ />
235
+ ) }
236
+
203
237
< PrimaryButton >
204
- Let's begin < Fa icon = "chevronRight" />
238
+ Let's begin < Arrow icon = "chevronRight" />
205
239
</ PrimaryButton >
206
240
< NotPart onClick = { this . notPartInfoModal . open } >
207
241
Not part of the College of Engineering and Computer Science?
0 commit comments