Frontend/React

React 리액트 - 리액트 style 애니메이션 적용

Ayel 2025. 12. 28. 16:37

 
 

keyframes.js

 
 

 
 
- keyframes 폴더로 애니메이션 이펙트 관리
- keyframes > keyframes.js 파일 내에서 이펙트 구현
 
 
<keyframes.js>

import { keyframes } from "styled-components";

export const fadeIn = keyframes`
  0% {
    opacity: 0;
    transform: translate(0, -30px);
  }
  100% {
    opacity: 1;
    transform: translate(0, 0);
  }
`

 
 
<style.js>

import styled from "styled-components";
import { flexCenter, flexCenterColumn, flexColumn, h1Bold, h3Regular } from "../../styles/common";
import { height, width } from "@fortawesome/free-solid-svg-icons/fa0";
import { fadeIn } from "../../keyframes/keyframes";
import { media } from "../../styles/breakpoint";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";

const S = {}

// SnowFlake
  // 이미지 스타일
  S.SnowImg = styled.img`
    width: ${(width) => width}; // props의 width를 width로만 사용 가능
    object-fit: cover;
    border-radius: 8px;
    padding: 20px;
  `;

  // 박스 스타일
  S.SnowImgWrapper = styled.div`
    border: 1px pink;
    ${flexCenterColumn}
  `

  S.SnowWrapper = styled.div`
    width: 800px;
    height: 800px;
    border: solid 1px purple;
    ${flexCenter}
  `;

  S.SnowBg = styled.div`
    width: ${({width}) => width};
    height: ${(height) => height};
    background-image: url("/assets/images/styled/04.jpg");
    background-repeat: no-repeat;
    background-size: cover;
    background-position: center;

    animation: ${fadeIn} 1s ease-in forwards;
  `

  // Styled04
  S.Title = styled.p`
    ${h1Bold}
    opacity: 0;
    animation: ${fadeIn} 1s ease-in forwards;
    }
  `

  S.SubTitle = styled.p`
    ${h3Regular}
  `

export default S;

 
 
- 기존의 style.js폴더에 정의된 컴포넌트에 애니메이션 추가
- animation: ${fadeIn} 1s ease-in forwards;으로 글씨 및 이미지에 적용 가능
 
 
<결과화면>


 
 
https://developernew.tistory.com/447

 

React 리액트 - 리액트 style 활용 방법 theme.js

theme.js - 테마 관련 정의 파일 - UI/UX 가이드에 정의된 값을 정의하는 파일 theme.js에서 전체 테마를 정의한 후 common.js에서 프로젝트에서 자주 쓰이는 공통 속성을 정의style.js에서 해당 폴더에 적용

developernew.tistory.com

https://developernew.tistory.com/446

 

React 리액트 - 리액트 style 활용 방법 global.js

styles > global.js global.js는 리액트의 글로벌 스타일 정의 파일-> 프로젝트 전체 속성을 한꺼번에 정의할 수 있다 ** common.js가 공통적으로 자주 사용하는 속성이라면global.js는 프로젝트 전체 속성 및

developernew.tistory.com

https://developernew.tistory.com/444

 

React 리액트 - 리액트 style 활용 방법 common.js

Style 컴포넌트 기본 구조 import React from 'react';import S from './style';const Styled01 = () => { return ( EMAIL PW SUBMIT );};export default Styled01; - 이메일, 패스워드 입력창을 꾸미기 위해 form과 div 사용-> 스타일 적용

developernew.tistory.com

https://developernew.tistory.com/443

 

React 리액트 - 폴더 구조, 리액트의 스타일

리액트 기본 폴더 구조 [components][utils] - arrayheler.js - parseheler.js[consts] - key.js (상수, 문자열)[styles] // js의 장점 -> 동적 스타일 변경이 가능하다 -> 변수 제어 -> 속도가 엄청나게 빠름 - theme.js - global

developernew.tistory.com

https://developernew.tistory.com/445

 

React 리액트 - 폰트 스타일 적용 방법

font : 상업적 이용 가능한 무료 한글 폰트 사이트 https://noonnu.cc 눈누상업적 이용 가능한 한글 폰트를 쉽게 찾아보세요.noonnu.cc 상업적으로 이용 가능한 유료 폰트를 포함해다양한 무료 폰트를 제

developernew.tistory.com