Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
tristan
committed
Sep 11, 2019
1 parent
1daccbb
commit ca9f58e
Showing
9 changed files
with
272 additions
and
50 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import React from 'react'; | ||
import styled from 'styled-components'; | ||
|
||
const Wrapper = styled.li` | ||
cursor: pointer; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
background: #ef7a82; | ||
.icon { | ||
width: 1.4rem; | ||
path { | ||
transition: all 0.5s ease-in; | ||
} | ||
} | ||
`; | ||
const IconCollection = ({ currColorHex, showCollection, ...rest }) => { | ||
const handleCollectClick = () => { | ||
console.log('collect t'); | ||
showCollection(); | ||
}; | ||
return ( | ||
<Wrapper {...rest} onClick={handleCollectClick}> | ||
<svg | ||
t="1568178514471" | ||
className="icon" | ||
viewBox="0 0 1024 1024" | ||
version="1.1" | ||
xmlns="http://www.w3.org/2000/svg" | ||
p-id="8559" | ||
width="32" | ||
height="32" | ||
> | ||
<path | ||
d="M914.304 182.848H109.696v36.608h804.608v-36.608z m-73.152-109.696H182.848v36.544h658.304v-36.544z m109.696 256h36.544v-36.608H36.544v621.696h950.912v-512h-36.608v475.456H73.152V329.152h877.696zM510.464 440.064a130.112 130.112 0 0 0-181.056-2.112 132.8 132.8 0 0 0 1.6 188.224l166.784 165.952a17.984 17.984 0 0 0 25.6 0l166.528-165.952a132.8 132.8 0 0 0 1.28-188.288 130.112 130.112 0 0 0-180.736 2.176z m182.848 88.256a100.288 100.288 0 0 1-29.184 71.936l-153.6 152.896-153.6-152.896a100.288 100.288 0 0 1-29.12-71.936 88.384 88.384 0 0 1 26.944-64 93.504 93.504 0 0 1 130.112 1.536l25.6 25.6 25.6-25.6a93.504 93.504 0 0 1 130.112-1.536 88.384 88.384 0 0 1 27.136 63.936z" | ||
fill="#fff" | ||
p-id="8560" | ||
></path> | ||
</svg> | ||
</Wrapper> | ||
); | ||
}; | ||
|
||
export default IconCollection; |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import React, { useState } from 'react'; | ||
import styled from 'styled-components'; | ||
import { CopyToClipboard } from 'react-copy-to-clipboard'; | ||
|
||
const Wrapper = styled.div` | ||
cursor: pointer; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
position: relative; | ||
> .hex { | ||
font-size: 0.6rem; | ||
padding: 0.2rem; | ||
background: rgba(51, 51, 51, 0.5); | ||
border-radius: 0.2rem; | ||
text-transform: uppercase; | ||
} | ||
.copyTip { | ||
position: absolute; | ||
left: 0.3rem; | ||
top: 2rem; | ||
font-size: 0.6rem; | ||
padding: 0.3rem 0.4rem; | ||
background: rgba(0, 0, 0, 0.6); | ||
border-radius: 0.2rem; | ||
} | ||
`; | ||
const IconFav = ({ currColorHex }) => { | ||
const [copied, setCopied] = useState(false); | ||
|
||
const handleCopyClick = () => { | ||
console.log('copy click'); | ||
}; | ||
return ( | ||
<CopyToClipboard | ||
text={currColorHex} | ||
onCopy={() => { | ||
setCopied(true); | ||
setTimeout(() => { | ||
setCopied(false); | ||
}, 1800); | ||
}} | ||
> | ||
<Wrapper onClick={handleCopyClick}> | ||
<svg | ||
t="1568174087144" | ||
className="icon" | ||
viewBox="0 0 1024 1024" | ||
version="1.1" | ||
xmlns="http://www.w3.org/2000/svg" | ||
p-id="7098" | ||
width="36" | ||
height="36" | ||
> | ||
<path | ||
d="M220.429 838.029c-18.2 0-32.9-14.7-32.9-32.9v-437c0-18.2 14.7-32.9 32.9-32.9h440c18.2 0 32.9 14.7 32.9 32.9v436.9c0 18.2-14.7 32.9-32.9 32.9h-440z m407-65.9v-371.1h-374.1v371.1h374.1z" | ||
fill="#fff" | ||
p-id="7099" | ||
></path> | ||
<path | ||
d="M438.129 254.029c-18.2 0-32.9-14.7-32.9-32.9s14.7-32.9 32.9-32.9h369.6c18.2 0 32.9 14.7 32.9 32.9v363.5c0 18.2-14.7 32.9-32.9 32.9s-32.9-14.7-32.9-32.9v-330.6h-336.7z" | ||
fill="#fff" | ||
p-id="7100" | ||
></path> | ||
</svg> | ||
<span className="hex">{currColorHex}</span> | ||
{copied ? <span className="copyTip">已复制!</span> : null} | ||
</Wrapper> | ||
</CopyToClipboard> | ||
); | ||
}; | ||
|
||
export default IconFav; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import React, { useState, useEffect } from 'react'; | ||
import styled from 'styled-components'; | ||
|
||
const Wrapper = styled.div` | ||
position: absolute; | ||
top: 0.2rem; | ||
right: 0.2rem; | ||
cursor: pointer; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
.icon path { | ||
transition: all 0.5s ease-in; | ||
} | ||
`; | ||
const FavStoreKey = 'FAV_COLORS'; | ||
const IconFav = ({ currColor }) => { | ||
const [isFav, setIsFav] = useState(false); | ||
|
||
useEffect(() => { | ||
const favs = JSON.parse(localStorage.getItem(FavStoreKey) || '[]'); | ||
console.log('favs e', favs); | ||
|
||
if (favs.some(f => f.name == currColor.name)) { | ||
setIsFav(true); | ||
} else { | ||
setIsFav(false); | ||
} | ||
}, [currColor]); | ||
const toggleFav = () => { | ||
let favs = JSON.parse(localStorage.getItem(FavStoreKey) || '[]'); | ||
console.log('favs t', favs); | ||
|
||
if (isFav) { | ||
favs = favs.filter(color => { | ||
return color.name != currColor.name; | ||
}); | ||
} else { | ||
favs.push(currColor); | ||
} | ||
setIsFav(prev => !prev); | ||
localStorage.setItem(FavStoreKey, JSON.stringify(favs)); | ||
}; | ||
return ( | ||
<Wrapper onClick={toggleFav}> | ||
<svg | ||
t="1568172188297" | ||
className="icon" | ||
viewBox="0 0 1024 1024" | ||
version="1.1" | ||
xmlns="http://www.w3.org/2000/svg" | ||
p-id="2640" | ||
width="32" | ||
height="32" | ||
> | ||
<path | ||
d="M512 910.933333l-61.866667-56.106667c-219.733333-199.466667-364.8-331.093333-364.8-492.16 0-131.626667 103.04-234.666667 234.666667-234.666667 74.24 0 145.493333 34.56 192 88.96 46.506667-54.4 117.76-88.96 192-88.96 131.626667 0 234.666667 103.04 234.666667 234.666667 0 161.066667-145.066667 292.693333-364.8 492.16l-61.866667 56.106667z" | ||
p-id="2641" | ||
fill={isFav ? '#ef7a82' : '#fff'} | ||
></path> | ||
</svg> | ||
</Wrapper> | ||
); | ||
}; | ||
|
||
export default IconFav; |
This file contains 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
This file contains 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
Oops, something went wrong.