Giter Site home page Giter Site logo

minesweeper's Introduction

설치 및 실행 방법

  • 라이브러리 설치
    npm install
  • 실행
    npm start

구현

  • 첫 번째 빈칸 오픈 시 지뢰가 터지지 않음
  • 게임 타이머 (우측)
  • 남은 지뢰 갯수 (좌측)
  • 우클릭 시 깃발 기능
  • 난이도 변경 기능
  • 난이도 시 난이도 정보 저장 (마지막에 사용한 난이도 유지)

참고 코드

타이머 구현

  • React 스톱워치 구현하기(TS)

    import { useState, useEffect } from "react";
    
    const StopWatch = () => {
      const [time, setTime] = useState(0);
      const [isRunning, setIsRunning] = useState(false);
    
      useEffect(() => {
        let interval: NodeJS.Timer | undefined;
    
        if (isRunning) {
          interval = setInterval(() => {
            setTime((prevTime) => prevTime + 10);
          }, 10);
        } else {
          clearInterval(interval);
        }
    
        return () => clearInterval(interval);
      }, [isRunning]);
    
      return (
        <div>
          <time>
            {`0${Math.floor((time / 60000) % 60)}`.slice(-2)} :{" "}
            {`0${Math.floor((time / 1000) % 60)}`.slice(-2)}
          </time>
          <div>
            <button type="button" onClick={() => setIsRunning(true)}>
              Start
            </button>
            <button type="button" onClick={() => setIsRunning(false)}>
              Stop
            </button>
            <button type="button" onClick={() => setTime(0)}>
              Reset
            </button>
          </div>
        </div>
      );
    };
    
    export default StopWatch;

지뢰 보드 구현 Grid

  • CSS Grid 완벽 가이드

    .container {
      display: grid;
      grid-template-rows: 1행크기 2행크기 ...;
      grid-template-rows: [선이름] 1행크기 [선이름] 2행크기 [선이름] ...;
    }

모달 창

  • react-modal

    import React from "react";
    import ReactDOM from "react-dom";
    import Modal from "react-modal";
    
    const customStyles = {
      content: {
        top: "50%",
        left: "50%",
        right: "auto",
        bottom: "auto",
        marginRight: "-50%",
        transform: "translate(-50%, -50%)",
      },
    };
    
    // Make sure to bind modal to your appElement (https://reactcommunity.org/react-modal/accessibility/)
    Modal.setAppElement("#yourAppElement");
    
    function App() {
      let subtitle;
      const [modalIsOpen, setIsOpen] = React.useState(false);
    
      function openModal() {
        setIsOpen(true);
      }
    
      function afterOpenModal() {
        // references are now sync'd and can be accessed.
        subtitle.style.color = "#f00";
      }
    
      function closeModal() {
        setIsOpen(false);
      }
    
      return (
        <div>
          <button onClick={openModal}>Open Modal</button>
          <Modal
            isOpen={modalIsOpen}
            onAfterOpen={afterOpenModal}
            onRequestClose={closeModal}
            style={customStyles}
            contentLabel="Example Modal"
          >
            <h2 ref={(_subtitle) => (subtitle = _subtitle)}>Hello</h2>
            <button onClick={closeModal}>close</button>
            <div>I am a modal</div>
            <form>
              <input />
              <button>tab navigation</button>
              <button>stays</button>
              <button>inside</button>
              <button>the modal</button>
            </form>
          </Modal>
        </div>
      );
    }
    
    ReactDOM.render(<App />, appElement);

우클릭 이벤트

숫자를 정해진 자리로 표시하기

minesweeper's People

Contributors

hhanoo avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.