diff --git a/app/assets/stylesheets/tpi/pages/ascor.scss b/app/assets/stylesheets/tpi/pages/ascor.scss index 310f0cdd5..533f99bf1 100644 --- a/app/assets/stylesheets/tpi/pages/ascor.scss +++ b/app/assets/stylesheets/tpi/pages/ascor.scss @@ -264,6 +264,11 @@ $see-more-width-tablet: 130px; background-color: transparentize($ascor-background-color, 0.96); } + &__header { + position: relative; + padding-bottom: 10px; + } + &__title { color: $dark; font-family: $family-sans-serif; @@ -285,6 +290,10 @@ $see-more-width-tablet: 130px; } } + &__areas { + display: none; + } + &__area { outline: solid 1px $grey-lighter-medium; padding: 15px 20px 30px 20px; @@ -493,7 +502,26 @@ $see-more-width-tablet: 130px; } } - input.toggle:checked + .country-assessment__area-block { + input.toggle.pillar:checked + .country-assessment__pillar { + .country-assessment__areas { + display: block; + } + + .country-assessment__more.pillar { + top: 25px; + bottom: -1px; + + &:before { + content: 'See less'; + } + + &::after { + transform: rotate(-180deg); + } + } + } + + input.toggle.area:checked + .country-assessment__area-block { .country-assessment__indicators { display: block; } diff --git a/app/javascript/components/tpi/AscorQuestionLegend.js b/app/javascript/components/tpi/AscorQuestionLegend.js index 27fe583ea..0e0322a10 100644 --- a/app/javascript/components/tpi/AscorQuestionLegend.js +++ b/app/javascript/components/tpi/AscorQuestionLegend.js @@ -1,7 +1,10 @@ -import React, { useEffect } from 'react'; +import React, { useState, useEffect } from 'react'; +import cx from 'classnames'; const AscorQuestionLegend = () => { - const isChecked = () => { + const [isVisible, setVisible] = useState(false); + + const isCheckedArea = () => { let anyChecked = false; document @@ -9,7 +12,7 @@ const AscorQuestionLegend = () => { .forEach((section) => { let areaChecked = false; - section.querySelectorAll('input.toggle').forEach((input) => { + section.querySelectorAll('.country-assessment__areas > input.toggle').forEach((input) => { areaChecked = areaChecked || input.checked; anyChecked = anyChecked || input.checked; }); @@ -19,14 +22,33 @@ const AscorQuestionLegend = () => { }); }; + const isCheckedPillar = () => { + let anyChecked = false; + + document.querySelectorAll('.country-assessment > input.toggle.pillar').forEach((input) => { + anyChecked = anyChecked || input.checked; + }); + + setVisible(anyChecked); + }; + useEffect(() => { const eventListeners = []; document .querySelectorAll( - '.country-assessment > .country-assessment__pillar > input.toggle' + '.country-assessment .country-assessment__areas > input.toggle' + ) + .forEach((input) => { + const listener = input.addEventListener('click', isCheckedArea); + eventListeners.push([input, listener]); + }); + + document + .querySelectorAll( + '.country-assessment > input.toggle.pillar' ) .forEach((input) => { - const listener = input.addEventListener('click', isChecked); + const listener = input.addEventListener('click', isCheckedPillar); eventListeners.push([input, listener]); }); @@ -38,7 +60,7 @@ const AscorQuestionLegend = () => { }); return ( -