2021-06-28 12:13:34 +00:00
|
|
|
import React from 'react'
|
2021-05-28 16:25:43 +00:00
|
|
|
import { useSelector } from 'state'
|
2021-06-29 12:00:59 +00:00
|
|
|
import tld from 'utils/tld'
|
2021-06-05 06:36:39 +00:00
|
|
|
import { DotCircle, Handle } from './misc'
|
2021-06-29 14:54:46 +00:00
|
|
|
import styled from 'styles'
|
2021-05-28 13:08:51 +00:00
|
|
|
|
2021-06-21 21:35:28 +00:00
|
|
|
export default function Defs(): JSX.Element {
|
2021-05-28 13:08:51 +00:00
|
|
|
return (
|
|
|
|
<defs>
|
2021-06-05 06:36:39 +00:00
|
|
|
<DotCircle id="dot" r={4} />
|
|
|
|
<Handle id="handle" r={4} />
|
2021-06-27 09:07:20 +00:00
|
|
|
<ExpandDef />
|
2021-07-09 16:15:27 +00:00
|
|
|
<HoverDef />
|
2021-05-28 13:08:51 +00:00
|
|
|
</defs>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2021-06-27 09:07:20 +00:00
|
|
|
function ExpandDef() {
|
2021-06-29 12:00:59 +00:00
|
|
|
const zoom = useSelector((s) => tld.getCurrentCamera(s.data).zoom)
|
2021-06-27 09:07:20 +00:00
|
|
|
return (
|
|
|
|
<filter id="expand">
|
2021-07-09 16:15:27 +00:00
|
|
|
<feMorphology operator="dilate" radius={1 / zoom} />
|
2021-06-27 09:07:20 +00:00
|
|
|
</filter>
|
|
|
|
)
|
|
|
|
}
|
2021-06-29 14:54:46 +00:00
|
|
|
|
2021-07-09 16:15:27 +00:00
|
|
|
function HoverDef() {
|
2021-06-29 14:54:46 +00:00
|
|
|
return (
|
|
|
|
<filter id="hover">
|
2021-07-09 16:15:27 +00:00
|
|
|
<StyledShadow
|
|
|
|
dx="2"
|
|
|
|
dy="2"
|
|
|
|
stdDeviation="0.5"
|
|
|
|
floodOpacity="1"
|
|
|
|
floodColor="blue"
|
|
|
|
/>
|
2021-06-29 14:54:46 +00:00
|
|
|
</filter>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
const StyledShadow = styled('feDropShadow', {
|
|
|
|
floodColor: '$selected',
|
|
|
|
})
|