ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • React - Shadow
    React/Style 2021. 6. 6. 20:41
    • React Shadow 모듈 설치
      • npm i react-shadow
      • root.div 안의 태그들만 별도의 스타일 속성 지정
      • 단점
        1. 공통적인 스타일인 경우에도 반복적으로 추가해야 함
        2. 외부와 내부가 차단되어 있어 document에 지정되어 있는 값을 상대적으로 표현할 때 제약사항 발생
    // App.js
    import root from 'react-shadow';
    
    // App.css 내용 삽입
    const styles = `
    .App {
      text-align: center;
    }
    
    .App-logo {
      height: 40vmin;
      pointer-events: none;
    }
    
    @media (prefers-reduced-motion: no-preference) {
      .App-logo {
        animation: App-logo-spin infinite 20s linear;
      }
    }
    
    .App-header {
      background-color: #282c34;
      min-height: 100vh;
      display: flex;
      flex-direction: column;
      align-items: center;
      justify-content: center;
      font-size: calc(10px + 2vmin);
      color: white;
    }
    
    .App-link {
      color: #61dafb;
    }
    
    @keyframes App-logo-spin {
      from {
        transform: rotate(0deg);
      }
      to {
        transform: rotate(360deg);
      }
    }
    `;
    
    function App() {
      return (
        <root.div>
          <div className="App">
            <header className="App-header">
              <img src={logo} className="App-logo" alt="logo" />
              <p>
                Edit <code>src/App.js</code> and save to reload.
              </p>
              <a
                className="App-link"
                href="https://reactjs.org"
                target="_blank"
                rel="noopener noreferrer"
              >
                Learn React
              </a>
            </header>
          </div>
          <style type="text/css">{styles}</style>
        </root.div>
      );
    }

     

    'React > Style' 카테고리의 다른 글

    Ant Design  (0) 2021.06.06
    React - Styled Components  (0) 2021.06.06
    React - CSS Modules  (0) 2021.06.05
    React - Style Loaders  (0) 2021.06.05

    댓글

Designed by Tistory.