|
| 1 | +/* eslint-disable @docusaurus/no-html-links */ |
| 2 | +// eslint-disable-next-line @typescript-eslint/ban-ts-comment |
| 3 | +// @ts-nocheck |
| 4 | +// External Components |
| 5 | + |
| 6 | +import React, { useEffect, useState } from "react"; |
| 7 | +import styles from "./styles.module.css"; |
| 8 | +import useBaseUrl from "@docusaurus/useBaseUrl"; |
| 9 | + |
| 10 | +export default function ContentBlock() { |
| 11 | + const [isDarkMode, setIsDarkMode] = useState(false); |
| 12 | + |
| 13 | + useEffect(() => { |
| 14 | + const theme = document.documentElement.getAttribute("data-theme"); |
| 15 | + setIsDarkMode(theme === "dark"); |
| 16 | + const observer = new MutationObserver(() => { |
| 17 | + const newTheme = document.documentElement.getAttribute("data-theme"); |
| 18 | + setIsDarkMode(newTheme === "dark"); |
| 19 | + }); |
| 20 | + |
| 21 | + observer.observe(document.documentElement, { |
| 22 | + attributes: true, |
| 23 | + attributeFilter: ["data-theme"], |
| 24 | + }); |
| 25 | + |
| 26 | + return () => observer.disconnect(); |
| 27 | + }, []); |
| 28 | + return ( |
| 29 | + <section |
| 30 | + className={`${styles.section} ${styles["section--content-block"]}`} |
| 31 | + > |
| 32 | + <div className={`${styles.msf} ${styles["content-block"]}`}> |
| 33 | + <div className={styles.container}> |
| 34 | + <div className={styles["content-block__wrapper"]}> |
| 35 | + <article className={styles["l-title"]}> |
| 36 | + <h2>This is a headline. It should be a max of two lines.</h2> |
| 37 | + <p> |
| 38 | + Lorem ipsum dolor sit amet consectetur. Turpis vulputate gravida |
| 39 | + ut id dictum aliquam aliquam. Amet fermentum vivamus vestibulum |
| 40 | + pellentesque. Nec ultricies in fusce pulvinar integer diam |
| 41 | + tincidunt massa tincidunt. |
| 42 | + </p> |
| 43 | + <a className={styles["l-btn"]} href="#" title="Optional button"> |
| 44 | + Optional button |
| 45 | + </a> |
| 46 | + </article> |
| 47 | + <figure className={styles["aspect-box"]}> |
| 48 | + <img |
| 49 | + src={ |
| 50 | + isDarkMode |
| 51 | + ? useBaseUrl("/img/placeholder_dark.png") |
| 52 | + : useBaseUrl("/img/placeholder.png") |
| 53 | + } |
| 54 | + onError={({ currentTarget }) => { |
| 55 | + currentTarget.style.display = "none"; |
| 56 | + }} |
| 57 | + alt="Placeholder image" |
| 58 | + /> |
| 59 | + </figure> |
| 60 | + </div> |
| 61 | + </div> |
| 62 | + </div> |
| 63 | + |
| 64 | + {/* content block inverse */} |
| 65 | + <div |
| 66 | + className={`${styles.msf} ${styles["content-block"]} ${styles["content-block--inverse"]}`} |
| 67 | + > |
| 68 | + <div className={styles.container}> |
| 69 | + <div className={styles["content-block__wrapper"]}> |
| 70 | + <article className={styles["l-title"]}> |
| 71 | + <h2>This is a headline. It should be a max of two lines.</h2> |
| 72 | + <p> |
| 73 | + Lorem ipsum dolor sit amet consectetur. Turpis vulputate gravida |
| 74 | + ut id dictum aliquam aliquam. Amet fermentum vivamus vestibulum |
| 75 | + pellentesque. Nec ultricies in fusce pulvinar integer diam |
| 76 | + tincidunt massa tincidunt. |
| 77 | + </p> |
| 78 | + <a className={styles["l-btn"]} href="#" title="Optional button"> |
| 79 | + Optional button |
| 80 | + </a> |
| 81 | + </article> |
| 82 | + <figure className={styles["aspect-box"]}> |
| 83 | + <img |
| 84 | + src={ |
| 85 | + isDarkMode |
| 86 | + ? useBaseUrl("/img/placeholder_dark.png") |
| 87 | + : useBaseUrl("/img/placeholder.png") |
| 88 | + } |
| 89 | + onError={({ currentTarget }) => { |
| 90 | + currentTarget.style.display = "none"; |
| 91 | + }} |
| 92 | + alt="Placeholder image" |
| 93 | + /> |
| 94 | + </figure> |
| 95 | + </div> |
| 96 | + </div> |
| 97 | + </div> |
| 98 | + </section> |
| 99 | + ); |
| 100 | +} |
0 commit comments