Skip to content

Instantly share code, notes, and snippets.

@lomse
Last active October 20, 2018 15:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lomse/d4534c8aab8ee7dfb461e32ebab5a359 to your computer and use it in GitHub Desktop.
Save lomse/d4534c8aab8ee7dfb461e32ebab5a359 to your computer and use it in GitHub Desktop.
TodoItem component
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