Skip to content

Instantly share code, notes, and snippets.

@lomse
Last active October 9, 2018 09:16
Show Gist options
  • Save lomse/747c83a2c59c8ee29aa830afe11d111a to your computer and use it in GitHub Desktop.
Save lomse/747c83a2c59c8ee29aa830afe11d111a to your computer and use it in GitHub Desktop.
Styled Components
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.string.isRequired
}
export default TodoItem
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment