Last active
October 20, 2018 15:16
-
-
Save lomse/d4534c8aab8ee7dfb461e32ebab5a359 to your computer and use it in GitHub Desktop.
TodoItem component
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react' | |
import PropTypes from 'prop-types' | |
import styled from 'styled-components' | |
const StyledList = styled.li` | |
list-style: none; | |
overflow: hidden; | |
width: 100%; | |
margin-bottom: 10px; | |
` | |
const StyledLabel = styled.label` | |
float: left; | |
cursor: pointer; | |
` | |
const StyledButton = styled.button` | |
float: right; | |
background: palevioletred; | |
color: #fff; | |
border-radius: 3px; | |
border: 2px solid palevioletred; | |
padding: 3px 10px; | |
outline: none; | |
cursor: pointer; | |
` | |
const TodoItem = props => { | |
const { id, title } = props | |
return ( | |
<StyledList> | |
<StyledLabel htmlFor={id}> | |
<input type="checkbox" id={id} /> {title} | |
</StyledLabel> | |
<StyledButton type="button">Delete</StyledButton> | |
</StyledList> | |
) | |
} | |
TodoItem.propTypes = { | |
title: PropTypes.string.isRequired, | |
id: PropTypes.number.isRequired | |
} | |
export default TodoItem |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment