Skip to content
Snippets Groups Projects
VizTitle.vue 3.2 KiB
Newer Older
  <header id="grid-container">
Cee Nell's avatar
Cee Nell committed
    <div id="title-container" :class="{ mobile: mobileView }">
Cee Nell's avatar
Cee Nell committed
        ref="heroImage"
Cee Nell's avatar
Cee Nell committed
        :class="{ mobile: mobileView }"
        src="@/assets/images/hero_img_cutout_less-stylized_feather.png"
        alt="Social vulnerability and water insecurity"
Cee Nell's avatar
Cee Nell committed
        @load="updateSvgDimensions"
Cee Nell's avatar
Cee Nell committed
      />
Cee Nell's avatar
Cee Nell committed
      <svg ref="overlay" id="overlay" xmlns="http://www.w3.org/2000/svg">
        <defs>
          <filter id="blueOverlay">
            <feColorMatrix type="matrix" values="0 0 0 0 0
                                                  0 0 0 0 0
                                                  0 0 0 0 1
                                                  0 0 0 1 0"/>
          </filter>
        </defs>
Cee Nell's avatar
Cee Nell committed
        <circle class="animated-circle" cx="100" cy="100" r="50" fill="royalblue" filter="url(#blueOverlay)"/>
        <circle class="animated-circle" cx="200" cy="150" r="30" fill="royalblue" filter="url(#blueOverlay)"/>
        <circle class="animated-circle" cx="300" cy="200" r="70" fill="royalblue" filter="url(#blueOverlay)"/>
Cee Nell's avatar
Cee Nell committed
      </svg>
Cee Nell's avatar
Cee Nell committed
        <h1>Unequal access to water</h1>
        <h3>
Cee Nell's avatar
Cee Nell committed
          How societal factors shape exposure to water-related hazards, likelihood to suffer harm, and ability to cope and recover from losses
Cee Nell's avatar
Cee Nell committed
        </h3>
    </div>
  </header>
</template>

Cee Nell's avatar
Cee Nell committed
<script setup>
Cee Nell's avatar
Cee Nell committed
import { ref, onMounted, watch } from 'vue';
Cee Nell's avatar
Cee Nell committed
import { isMobile } from 'mobile-device-detect';
Cee Nell's avatar
Cee Nell committed
const mobileView = ref(isMobile);
Cee Nell's avatar
Cee Nell committed
const heroImage = ref(null);
const overlay = ref(null);

const updateSvgDimensions = () => {
  if (heroImage.value && overlay.value) {
    const { width, height, top, left } = heroImage.value.getBoundingClientRect();
    overlay.value.setAttribute('width', width);
    overlay.value.setAttribute('height', height);
    overlay.value.style.width = `${width}px`;
    overlay.value.style.height = `${height}px`;
    overlay.value.style.top = `${top}px`;
    overlay.value.style.left = `${left}px`;
  }
};

onMounted(() => {
  updateSvgDimensions();
  window.addEventListener('resize', updateSvgDimensions);
});

watch(mobileView, () => {
  updateSvgDimensions();
});
<style lang="scss" scoped>
#grid-container {
  display: grid;
Cee Nell's avatar
Cee Nell committed
  padding: 0px 0;
Cee Nell's avatar
Cee Nell committed
  gap: 0px;
Cee Nell's avatar
Cee Nell committed
  grid-template-columns: 1fr;
  grid-template-areas: 
Cee Nell's avatar
Cee Nell committed
    "title";
Cee Nell's avatar
Cee Nell committed
  width: 100vw;
  justify-content: center;
  margin: auto;
  @media screen and (max-width: 600px) {
Cee Nell's avatar
Cee Nell committed
    padding: 0 0 20px;
    grid-template-columns: 100%;
Cee Nell's avatar
Cee Nell committed
    grid-template-rows: max-content max-content;
Cee Nell's avatar
Cee Nell committed

Cee Nell's avatar
Cee Nell committed
#title-container  {
  grid-area: title;
Cee Nell's avatar
Cee Nell committed
  text-align: center;
Cee Nell's avatar
Cee Nell committed
  width: 100vw;
  max-width: 100%;
  margin: auto;
Cee Nell's avatar
Cee Nell committed
h1, h3 {
  margin-left: 50px; 
  margin-right: 50px; 
  text-align: left;  
}

Cee Nell's avatar
Cee Nell committed
#overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none; /* Ensure the SVG overlay doesn't interfere with other interactions */
}
Cee Nell's avatar
Cee Nell committed
.animated-circle {
  fill-opacity: 0.5; /* Make the circles semi-transparent */
  animation: pulse 20s infinite;
}
Cee Nell's avatar
Cee Nell committed

Cee Nell's avatar
Cee Nell committed
@keyframes pulse {
  0% {
    transform: scale(1);
    opacity: 0.5;
  }
  50% {
    transform: scale(1.1);
    opacity: 0.7;
  }
  100% {
    transform: scale(1);
    opacity: 0.5;
  }
}
Cee Nell's avatar
Cee Nell committed