[D-3] 컴포넌트 UI 구성

2020. 1. 24. 15:38Project D (ToDoList)

반응형

총 4개의 컴포넌트 구성 (src/components)


TodoTemplate

 

1. 화면을 가운데 정렬, 앱 타이틀(일정관리) 표시

 

src/componenets

TodoTemplate.scss

더보기
.TodoTemplate {
  width: 512px;
  margin-left: auto;
  margin-right: auto;
  margin-top: 6rem;
  border-radius: 4px;
  overflow: hidden;

  .app-title {
    background: #22b8cf;
    color: white;
    height: 4rem;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
  }
  .content {
    background: white;
  }
}

TodoInsert


1. 새 항목 입력 및 추가 컴포넌트
2. state 를 통한 인풋상태 관리

 

src/componenets

TodoInsert.scss

더보기
.TodoInsert {
  display: flex;
  background: #495057;

  input {
    //기본 스타일 초기화
    background: none;
    outline: none;
    border: none;
    padding: 0.5rem;
    font-size: 1.125rem;
    line-height: 1.5;
    color: white;

    &::placeholder {
      color: #dee2e6;
    }

    //버튼을 제외한 영역 모두 차지하기
    flex: 1;
  }

  button {
    background: none;
    outline: none;
    border: none;
    background: #868e96;
    color: white;
    padding-left: 1rem;
    padding-right: 1rem;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    cursor: pointer;
    transition: 0.1s background ease-in;

    &:hover {
      background: #adb5bd;
    }
  }
}

TodoListItem


1. 각각의 할 일 항목에 대한 정보 표시 컴포넌트
2. todo 객체를 props로 받아와서 상태에 따라 다른 스타일의 UI 표시

 

src/componenets

TodoListItem.scss

더보기
.TodoListItem {
    padding: 1rem;
    display: flex;
    align-items: center;

    &:nth-child(even) {
        background: #f8f9fa
    }

    .checkbox {
        cursor: pointer;
        flex: 1;
        display: flex;
        align-items: center;

        svg {
            font-size: 1.5rem;
        }

        .text {
            margin-left: 0.5rem;
            flex: 1;
        }

        &.checked {
            svg {
                color: #22b8cf;
            }

            .text {
                color: #adb5bd;
                text-decoration: line-through;
            }
        }
    }

    .remove {
        display: flex;
        align-items: center;
        font-size: 1.5rem;
        color: #ff6b6b;
        cursor: pointer;

        &:hover {
            color: #ff8787;
        }
    }

    &+& {
        border-top: 1px solid #dee2e6;
    }
}

TodoList


1. todos 배열을 props로 받아서, 배열내장함수 map 사용해서 
   여러 개의 TodoListItem 컴포넌트로 변환해서 표시

 

src/componenets

TodoList.scss

더보기
.TodoList {
    min-height: 320px;
    max-height: 513px;
    overflow-y: auto;
}
반응형