티스토리 뷰
1️⃣ 개요
환경은 React와 typescript, styled-components 를 사용했습니다. Styled-Components 는 Props 를 받아서 CSS 속성을 동적으로 변경해줄 수 있습니다.
npm install -D styled-components
Progress Bar가 위 그림에서 회색 전체 진행바 부분이고, 파란색 부분은 Progress 입니다.
파란색 Progress의 width를 조정하여 왼쪽부터 채우는 원리다.
위 사진에 border-radius를 씌우면 귀염귀염한 진행 바를 확인할 수 있다.
import {useEffect, useState, useRef} from "react";
import styled from "styled-components";
interface ITest{
width: number,
}
const ProgressBar = styled.div`
width: 100%;
height: 30px;
background-color: #dedede;
border-radius:12px;
font-weight: 600;
font-size: .8rem;
margin-top: 20px;
overflow: hidden;
`;
const Progress = styled.div`
width: ${(props:ITest) => props.width}%;
height: 30px;
padding: 0;
text-align: center;
background-color: skyblue;
color: #111;
`
function App(){
const maxItem = 5
let availableItem = 2
return(
<ProgressBar>
<Progress width = {100-(availableItem*100/maxItem)}/>
</ProgressBar>
)]
참고
'웹 개발' 카테고리의 다른 글
[HTML/CSS/Vanilla JS] 스크롤 애니메이션 (2) | 2023.07.27 |
---|---|
[React TS + CSS] 클릭시 퍼지는 버튼 메뉴 만들기 (0) | 2023.02.12 |
[React + Typescript + Express + MySQL] 개발 환경 구축하기[1] (0) | 2022.08.19 |
[CSS] 이미지 두 개 겹친 후 CSS Animation 넣기(대각선으로 들어오고 대각선으로 사라지기) (0) | 2022.07.10 |
[React] 프로젝트 제작부터 간단한 작업을 통한 이해 (0) | 2022.07.04 |
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- 성능 개선
- FE 주니어
- 사이드프로젝트
- 프론트엔드개발자
- 리뷰
- Not Working
- 로딩성능
- JavaScript
- 패스트캠퍼스
- Vercel
- 국비지원
- 인프콘 2023
- Tailwind CSS
- netlify
- ci/cd
- RARS
- FE
- 이미지최적화
- 성능 측정
- no found
- 프론트엔드 성능
- 부트캠프
- 개발자 회고
- 깃허브 사용법
- 모노레포
- 국비지원취업
- kpt
- 깃허브
- next 14
- Github Actions
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
글 보관함