Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve search not found text #148

Merged
merged 7 commits into from
Jan 18, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@
"explore": "gridsome explore",
"eslint-ci": "yarn eslint-base --format @microsoft/eslint-formatter-sarif --output-file eslint-results.sarif",
"eslint-base": "yarn eslint --ext .ts,.vue ./src",
"lint": "yarn eslint-base && npx prettier . --check",
"lint-fix": "yarn eslint-base --fix && npx prettier . --write"
"prettier-base": "npx prettier ./**/*{.ts,.vue}",
"prettier-fix": "yarn prettier-base --write",
"lint": "yarn eslint-base && yarn prettier-base --check",
"lint-fix": "yarn eslint-base --fix && yarn prettier-base --write"
},
"dependencies": {
"csv-parse": "^5.3.6",
Expand Down
3 changes: 1 addition & 2 deletions src/components/DataDisclaimer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@
Chicago Energy Benchmarking Ordinance<NewTabIcon /> </a
>. According to the City &ldquo;As of 2016, this list includes all
commercial, institutional, and residential buildings larger than 50,000
square feet.&rdquo; This dataset is also then filtered to only buildings
with reported emissions > 1,000 metric tons CO<sub>2</sub> equivalent.
square feet.&rdquo;
</p>

<p class="constrained">
Expand Down
9 changes: 7 additions & 2 deletions src/components/graphs/PieChart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,10 @@ export default class PieChart extends Vue {
let data = d.data as any as IPieSlice;

const label =
`<tspan class="percent">${this.calculatePercentage(data.value, totalValue)}%</tspan>` +
`<tspan class="percent">${this.calculatePercentage(
data.value,
totalValue,
)}%</tspan>` +
`<tspan class="label" x="0" dy="1.5em">${data.label}</tspan>`;

return label;
Expand All @@ -121,7 +124,9 @@ export default class PieChart extends Vue {
return '';
}

return `translate(${labelArcGenerator.centroid(d as unknown as d3.DefaultArcObject)})`;
return `translate(${labelArcGenerator.centroid(
d as unknown as d3.DefaultArcObject,
)})`;
})
.style('text-anchor', (d) => {
// Center single slice label
Expand Down
32 changes: 27 additions & 5 deletions src/pages/Search.vue
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ export default class Search extends Vue {
searchResults: Array<IBuildingEdge> = [];
totalResultsCount = 0;

/** Dropdown information on database details */
dataDisclaimer!: HTMLDetailsElement;

created(): void {
// Make sure on load we have some data
this.setSearchResults(this.$static.allBuilding.edges);
Expand Down Expand Up @@ -157,6 +160,16 @@ export default class Search extends Vue {
this.totalResultsCount = allResults.length;
this.searchResults = allResults.slice(0, this.MaxBuildings);
}

/**
* Toggles DataDisclaimer open from the no-results message
*/
openDataDisclaimer(): void {
this.dataDisclaimer = document.getElementById(
'data-disclaimer',
) as HTMLDetailsElement;
this.dataDisclaimer.open = true;
}
}
</script>

Expand Down Expand Up @@ -200,7 +213,7 @@ export default class Search extends Vue {
results are limited to the first {{ MaxBuildings }} matches.
</p>

<DataDisclaimer />
<DataDisclaimer id="data-disclaimer" />

<form>
<div>
Expand Down Expand Up @@ -238,9 +251,18 @@ export default class Search extends Vue {
<div v-if="searchResults.length === 0" class="no-results-msg">
<h2>No results found!</h2>

<p class="layout-constrained">
There may be a typo in your search, the building name may be different
in the underlying data, or the building you are looking for may not be
in our dataset (buildings in Chicago over 50,000 square feet - see
<a href="#data-disclaimer" @click="openDataDisclaimer"
>dataset disclaimer</a
>).
</p>

<p>
There may be a typo in your query or in the underlying data, or the
building you are looking for may not be in our dataset.
<strong>Note:</strong> Addresses generally follow the format
<em>123 W Main St</em>
</p>
</div>

Expand Down Expand Up @@ -287,7 +309,7 @@ export default class Search extends Vue {
}

input[type='text'] {
width: 15rem;
width: 16rem;
}

button {
Expand All @@ -312,7 +334,7 @@ export default class Search extends Vue {

.no-results-msg {
background-color: $grey;
padding: 1rem;
padding: 1rem 0 2rem 0;
text-align: center;
}

Expand Down
Loading