Giter Site home page Giter Site logo

devjoylee / niconnaecon Goto Github PK

View Code? Open in Web Editor NEW

This project forked from free-onboarding-team4/gifticon-market

0.0 0.0 0.0 980 KB

Mobile Giftcard Trading Service built in Next.js ๐ŸŽŸ๏ธ

Home Page: https://gifticon-market.vercel.app/

JavaScript 3.08% TypeScript 95.18% CSS 1.74%
nextjs typescript

niconnaecon's Introduction

Logo

NiconNaecon

View Demo

Table of Contents

About The Project

It is a mobile trading website which has various gift cards on sale. This project was developed under the given directions by the design guide from Figma and API written in JSON.

  • Production Period : 2022.02.07 - 2022.02.12

Team Members


Hyunho Lee (Leader)


Joy Lee


Hoonju Park


Changhyun Yoon

Member Role
Hyunho Lee QnA Page / Side Navbar
Joy Lee Dynamic Header / Router structure
Hoonju Park Detailed Page / Carousel
Changhyun Yoon Grid menu component / Footer

References


Built With

ย ย ย ย 


Getting Started

You are able to start the app by typing the following commands in the command line:

git clone https://github.com/devjoylee/niconnaecon.git
npm install
npm run dev

Main Features

1. Conditional Page Router

  • Implemented conditional routing to the relevant page by saving query of a clicked component (Category Id โ†’ Brand Id โ†’ Item Id)
  • Code Preview
// components/common/ConCard.tsx
export const ConCard = ({ category }: CategoryProps) => {
  const router = useRouter();
  const categoryId = router.query.id;
  // if current data has item data, link to brand page. Or link to category page.
  const href = !!category.conItems
    ? `/brands/${category.id}`
    : `/categories/${category.id}`;
  return (
    <LinkBox>
      <Link
        href={{
          pathname: href,
          query: { categoryId: JSON.stringify(categoryId) },
        }}
        passHref
        key={category.id}
      >
        <div>
          <img src={category.imageUrl} />
          <span>{category.name}</span>
        </div>
      </Link>
    </LinkBox>
  );
};

2. Dynamic Header.

  • When a page redirect, change a header name into the name of the current page from API data (it can be a category name, brand name or item name).
  • Change the browser tab title with the <Head> tag as well as the header name.
  • Code Preview
// components/layout/Header.tsx
export const Header = ({ id }: Props) => {
  const categoryId = useRef(id);
  const { data } = useData(`con-category1s/${categoryId.current}/nested`);
  const brandTitle = useRef<Title[]>([]);
  const [title, setTitle] = useState('');

  useEffect(() => {
    if (data && id === categoryId.current) {
      data.conCategory1.conCategory2s.map((brand: ConCategory2) => {
        brandTitle.current.push({ id: brand.id, name: brand.name });
      });
      setTitle(data.conCategory1.name);
    } else {
      brandTitle.current.forEach(
        brand => brand.id === Number(id) && setTitle(brand.name)
      );
      brandTitle.current = [];
    }
  }, [data, id, title]);

  return (
    <>
      <Head>
        <title>๋‹ˆ์ฝ˜๋‚ด์ฝ˜ - {title}</title>
      </Head>
      <HeaderContainer>
        <h2>{title}</h2>
      </HeaderContainer>
    </>
  );
};

3. Carousel on Main Page

  • Implemented the carousel drag event using the difference in pageX value of the mouse event between mouseDown and mouseUp
  • Code Preview
// components/carousel/CarouselBox.tsx
export const CarouselBox = ({ currentIndex, setCurrentIndex }: Props) => {
  const [startX, setStartX] = useState(0);
  const CarouselBoxRef = useRef<HTMLDivElement>(null);
  const carouselLength = CAROUSEL_IMAGES.length - 1;

  const handleMouseDown = (e: React.MouseEvent<HTMLUListElement>) => {
    setStartX(e.pageX);
    return;
  };

  const handleMouseUp = (e: React.MouseEvent<HTMLUListElement>) => {
    const movedDistance = e.pageX - startX;
    if (Math.abs(movedDistance) >= 50) {
      setCurrentIndex(prev => (movedDistance > 0 ? prev - 1 : prev + 1));
      return;
    }
  };

  useEffect(() => {
    CarouselBoxRef.current!.style.transition = '0.2s';
  }, [currentIndex]);

  return (
    <CarouselBoxContainer currentIndex={currentIndex} ref={CarouselBoxRef}>
      <CarouselUl
        onMouseDown={e => handleMouseDown(e)}
        onMouseUp={e => handleMouseUp(e)}
      >
        // ...
      </CarouselUl>
    </CarouselBoxContainer>
  );
};

Commit Convention

The commit message is written with the GITMOJI icons in order to make commit messages more intuitive.

Gitmoji Meaning
๐ŸŽ‰ Init or begin a project.
๐Ÿšš Move or rename resources
โœจ Introduce new features
๐Ÿ’„ Add the UI and style files
โ™ป๏ธ Refactor code
๐Ÿ“ Add or update documentation
โž• Add a dependency
๐Ÿ› Fix a bug
๐Ÿš€ Deploy stuff

REFERENCE : Gitmoji (http://gitmoji.dev/)


(back to top)

niconnaecon's People

Contributors

devjoylee avatar yoon-ch avatar hoonjoo-park avatar leehyunho2001 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.