diff --git a/src/components/ImageViewer/ImageViewer.tsx b/src/components/ImageViewer/ImageViewer.tsx new file mode 100644 index 0000000..c6e4a47 --- /dev/null +++ b/src/components/ImageViewer/ImageViewer.tsx @@ -0,0 +1,82 @@ +import { + IonButton, + IonButtons, + IonContent, + IonHeader, + IonIcon, + IonModal, + IonSlide, + IonSlides, + IonToolbar, +} from '@ionic/react'; +import { close } from 'ionicons/icons'; +import React, { + cloneElement, + ReactElement, + SyntheticEvent, + useState, +} from 'react'; +import './imageViewer.css'; + +type ContainerProps = { + alt: string; + class?: string; + children?: ReactElement; + className?: string; + onError?: + | ((event: SyntheticEvent) => void) + | undefined; + src: string; + open?: boolean; +}; + +export const ImageViewer: React.FC = (props) => { + const { alt, children, onError = () => {}, open = false, src } = props; + + const [isOpen, setIsOpen] = useState(open); + + const slideOpts = { + passiveListeners: false, + zoom: { + maxRatio: 5, + }, + }; + + return ( + <> + setIsOpen(false)} + swipeToClose + > + + + + setIsOpen(false)}> + + + + + + + + + {alt} + + + + + {cloneElement(children as ReactElement, { + onClick: () => setIsOpen(true), + })} + + ); +}; diff --git a/src/components/ImageViewer/imageViewer.css b/src/components/ImageViewer/imageViewer.css new file mode 100644 index 0000000..4025cc2 --- /dev/null +++ b/src/components/ImageViewer/imageViewer.css @@ -0,0 +1,31 @@ +.image-viewer { + --border-radius: 0; + --background: transparent; +} + +.image-viewer ion-slides { + height: 100vh; +} + +.image-viewer ion-slides img { + height: 100vh; +} + +.image-viewer ion-toolbar { + --background: transparent; + --border-width: 0 !important; + position: absolute; +} + +.image-viewer ion-toolbar::after { + display: none; +} + +.image-viewer .modal-wrapper { + display: block; + height: 100%; + left: 0; + position: absolute; + top: 0; + width: 100%; +} diff --git a/src/components/ImageViewer/index.tsx b/src/components/ImageViewer/index.tsx new file mode 100644 index 0000000..9d28e7f --- /dev/null +++ b/src/components/ImageViewer/index.tsx @@ -0,0 +1 @@ +export { ImageViewer } from './ImageViewer'; diff --git a/src/data/chapter/chapter01.tsx b/src/data/chapter/chapter01.tsx index d5d180c..eba74bd 100644 --- a/src/data/chapter/chapter01.tsx +++ b/src/data/chapter/chapter01.tsx @@ -1,8 +1,10 @@ import { IonImg, IonText } from '@ionic/react'; import React from 'react'; import { useTranslation } from 'react-i18next'; +import { ImageViewer } from '../../components/ImageViewer'; +import { ChapterId } from '../../utils/chapters'; -const CHAPTER_ID = '01'; +const CHAPTER_ID: ChapterId = '01'; export const Section01 = () => { const sectionId = '01'; @@ -30,10 +32,15 @@ export const Section01 = () => {
  • {t(`CHAPTER.${CHAPTER_ID}.${sectionId}.TEXT.LIST.01.070000`)}
  • {t(`CHAPTER.${CHAPTER_ID}.${sectionId}.TEXT.LIST.01.080000`)}
  • - + > + + {t(`CHAPTER.${CHAPTER_ID}.${sectionId}.IMAGE.01.TITLE`)} @@ -56,10 +63,15 @@ export const Section02 = () => {
  • {t(`CHAPTER.${CHAPTER_ID}.${sectionId}.TEXT.LIST.01.050000`)}
  • {t(`CHAPTER.${CHAPTER_ID}.${sectionId}.TEXT.LIST.01.060000`)}
  • - + > + + {t(`CHAPTER.${CHAPTER_ID}.${sectionId}.IMAGE.01.TITLE`)} @@ -81,10 +93,15 @@ export const Section03 = () => {
  • {t(`CHAPTER.${CHAPTER_ID}.${sectionId}.TEXT.LIST.01.050000`)}
  • {t(`CHAPTER.${CHAPTER_ID}.${sectionId}.TEXT.LIST.01.060000`)}
  • - + > + + {t(`CHAPTER.${CHAPTER_ID}.${sectionId}.IMAGE.01.TITLE`)} @@ -115,10 +132,15 @@ export const Section04 = () => {
  • {t(`CHAPTER.${CHAPTER_ID}.${sectionId}.TEXT.LIST.01.040000`)}
  • - + > + + {t(`CHAPTER.${CHAPTER_ID}.${sectionId}.IMAGE.01.TITLE`)} diff --git a/src/data/chapter/chapter02.tsx b/src/data/chapter/chapter02.tsx index f2e4d9f..3051021 100644 --- a/src/data/chapter/chapter02.tsx +++ b/src/data/chapter/chapter02.tsx @@ -1,8 +1,10 @@ import { IonImg, IonText } from '@ionic/react'; import React from 'react'; import { useTranslation } from 'react-i18next'; +import { ImageViewer } from '../../components/ImageViewer'; +import { ChapterId } from '../../utils/chapters'; -const CHAPTER_ID = '02'; +const CHAPTER_ID: ChapterId = '02'; export const Section01 = () => { const sectionId = '01'; @@ -16,15 +18,20 @@ export const Section01 = () => {
  • {t(`CHAPTER.${CHAPTER_ID}.${sectionId}.TEXT.LIST.01.020000`)}
  • {t(`CHAPTER.${CHAPTER_ID}.${sectionId}.TEXT.LIST.01.030000`)}
  • {t(`CHAPTER.${CHAPTER_ID}.${sectionId}.TEXT.LIST.01.040000`)}
  • -
    + - - {t(`CHAPTER.${CHAPTER_ID}.${sectionId}.IMAGE.01.TITLE`)} - -
    + + + {t(`CHAPTER.${CHAPTER_ID}.${sectionId}.IMAGE.01.TITLE`)} +
  • {t(`CHAPTER.${CHAPTER_ID}.${sectionId}.TEXT.LIST.01.050000`)}
    • {t(`CHAPTER.${CHAPTER_ID}.${sectionId}.TEXT.LIST.01.050100`)}
    • @@ -33,15 +40,20 @@ export const Section01 = () => {
    • {t(`CHAPTER.${CHAPTER_ID}.${sectionId}.TEXT.LIST.01.070000`)}
    • {t(`CHAPTER.${CHAPTER_ID}.${sectionId}.TEXT.LIST.01.080000`)}
    • {t(`CHAPTER.${CHAPTER_ID}.${sectionId}.TEXT.LIST.01.090000`)}
    • -
      + - - {t(`CHAPTER.${CHAPTER_ID}.${sectionId}.IMAGE.02.TITLE`)} - -
      + + + {t(`CHAPTER.${CHAPTER_ID}.${sectionId}.IMAGE.02.TITLE`)} +
    ); @@ -63,10 +75,15 @@ export const Section02 = () => {
  • {t(`CHAPTER.${CHAPTER_ID}.${sectionId}.TEXT.LIST.01.060000`)}
  • {t(`CHAPTER.${CHAPTER_ID}.${sectionId}.TEXT.LIST.01.070000`)}
  • - + > + + {t(`CHAPTER.${CHAPTER_ID}.${sectionId}.IMAGE.01.TITLE`)} @@ -91,10 +108,15 @@ export const Section03 = () => {
  • {t(`CHAPTER.${CHAPTER_ID}.${sectionId}.TEXT.LIST.01.080000`)}
  • {t(`CHAPTER.${CHAPTER_ID}.${sectionId}.TEXT.LIST.01.090000`)}
  • - + > + + {t(`CHAPTER.${CHAPTER_ID}.${sectionId}.IMAGE.01.TITLE`)} @@ -112,16 +134,19 @@ export const Section04 = () => {
    • {t(`CHAPTER.${CHAPTER_ID}.${sectionId}.TEXT.LIST.01.010000`)}
    • {t(`CHAPTER.${CHAPTER_ID}.${sectionId}.TEXT.LIST.01.020000`)}
    • -
      - - - {t(`CHAPTER.${CHAPTER_ID}.${sectionId}.IMAGE.01.TITLE`)} - -
    + + + + + {t(`CHAPTER.${CHAPTER_ID}.${sectionId}.IMAGE.01.TITLE`)} +

    {t(`CHAPTER.${CHAPTER_ID}.${sectionId}.TEXT.PARAGRAPH.02`)}

    • {t(`CHAPTER.${CHAPTER_ID}.${sectionId}.TEXT.LIST.02.010000`)}
    • @@ -129,15 +154,18 @@ export const Section04 = () => {
    • {t(`CHAPTER.${CHAPTER_ID}.${sectionId}.TEXT.LIST.02.030000`)}

    {t(`CHAPTER.${CHAPTER_ID}.${sectionId}.TEXT.PARAGRAPH.03`)}

    -
    + - - {t(`CHAPTER.${CHAPTER_ID}.${sectionId}.IMAGE.02.TITLE`)} - -
    + + + {t(`CHAPTER.${CHAPTER_ID}.${sectionId}.IMAGE.02.TITLE`)} + ); }; @@ -156,15 +184,18 @@ export const Section05 = () => {
  • {t(`CHAPTER.${CHAPTER_ID}.${sectionId}.TEXT.LIST.01.040000`)}
  • {t(`CHAPTER.${CHAPTER_ID}.${sectionId}.TEXT.LIST.01.050000`)}
  • -
    + - - {t(`CHAPTER.${CHAPTER_ID}.${sectionId}.IMAGE.01.TITLE`)} - -
    + + + {t(`CHAPTER.${CHAPTER_ID}.${sectionId}.IMAGE.01.TITLE`)} + ); }; @@ -189,15 +220,18 @@ export const Section06 = () => {
  • {t(`CHAPTER.${CHAPTER_ID}.${sectionId}.TEXT.LIST.01.020300`)}
  • -
    + - - {t(`CHAPTER.${CHAPTER_ID}.${sectionId}.IMAGE.01.TITLE`)} - -
    + + + {t(`CHAPTER.${CHAPTER_ID}.${sectionId}.IMAGE.01.TITLE`)} + ); };