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

Add species images and fix Minesweeper miscoloring in IDEAS #2629

Merged
merged 8 commits into from
Jul 15, 2024
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
8 changes: 4 additions & 4 deletions app/src/components/Modal/MinesweeperDialog.vue
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
</v-card-title>
<v-card-text>
<p>Try to find locations with <b>very high diversity</b>
and mark them with a <b>flower (right click)</b> and learn about
and mark them with a <b>flag (right click)</b> and learn about
Earth Observation data along the way.
</p>
<p>
Expand All @@ -31,8 +31,8 @@
<p>
Game is played like a minesweeper:
<br>
<b>Left mouse click</b> to uncover a <b>field.</b>
<b>Right mouse click</b> to flag it with a <b>flower.</b></p>
<b>Left mouse click</b> to uncover a <b>field. </b>
<b>Right mouse click</b> to flag it with a <b>flag.</b></p>
<br>A random game location is chosen every day. <b>Come back to explore more </b>tomorrow!
<!-- To explore new locations, add query parameter
seed with any value e.g. &seed=SeedString.
Expand Down Expand Up @@ -190,7 +190,7 @@ export default {
return;
}
// Get wildlife species index
const r1 = await fetch('https://eox-ideas.s3.eu-central-1.amazonaws.com/indicator2/species_index.json');
const r1 = await fetch('https://eox-ideas.s3.eu-central-1.amazonaws.com/indicator2/Species_Index_Images.json');
const speciesIndex = await r1.json();

// Get locations of species
Expand Down
56 changes: 53 additions & 3 deletions app/src/components/SpeciesList.vue
Original file line number Diff line number Diff line change
@@ -1,8 +1,27 @@
<template>
<dl>
<div v-for="s in species" :key="s.species" style="margin-bottom: 16px;">
<dt><b>{{ s.species }}</b><span v-if="s.count > 1" class="count">{{ s.count }}</span></dt>
<dd v-if="s.common_name !== 'Unknown'">({{ s.common_name }})</dd>
<div
class="species v-row"
v-for="s in species"
:key="s.species"
style="margin-bottom: 16px;"
>
<img
v-if="s.image_url && /\.(jpg|jpeg|png|gif|bmp|svg|webp)$/i.test(s.image_url)"
:src="s.image_url"
/>

<div
v-else
class="placeholder"
>?</div>

<a :href="s.image_url" class="names" target="_blank">
<dt><b>{{ s.species.replace(/(?:^|\s)\S/g, (match) => match.toUpperCase()) }}</b></dt>
<dd v-if="s.common_name !== 'Unknown'">({{ s.common_name }})</dd>
</a>

<span v-if="s.count > 1" class="count">{{ s.count }}</span>
</div>
</dl>
</template>
Expand All @@ -19,6 +38,37 @@ export default {
</script>

<style lang="scss" scoped>
.species {
display: flex;
flex-direction: row;
justify-content: space-between;
align-items: center;
margin-bottom: 16px;
min-width: 280px;

img, .placeholder {
height: 64px;
width: 64px;
border-radius: 4px;
margin-right: 12px;
border: 2px solid #99a;
}

.placeholder {
display: flex;
justify-content: center;
align-items: center;
font-size: 24px;
font-weight: 600;
background: #00417011;
}

.names {
width: 200px;
font-size: 15px;
}
}

.count {
height:22px;
padding: 0 9px;
Expand Down
8 changes: 4 additions & 4 deletions app/src/plugins/minesweeper/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,12 @@ const setupGrid = (game) => {
function getColorFromValue(v, min = 1, max = 8) {
let value;

if (v.isNaN) {
value = 0.0;
} else {
value = v;
if (Number.isNaN(v)) {
return 'rgba(0, 0, 0, 0)';
}

value = v;

// Ensure the value is within the expected range
value = Math.max(min, Math.min(max, value));

Expand Down
Loading