-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #433 from unepwcmc/ticket-53
Ticket 53
- Loading branch information
Showing
12 changed files
with
355 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
161 changes: 161 additions & 0 deletions
161
app/assets/stylesheets/components/select/_select-equity.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,161 @@ | ||
&--equity { | ||
@include breakpoint($medium) { | ||
display: flex; | ||
max-width: none; | ||
} | ||
|
||
max-width: rem-calc(685); | ||
margin: 0 auto; | ||
display: block; | ||
|
||
&__button { | ||
@include flex-vs-start; | ||
border-radius: rem-calc(4); | ||
} | ||
|
||
&__content { | ||
@include breakpoint-down($small) { | ||
img { | ||
object-fit: contain; | ||
} | ||
} | ||
@include breakpoint($small) { | ||
height: rem-calc(507); | ||
padding: rem-calc(30 0); | ||
|
||
img { | ||
object-fit: cover; | ||
} | ||
} | ||
@include breakpoint($medium) { | ||
width: 50%; | ||
height: auto; | ||
padding: rem-calc(60 0); | ||
} | ||
|
||
@include flex; | ||
border: 1px solid $grey-dark; | ||
|
||
height: rem-calc(271); | ||
padding: rem-calc(20 0); | ||
|
||
img { | ||
margin: 0 auto; | ||
} | ||
} | ||
|
||
&__description { | ||
@include flex-grow; | ||
} | ||
|
||
&__header { | ||
@include breakpoint($small) { | ||
margin-bottom: rem-calc(8); | ||
} | ||
@include breakpoint($medium) { | ||
margin-bottom: rem-calc(14); | ||
} | ||
|
||
margin-top: 0; | ||
margin-bottom: 0; | ||
} | ||
|
||
&__panel { | ||
@include breakpoint($small) { | ||
padding: rem-calc(50 44 62 49); | ||
} | ||
@include breakpoint($medium) { | ||
padding: rem-calc(41 40 29 57); | ||
width: 50%; | ||
} | ||
padding: rem-calc(32 13 29 18); | ||
|
||
@include flex; | ||
@include flex-column; | ||
|
||
background-color: $grey-xlight; | ||
} | ||
|
||
|
||
} | ||
|
||
// Custom select for this component | ||
&--dropdown { | ||
&__custom-select { | ||
@include breakpoint($small) { | ||
margin: rem-calc(30 0 36); | ||
} | ||
@include breakpoint($medium) { | ||
margin: rem-calc(14 0 19); | ||
} | ||
margin: rem-calc(0 0 27); | ||
position: relative; | ||
user-select: none; | ||
width: 100%; | ||
} | ||
|
||
&__selected { | ||
@include breakpoint($small) { | ||
padding: rem-calc(20 24); | ||
} | ||
|
||
@include flex; | ||
@include flex-v-center; | ||
@include flex-h-between; | ||
@include text-body; | ||
|
||
background: $white; | ||
border: 1px solid $grey-black; | ||
cursor: pointer; | ||
line-height: 1.9; | ||
padding: rem-calc(11 20); | ||
position: relative; | ||
} | ||
|
||
&__options { | ||
display: none; | ||
|
||
&--active { | ||
height: 40vh; | ||
background: $white; | ||
border: 1px solid $grey-black; | ||
border-top: 0; | ||
overflow: scroll; | ||
display: block; | ||
position: absolute; | ||
top: 100%; | ||
left: 0; | ||
right: 0; | ||
z-index: 2; | ||
} | ||
} | ||
|
||
&__option { | ||
@include breakpoint($small) { | ||
padding: rem-calc(5 24); | ||
} | ||
|
||
@include text-body; | ||
|
||
line-height: 1.9; | ||
display: block; | ||
padding: rem-calc(2 20); | ||
position: relative; | ||
|
||
&:hover { | ||
background-color: $grey-light; | ||
} | ||
} | ||
|
||
&__dropdown { | ||
@include icon-chevron-black-down; | ||
height: rem-calc(10); | ||
width: rem-calc(18); | ||
transform: rotate(0deg); | ||
|
||
&--active { | ||
@extend .select--dropdown__dropdown; | ||
transform: rotate(180deg); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
module EquityHelper | ||
def tabs | ||
@tabs = get_cms_tabs(2).to_json | ||
end | ||
|
||
def pa_pages | ||
@pa_pages ||= @cms_page.children.first.children | ||
end | ||
|
||
def text | ||
@text ||= cms_fragment_content(:text, @pa_pages.first) | ||
end | ||
|
||
def protected_areas | ||
pa_pages.published.map do |child| | ||
{ | ||
title: child.label, | ||
text: parsed_text(text), | ||
url: child.full_path, | ||
image: include_image(cms_fragment_content(:text, child)) | ||
} | ||
end | ||
end | ||
|
||
def include_image(pa_page) | ||
Nokogiri::HTML(pa_page).css("img").attr('src').value | ||
end | ||
|
||
def parsed_text(text) | ||
Nokogiri::HTML(text).css("p").last.text rescue "No description available." | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
<template> | ||
<div class="select--dropdown__custom-select"> | ||
<div class="select--dropdown__custom-select-box"> | ||
<div class="select--dropdown__selected" @click="toggleVis"> | ||
<span>{{ selected.title }}</span> | ||
<div | ||
:class="[ isActive ? 'select--dropdown__dropdown--active' : 'select--dropdown__dropdown' ]" | ||
></div> | ||
</div> | ||
<div :class="[ isActive ? 'select--dropdown__options--active' : 'select--dropdown__options' ]"> | ||
<span | ||
v-for="(area, index) in protectedAreas" | ||
:key="index" | ||
class="select--dropdown__option" | ||
@click="selectArea(index)" | ||
>{{ area.title }}</span> | ||
</div> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import mixinPopupCloseListeners from "../../mixins/mixin-popup-close-listeners" | ||
export default { | ||
name: "SelectDropdown", | ||
mixins: [ mixinPopupCloseListeners({closeCallback: 'close', toggleVariable: 'isActive'}) ], | ||
props: { | ||
protectedAreas: { | ||
type: Array | ||
} | ||
}, | ||
data() { | ||
return { | ||
isActive: false, | ||
selected: this.protectedAreas[0] | ||
}; | ||
}, | ||
methods: { | ||
toggleVis() { | ||
this.isActive ? this.close() : this.open(); | ||
}, | ||
close() { | ||
this.isActive = false; | ||
}, | ||
open() { | ||
this.isActive = true; | ||
}, | ||
selectArea(index) { | ||
this.selected = this.protectedAreas[index]; | ||
this.close(); | ||
this.$emit('pa-selected', this.selected); | ||
} | ||
} | ||
}; | ||
</script> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
<template> | ||
<div class="select--equity"> | ||
<div class="select--equity__content"> | ||
<img :src="selected.image" :alt="'Visual results for ' + selected.title" /> | ||
</div> | ||
|
||
<div class="select--equity__panel"> | ||
<h2 class="select--equity__header">Results from study sites</h2> | ||
<p class="select--equity__description">{{ selected.text }}</p> | ||
<select-dropdown :protected-areas="protectedAreas" @pa-selected="changeSelection" /> | ||
<a | ||
:href="selected.url" | ||
class="button--primary select--equity__button" | ||
title="View the protected area" | ||
>View Protected Area</a> | ||
</div> | ||
</div> | ||
</template> | ||
|
||
<script> | ||
import SelectDropdown from "./SelectDropdown"; | ||
export default { | ||
name: "select-equity", | ||
components: { SelectDropdown }, | ||
props: { | ||
protectedAreas: { | ||
type: Array | ||
} | ||
}, | ||
data() { | ||
return { | ||
selected: this.protectedAreas[0] | ||
}; | ||
}, | ||
methods: { | ||
changeSelection(selected) { | ||
this.selected = selected; | ||
} | ||
} | ||
}; | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.