In the bellow React component, I'm using styled-components library for the purpose of styling.
import React from 'react'
import jsonResponse from '../data'
import styled from 'styled-components'
const StyledUl = styled.ul`
width: 100%;
`
const StyledLi = styled.li`
width: 100%;
/* Tablet View */
@media (min-width: 45.563em) and (max-width: 61.312em) {
width: 50%;
}
/* Desktop View */
@media (min-width: 61.313em) {
width: 33.33%;
}
`
const TextContainer = styled.div`
text-align: left;
`
const Btn = styled.button`
width: 26%;
@media (min-width: 45.563em) and (max-width: 61.312em) {
width: 42%;
}
@media (min-width: 61.313em) {
width: 42%;
}
`
function MyList ({ setID }) {
const list = jsonResponse.characters.map((item) => {
return (
<StyledLi key={item.id}>
<TextContainer>
<h3>{item.name}</h3>
<p>{item.details.short}</p>
</TextContainer>
<Btn onClick={() => setID(item.id)}>Read more</Btn>
</StyledLi>
)
})
return (
<StyledUl className='cf'>
{list}
</StyledUl>
)
}
export default MyList
Now I want to cut the styling part and put it in a separate file called myList-styling.js and import it in to my component MyList.jsx, but I'm not sure how.
Could you please help?