Skip to content

Commit

Permalink
Update frontend UI for changing place on place page (#3852)
Browse files Browse the repository at this point in the history
Update the styling of the search bar used to change places on the place
explorer to match figma mocks. This improves the current UI by
preventing two search bars from showing up next to each other on page
load.

Screenshots:
![Screenshot 2023-12-21 at 12 56
06 PM](https://github.com/datacommonsorg/website/assets/4034366/ec687f56-0c99-4365-8258-2fe9e50e8855)
![Screenshot 2023-12-21 at 12 55
56 PM](https://github.com/datacommonsorg/website/assets/4034366/0a255caf-6449-490c-b8c1-d86e71ef2605)
![Screenshot 2023-12-21 at 12 55
33 PM](https://github.com/datacommonsorg/website/assets/4034366/4ed36fab-f1fa-439d-ae92-f0dfd5593ed0)

![Screenshot 2023-12-21 at 12 44
33 PM](https://github.com/datacommonsorg/website/assets/4034366/85139d3f-18e7-4b3c-ac92-0568d5146219)
![Screenshot 2023-12-21 at 12 44
44 PM](https://github.com/datacommonsorg/website/assets/4034366/71ed4cbf-268d-4622-8b1b-b5dd3ed3b5d6)
![Screenshot 2023-12-21 at 12 44
59 PM](https://github.com/datacommonsorg/website/assets/4034366/996ef52a-4daa-4984-8742-28fd1dca7dbd)
  • Loading branch information
juliawu authored Jan 6, 2024
1 parent 5fd8abb commit 6afce2e
Show file tree
Hide file tree
Showing 14 changed files with 768 additions and 457 deletions.
153 changes: 77 additions & 76 deletions server/config/subject_page_pb2.py

Large diffs are not rendered by default.

28 changes: 12 additions & 16 deletions server/templates/place.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
{% set place_category = category %}

{% block head %}
<link rel="stylesheet" href={{url_for('static', filename='css/place.min.css' , t=config['VERSION'])}}>
<link rel="stylesheet" href={{url_for('static', filename='css/place_page.min.css' , t=config['VERSION'])}}>
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Material+Symbols+Outlined" />
{% endblock %}

{% block content %}
Expand All @@ -38,21 +39,16 @@
</div>
</div>
<div id="main" class="col-md-9x col-lg-10">
<div id="title" class="row" data-dcid="{{ place_dcid }}">
<div class="col-12 col-md-6 order-last order-md-2">
<h1 id="place-name" data-pn="{{ place_name }}">{{ place_name }}</h1>
<h3 id="place-type" data-pt="{{ place_type }}"></h3>
<h3 id="locale" data-lc="{{ locale }}"></h3>
<div id="place-highlight"></div>
</div>
<div class="col-12 col-md-6 order-first order-md-last pb-3 pb-md-0">
<div class="search border">
<div id="location-field">
<div id="search-icon"></div>
{# TRANSLATORS: A hint shown in the search box, asking users to search for places. #}
<input id="place-autocomplete"
placeholder="{% trans %}Enter a country, state, county or city{% endtrans %}" type="text" />
</div>
<div id="title" data-dcid="{{ place_dcid }}">
<div id="place-heading-container">
<div id="place-heading">
<h1 id="place-name" data-pn="{{ place_name }}">{{ place_name }}</h1>
<h3 id="place-type" data-pt="{{ place_type }}"></h3>
<h3 id="locale" data-lc="{{ locale }}"></h3>
<div id="place-highlight"></div>
</div>
<div id="place-change-ui">
<div id="place-search-container"></div>
</div>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion server/templates/place_landing.html
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
{%- endmacro %}

{% block head %}
<link rel="stylesheet" href={{url_for('static', filename='css/place.min.css', t=config['VERSION'])}}>
<link rel="stylesheet" href={{url_for('static', filename='css/place_landing.min.css', t=config['VERSION'])}}>
{% endblock %}

{% block content %}
Expand Down
18 changes: 14 additions & 4 deletions server/webdriver/tests/place_explorer_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,13 +118,23 @@ def test_place_search(self):
# Load USA page.
self.driver.get(self.url_ + USA_URL)

# Wait until the place name has loaded.
element_present = EC.presence_of_element_located(
(By.CLASS_NAME, 'pac-target-input'))
# Wait until "Change Place" toggle has loaded.
element_present = EC.visibility_of_element_located(
(By.ID, 'change-place-toggle-text'))
WebDriverWait(self.driver, self.TIMEOUT_SEC).until(element_present)

search_box = self.driver.find_element(By.CLASS_NAME, "pac-target-input")
# Click on Change place
change_place_toggle = self.driver.find_element(By.ID,
'change-place-toggle-text')
change_place_toggle.click()

# Wait until the search bar is visible.
element_present = EC.visibility_of_element_located(
(By.ID, 'place-autocomplete'))
WebDriverWait(self.driver, self.TIMEOUT_SEC).until(element_present)

# Search for California in search bar
search_box = self.driver.find_element(By.ID, "place-autocomplete")
search_box.send_keys(PLACE_SEARCH)

# Wait until the place name has loaded.
Expand Down
1 change: 1 addition & 0 deletions static/css/base/_color.scss
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ $dc-primary-color: #467bd5;
--gm-3-white: #fff;
--gm-3-sys-light-surface-container-low: #f8fafd;
--gm-3-sys-light-outline-variant: #c4c7c5;
--gm-3-sys-light-on-surface: #1f1f1f;
// Following vars are overwritten in custom dc modes
--dc-primary: #{$dc-primary-color};
--link-color: #0b57d0;
Expand Down
163 changes: 163 additions & 0 deletions static/css/place/change_place_search_bar.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,163 @@
/**
* Copyright 2024 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

/** Styles for "Change Place" search bar on place pages */

// "Change Place" search bar colors
@import "../base/color";

#place-change-ui {
flex-grow: 1;
margin-bottom: 4px;
}

#place-search-container {
align-items: flex-end;
display: flex;
height: 100%;
width: 100%;
}

#change-place {
display: flex;
height: fit-content;
width: 100%;
}

.toggle-text {
color: var(--gm-3-sys-light-primary, #0b57d0);
cursor: pointer;
font-family: Google Sans Text;
font-size: 14px;
font-style: normal;
font-weight: 500;
height: 48px;
justify-content: center;
line-height: 20px;
margin-left: auto;
padding: 10px 12px 10px 0;
text-align: center;
width: fit-content;

@media only screen and (max-width: 420px) {
margin-left: 0;
margin-right: auto;
}
}

.search {
background: var(--gm-3-sys-light-surface-container-low);
border-bottom: 3px solid var(--gm-3-sys-light-primary);
color: var(--gm-3-sys-light-primary);
display: flex;
flex-direction: row;
flex-grow: 1;
font-family: Google Sans Text;
font-size: 12px;
font-style: normal;
font-weight: 400;
justify-content: space-around;
letter-spacing: 0.1px;
line-height: 16px;
margin-top: -6px;
overflow: hidden;
padding: 8px 0px;
position: relative;
width: 100%;
}

.search-text {
display: flex;
flex-direction: column;
flex-grow: 1;
justify-content: space-between;
}

.search-instructions {
cursor: default;
padding: 0px 16px;
}

.location-field {
align-items: center;
background: var(--gm-3-sys-light-surface-container-low);
display: flex;
flex-direction: row;
flex-wrap: wrap;
}

.place-list {
align-items: center;
display: flex;
flex-shrink: 0;
flex-wrap: wrap;
margin-left: 32px;
}

.close-icon {
color: #444746;
cursor: pointer;
height: 24px;
margin-left: auto;
position: absolute;
right: 8px;
top: 16px;
width: 24px;
}

.place-autocomplete-input {
background: var(--gm-3-sys-light-surface-container-low);
border: none;
box-sizing: content-box;
color: var(--gm-3-sys-light-on-surface);
display: flex;
flex-grow: 1;
font-family: Google Sans Text;
font-size: 14px;
font-weight: 500;
height: fit-content;
letter-spacing: 0;
line-height: 20px;
margin-left: 0;
outline: none;
padding: 0px 40px 0px 16px;
}

.place-autocomplete-input::-webkit-input-placeholder {
/* Chrome/Opera/Safari */
color: rgba(0, 0, 0, 0.25);
}

/* Maps suggestion dropdown overrides */
.pac-container {
background: white;
border: none;
box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.12);
box-sizing: border-box;
font-weight: 500;
font: normal 14px Google Sans Text;
line-height: 20px;
margin-top: 11px;
}
.pac-item {
padding: 10px 16px;
}
.pac-icon {
display: none;
}
.pac-logo:after {
display: none;
}
Loading

0 comments on commit 6afce2e

Please sign in to comment.