Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Helpページの追加 #309

Merged
merged 16 commits into from
Sep 9, 2024
Merged

Helpページの追加 #309

merged 16 commits into from
Sep 9, 2024

Conversation

AKIYAMA-HAYATE
Copy link
Collaborator

対応Issue

概要

Helpページを実装しました

実装詳細

Embla Carouselライブラリの導入
Helpコンポーネントを作成

画面スクリーンショット等

image

テスト項目

  • [ ]ヘッダーのヘルプボタンからHelpページが開けるか
  • [ ]モーダル外もしくはヘッダーのヘルプボタンを押すとページが消えるか
  • [ ]戻るボタン、次へボタン、ドットボタンを押すことで画像が切り替わるか

備考

Copy link
Collaborator

@hikahana hikahana left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image

ルートディレクトリ配下にnode_modulesがインストールされちゃってるけどこれなにも参照されないし、すべてのデータはview-user/node_modulesに入っているのでpushしたnode_moduelsは削除しちゃっておけ。
package.jsonとpackage-lock.jsonもいらない

Copy link
Collaborator

@hikahana hikahana left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ちらっとみて気になったところコメントしました

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DotButton

Bを大文字にしてほしい。多分タイポ
パスカルケースにしてね

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ディレクトリ全てね

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

HelpCarousel
とかにしましょう。Helpだけだと分かりづらいので

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image
最後だけ次へではなく"閉じる"とかにしてほしい。
またできるなら言語切り替えによって英語と日本語を切り替えるようにしてほしい

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

あとlocalstrageとかを使ってページを開いた際にこのhelpを表示するようにしてほしい。

Comment on lines 73 to 78
<Button onClick={scrollPrev} inversion={true}>
戻る
</Button>
<Button onClick={scrollNext} inversion={true}>
次へ
</Button>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<Button onClick={scrollPrev} inversion={true}>
戻る
</Button>
<Button onClick={scrollNext} inversion={true}>
次へ
</Button>
{selectedIndex === 0 ? (
<Button onClick={() => setIsOpened(false)} inversion={true}>
{t.helpCarousel.close}
</Button>
) : (
<Button onClick={scrollPrev} inversion={true}>
{t.helpCarousel.back}
</Button>
)}
{selectedIndex === slidesCount - 1 ? (
<Button onClick={() => setIsOpened(false)} inversion={true}>
{t.helpCarousel.close}
</Button>
) : (
<Button onClick={scrollNext} inversion={true}>
{t.helpCarousel.next}
</Button>
)}

多分こんな感じ

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

localesの中身
jaに追記

  helpCarousel: {
    close: "閉じる",
    back: "戻る",
    next: "次へ",
  },

enに追記

  helpCarousel: {
    close: "close",
    back: "back",
    next: "next",
  },

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

画像の差し替えもできたら理想だけどちょっとめんどいね
英文の表記の

Copy link
Collaborator

@hikahana hikahana left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ごめん修正点だけ貼るのめんどくて全文貼っちゃった。
コピペして修正して欲しい

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

React.FCは使わない方面で

import styles from "./DotButton.module.css";

interface DotButtonProps {
  selected: boolean;
  onClick: () => void;
}

const DotButton = ({ selected, onClick }: DotButtonProps) => {
  return (
    <button
      className={`${styles.dotButton} ${selected ? styles.selected : ""}`}
      onClick={onClick}
    />
  );
};

export default DotButton;

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

useStateの変数名が気になったので

import styles from "./Header.module.css";
import { useRouter } from "next/router";
import Image from "next/image";
import { IoHelpCircleOutline } from "react-icons/io5";
import { HelpCarousel } from "@/components";
import { useState, useEffect } from "react";

const Header = () => {
  const router = useRouter();
  const [isOpenHelpCarousel, setIsOpenHelpCarousel] = useState(false);

  useEffect(() => {
    const isHelpShown = localStorage.getItem("helpShown");

    if (isHelpShown === null) {
      setIsOpenHelpCarousel(true);
      localStorage.setItem("isOpenHelpCarousel", JSON.stringify(true));
    }
  }, []);

  const handleClick = () => {
    setIsOpenHelpCarousel(true);
  };

  return (
    <div className={styles.container}>
      <div className={styles.main}>
        <Image
          className={styles.logo}
          src="/Bingo_logo.png"
          alt="sample"
          width={300}
          height={300}
          onClick={() => router.push("/")}
        />
        <button className={styles.icon} onClick={handleClick}>
          <IoHelpCircleOutline />
        </button>
      </div>
      {isOpenHelpCarousel && (
        <HelpCarousel
          isOpened={isOpenHelpCarousel}
          setIsOpened={setIsOpenHelpCarousel}
        />
      )}
    </div>
  );
};

