Skip to content

Commit ebadb84

Browse files
author
DIVYAM TAYAL
authored
feat: Front Page: Move Search Function to Top Bar (#6007)
1 parent 871ea57 commit ebadb84

File tree

12 files changed

+121
-27
lines changed

12 files changed

+121
-27
lines changed

app/components/nav-bar.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,24 @@ export default class NavBar extends Component {
99
return !(String(this.session.currentRouteName).includes('public'));
1010
}
1111

12+
@computed('session.currentRouteName')
13+
get isNotExplorePageRoute() {
14+
return !(String(this.session.currentRouteName).includes('explore'));
15+
}
16+
17+
@action
18+
handleKeyPress() {
19+
if (event.code === 'Enter') {
20+
this.sendAction('search');
21+
document.querySelector('#mobile-bar').classList.remove('show-bar');
22+
}
23+
}
24+
25+
@action
26+
toggleSearchBar() {
27+
document.querySelector('#mobile-bar').classList.toggle('show-bar');
28+
}
29+
1230
@action
1331
logout() {
1432
this.authManager.logout();

app/components/side-bar.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import classic from 'ember-classic-decorator';
22
import $ from 'jquery';
33
import Component from '@ember/component';
4+
import { action } from '@ember/object';
45

56
@classic
67
export default class SideBar extends Component {
@@ -14,6 +15,14 @@ export default class SideBar extends Component {
1415
this.set('sidebarVisible', false);
1516
}
1617

18+
@action
19+
handleKeyPress() {
20+
if (event.code === 'Enter') {
21+
this.set('sidebarVisible', false);
22+
this.sendAction('search');
23+
}
24+
}
25+
1726
didInsertElement() {
1827
super.didInsertElement(...arguments);
1928

app/controllers/application.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { inject as service } from '@ember/service';
44
import { filterBy } from '@ember/object/computed';
55
import Controller from '@ember/controller';
66
import moment from 'moment';
7+
import { tracked } from '@glimmer/tracking';
78

89

910
@classic
@@ -17,6 +18,8 @@ export default class ApplicationController extends Controller {
1718
@service
1819
fastboot;
1920

21+
@tracked event_name = null;
22+
2023
@filterBy('model.notifications', 'isRead', false)
2124
unreadNotifications;
2225

@@ -47,4 +50,10 @@ export default class ApplicationController extends Controller {
4750
this.getCookieSeen(true);
4851
this.showCookie = false;
4952
}
53+
54+
@action
55+
search() {
56+
this.transitionToRoute('explore', { queryParams: { event_name: this.event_name } });
57+
this.event_name = null;
58+
}
5059
}

app/styles/libs/_helpers.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ $spacer-heights: 50 100 200 300 400 500 600 700 800 900;
8484
}
8585

8686
.space-between {
87-
justify-content: space-between;
87+
justify-content: space-between !important;
8888
}
8989

9090
.flex-1 {

app/styles/pages/events.scss

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,51 @@
1313
width: 100%;
1414
}
1515
}
16+
17+
.search-bar {
18+
19+
background-color: #fafafa;
20+
border-radius: .5rem;
21+
color: #808080;
22+
23+
24+
input[type='text'] {
25+
background-color: #fafafa;
26+
border: 0;
27+
outline: 0;
28+
transition: width .2s ease-in-out;
29+
width: 140px;
30+
31+
&:focus {
32+
width: 200px;
33+
}
34+
35+
}
36+
37+
i {
38+
margin-bottom: .5rem;
39+
}
40+
41+
&-mobile {
42+
position: absolute;
43+
left: 50%;
44+
transform: translateX(-52%);
45+
z-index: -1;
46+
width: 20%;
47+
transition: all .2s ease-in-out;
48+
49+
input[type='text'] {
50+
width: 100%;
51+
52+
&:focus {
53+
width: 100%;
54+
}
55+
}
56+
57+
}
58+
}
59+
60+
.show-bar {
61+
z-index: 1;
62+
width: 80%;
63+
}

app/styles/partials/utils.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@
4949
padding: .25rem !important;
5050
}
5151

52+
.p-2 {
53+
padding: .5rem !important;
54+
}
55+
5256
.pt-1 {
5357
padding-top: .25rem !important;
5458
}

app/templates/application.hbs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,12 @@
99
{{/if}}
1010
</div>
1111
{{/if}}
12-
<SideBar>
12+
<SideBar @search={{action 'search'}} @event_name={{this.event_name}}>
1313
<div class="footer-pusher">
14-
<NavBar />
14+
<NavBar @search={{action 'search'}} @event_name={{this.event_name}}/>
15+
1516
{{#if (eq this.routing.currentRouteName 'index')}}
16-
<WelcomeHeader />
17+
<WelcomeHeader @class={{'mb-4'}}/>
1718
{{/if}}
1819
<div id="main-container"
1920
class="ui fluid container main-container {{unless this.device.isInternetExplorer 'flexed-container' ''}}">

app/templates/components/nav-bar.hbs

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,16 @@
55
<h3>{{this.settings.appName}}</h3>
66
</LinkTo>
77
<div class="right menu nav-bar">
8+
{{#if (and this.isNotEventPageRoute this.isNotExplorePageRoute)}}
9+
<div class="search-bar d-flex items-center space-between m-2 p-2">
10+
<Input @class="prompt" @type="text" @key-up={{"handleKeyPress"}} @value={{this.event_name}} placeholder="Search Events" />
11+
<i class="search icon"></i>
12+
</div>
13+
{{/if}}
814
{{#if (and (not this.session.isAuthenticated) this.isNotEventPageRoute)}}
915
<LinkTo
1016
@route="pricing" class="item"
1117
@activeClass="">{{t 'Pricing'}}</LinkTo>
12-
{{/if}}
13-
{{#if this.isNotEventPageRoute}}
14-
<LinkTo
15-
@route="explore" class="item"
16-
@activeClass="">{{t 'Browse Events'}}</LinkTo>
1718
{{/if}}
1819
{{#if this.session.isAuthenticated}}
1920
<NotificationDropdown />
@@ -67,7 +68,19 @@
6768
@route="index" class="item" @activeClass="">
6869
<div class="ui header small text">{{this.settings.appName}}</div>
6970
</LinkTo>
71+
<div id="mobile-bar" class="search-bar search-bar-mobile d-flex items-center space-between m-1 p-2">
72+
<i class="search icon" style="cursor: auto;"></i>
73+
<Input @class="prompt" @type="text" @key-up={{"handleKeyPress"}} @value={{this.event_name}} placeholder="Search Events" />
74+
<div role="button" {{action "toggleSearchBar"}}>
75+
<i class="close icon" ></i>
76+
</div>
77+
</div>
7078
<div class="right menu nav-bar">
79+
{{#if (and this.isNotEventPageRoute this.isNotExplorePageRoute)}}
80+
<div role="button" class="item ui" {{action "toggleSearchBar"}}>
81+
<i class="search icon"></i>
82+
</div>
83+
{{/if}}
7184
{{#if this.session.isAuthenticated}}
7285
<NotificationDropdown
7386
@notifications={{this.notifications}} />

app/templates/components/side-bar.hbs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
<div class="ui left inverted vertical menu sidebar {{if this.sidebarVisible 'visible'}}">
2-
<LinkTo
3-
@route="explore" class="item"
4-
@activeClass="">{{t 'Browse Events'}}</LinkTo>
2+
<div class="search-bar d-flex items-center space-between m-2 p-2">
3+
<Input @class="prompt" @type="text" @key-up={{"handleKeyPress"}} @value={{this.event_name}} placeholder="Search Events" />
4+
<i class="search icon"></i>
5+
</div>
56
{{#if this.session.isAuthenticated}}
67
<div class="item">
78
<a href="{{href-to 'account.profile'}}">

app/templates/index.hbs

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,14 @@
11
<div class="ui container">
2-
<div class="ui input fluid">
3-
<Input
4-
@type="text"
5-
@key-up={{action "handleKeyPress"}}
6-
placeholder={{t "Search for events"}}
7-
@value={{this.event_name}} />
8-
<button class="ui blue button large" type="button" {{action 'search'}}>{{t 'Search'}}</button>
9-
</div>
10-
112
{{#if this.featuredEvents}}
12-
<h2 class="main-heading">{{t 'Featured Events'}}</h2>
3+
<h2 class="main-heading mb-4">{{t 'Featured Events'}}</h2>
134
<div class="ui stackable three column grid">
145
{{#each this.featuredEvents as |event|}}
156
<EventCard @event={{event}} @shareEvent={{action "shareEvent"}} />
167
{{/each}}
178
</div>
189
{{/if}}
1910
{{#if this.filteredEvents}}
20-
<h2 class="main-heading">{{t 'Upcoming Events'}}</h2>
11+
<h2 class="main-heading mb-4">{{t 'Upcoming Events'}}</h2>
2112
<div class="ui stackable three column grid">
2213
{{#each this.promotedEvents as |event|}}
2314
<EventCard @event={{event}} @shareEvent={{action "shareEvent"}} />
@@ -27,10 +18,10 @@
2718
{{/each}}
2819
</div>
2920
{{else}}
30-
<h2 class="main-heading">{{t 'No Upcoming Events Found'}}</h2>
21+
<h2 class="main-heading mb-4">{{t 'No Upcoming Events Found'}}</h2>
3122
{{/if}}
3223
{{#if this.model.callForSpeakersEvents}}
33-
<h2 class="main-heading">{{t 'Call for speakers'}}</h2>
24+
<h2 class="main-heading mb-4">{{t 'Call for speakers'}}</h2>
3425
<div class="ui stackable three column grid">
3526
{{#each this.model.callForSpeakersEvents as |event|}}
3627
<EventCard @event={{event}} @isCFS={{true}} @shareEvent={{action "shareEvent"}} />

0 commit comments

Comments
 (0)