inflearn logo
강의

Course

Instructor

[Renewal] Creating a NodeBird SNS with React

styles파일의 분리 문의

472

salus82

11 asked

0

안녕하세요? 다음과 같은 props값을 는 경우에 styles 코드만 따로 분리하려 합니다.

A.js(다음의 코드) Astyles.js(styled-components 따로 분리하려는 새 파일)

isSelected는 어떻게 처리해야하는지, 궁금합니다.

 

import React from 'react'
import styled from 'styled-components'

const Bar = (props) => {
    return (
        <BarWrapper onClick={props.handleClickBar} isSelected={props.isSelected}>
            <BarInfo>
                <Percent>{props.percent}%</Percent>
                <ItemVaue>{props.itemValue}</ItemVaue>
                <Count>{props.count}</Count>
            </BarInfo>
            <BarGraph width={props.percent} isSelected={props.isSelected}></BarGraph>
        </BarWrapper>
    )
}

const BarWrapper = styled.div`
    position: relative;
    margin-bottom: 3px;
    padding: 8px 0;
    background: ${({isSelected}) => isSelected ? '#dddddd' : '#f3f3f3'};
`
const BarInfo = styled.div`
    width: 100%;
    display: flex;
    z-index: 2;
    position: relative;
`
const Percent = styled.span`
    text-align: right;
    min-width: 70px;
    flex: 0 0 auto;
`
const ItemVaue = styled.span`
    padding-left: 60px;
    flex: 1 1 0%;
`
const Count = styled.span`
    padding-right: 20px;
    flex: 0 0 auto;
`
const BarGraph = styled.div`
    position: absolute;
    left: 0;
    top: 0;
    width: ${({width}) => width}%;
    transition: width 1.5s ease;
    height: 100%;
    background: ${({isSelected}) => isSelected ? 'rgba(126, 198, 81, 0.7)' : 'rgb(198, 198, 198)'};
    z-index: 1;
`

export default Bar

Next.js redux react nodejs express

Answer 2

0

salus82

네 강사님 감사합니다. 새해 복 많이 받으세요

0

zerocho

그냥 다른 파일로 그대로 옮기시면 됩니다. 아무 에러 나지 않습니다.

넥스트 버젼 질문

0

78

2

로그인시 401 Unauthorized 오류가 뜹니다

0

89

1

무한 스크롤 중 스크롤 튐 현상

0

175

1

특정 페이지 접근을 막고 싶을 때

0

103

2

createGlobalStyle의 위치와 영향범위

0

96

2

인라인 스타일 리렌더링 관련

0

91

2

vsc 에서 npm init 설치시 오류

0

146

2

nextjs 15버전 사용 가능할까요?

0

158

1

화면 새로고침 문의

0

121

1

RTK에서 draft, state 차이가 있나요?

0

153

2

Next 14 사용해도 될까요?

0

452

1

next, node 버전 / 폴더 구조 질문 드립니다.

0

349

1

url 오류 질문있습니다

0

211

1

ssh xxxxx로 우분투에 들어가려니까 port 22: Connection timed out

0

373

1

sudo certbot --nginx 에러

0

1275

2

Minified React error 콘솔에러 (hydrate)

0

470

1

카카오 공유했을 때 이전에 작성했던 글이 나오는 버그

0

247

1

프론트서버 배포 후 EADDRINUSE에러 발생

0

327

1

npm run build 에러

0

518

1

front 서버 npm run build 중에 발생한 에러들

0

382

1

서버 실행하고 브라우저로 들어갔을때 404에러

0

338

2

css 서버사이드 랜더링이 적용되지 않아서 문의 드립니다.

0

288

1

팔로워 3명씩 불러오고 데이터 합쳐주는걸로 바꾸고 서버요청을 무한으로하고있습니다.

0

239

2

해시태그 검색에서 throttle에 관해 질문있습니다.

0

201

1