export default Header;

display: flex;
justify-content: center;
margin-top: 10px;
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

テキストサイズのcssを追加

Suggested change
}
}
.buttonText {
font-size: 2.5vw;
}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

つかってない変数とtextのcssを追記

import { useCallback, useState, useEffect } from "react";
import styles from "./HelpCarousel.module.css";
import { Button, Modal, DotButton } from "@/components";
import useEmblaCarousel from "embla-carousel-react";
import Image from "next/image";
import { useRouter } from "next/router";
import { ja, en } from "@/locales";

interface HelpCarouselProps {
  isOpened: boolean;
  setIsOpened: (isOpened: boolean) => void;
}

const HelpCarousel = ({ isOpened, setIsOpened }: HelpCarouselProps) => {
  const [emblaRef, emblaApi] = useEmblaCarousel({ loop: false });
  const [selectedIndex, setSelectedIndex] = useState<number>(0);
  const [slidesCount, setSlidesCount] = useState<number>(0);
  const { locale } = useRouter();
  const [] = useState<string>(locale || "ja");
  const t = locale === "ja" ? ja : en;

  const onSelect = useCallback(() => {
    if (!emblaApi) return;
    setSelectedIndex(emblaApi.selectedScrollSnap());
  }, [emblaApi]);
  useEffect(() => {
    if (!emblaApi) return;
    onSelect();
    setSlidesCount(emblaApi.slideNodes().length);
    emblaApi.on("select", onSelect);
  }, [emblaApi, onSelect]);
  const scrollTo = useCallback(
    (index: number) => {
      if (emblaApi) emblaApi.scrollTo(index);
    },
    [emblaApi],
  );

  const scrollPrev = useCallback(() => {
    if (emblaApi) emblaApi.scrollPrev();
  }, [emblaApi]);
  const scrollNext = useCallback(() => {
    if (emblaApi) emblaApi.scrollNext();
  }, [emblaApi]);

  const images = [
    { src: "/Help_slide1.png", alt: "Help_slide1" },
    { src: "/Help_slide2.png", alt: "Help_slide2" },
    { src: "/Help_slide3.png", alt: "Help_slide3" },
    { src: "/Help_slide4.png", alt: "Help_slide4" },
    { src: "/Help_slide5.png", alt: "Help_slide5" },
  ];

  return (
    <Modal isOpened={isOpened} setIsOpened={setIsOpened}>
      <div className={styles.container}>
        <div className={styles.embla} ref={emblaRef}>
          <div className={styles.embla__container}>
            {images.map((image, index) => (
              <Image
                key={index}
                className={styles.embla__slide}
                src={image.src}
                alt={image.alt}
                width={1000}
                height={1000}
              />
            ))}
          </div>
          <div className={styles.carousel__dots}>
            {Array.from({ length: slidesCount }).map((_, index) => (
              <DotButton
                key={index}
                selected={index === selectedIndex}
                onClick={() => scrollTo(index)}
              />
            ))}
          </div>
          <div className={styles.screenTransition}>
            {selectedIndex === 0 ? (
              <Button onClick={() => setIsOpened(false)} inversion>
                <div className={styles.buttonText}>{t.helpCarousel.close}</div>
              </Button>
            ) : (
              <Button onClick={scrollPrev} inversion>
                <div className={styles.buttonText}>{t.helpCarousel.back}</div>
              </Button>
            )}
            {selectedIndex === slidesCount - 1 ? (
              <Button onClick={() => setIsOpened(false)} inversion>
                <div className={styles.buttonText}>{t.helpCarousel.close}</div>
              </Button>
            ) : (
              <Button onClick={scrollNext} inversion>
                <div className={styles.buttonText}>{t.helpCarousel.next}</div>
              </Button>
            )}
          </div>
        </div>
      </div>
    </Modal>
  );
};

export default HelpCarousel;

@@ -21,3 +21,5 @@ export { default as ToggleButton } from "./ToggleButton";
export { default as ReachIcon } from "./ReachIcon";
export { default as NavigationBar } from "./NavigationBar";
export { default as ReachCount } from "./ReachCount";
export { default as Help } from "./HelpCarousel";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
export { default as Help } from "./HelpCarousel";
export { default as HelpCarousel } from "./HelpCarousel";

直ってないよ

@AKIYAMA-HAYATE
Copy link
Collaborator Author

修正終わりました。確認お願いします。
・React.FCを使用し無くする
・useStateの変数名変更
・テキストサイズのcssを追加
・未使用の変数、関数を削除
・ボタンのCSSを追記
・HelpCarouselにしていないところを修正

Copy link
Collaborator

@hikahana hikahana left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@hikahana hikahana merged commit a7d7dd5 into develop Sep 9, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

helpページの作成(user)
2 participants