|
| 1 | +/* |
| 2 | + * Copyright (C) 2018-present Arctic Ice Studio <[email protected]> |
| 3 | + * Copyright (C) 2018-present Sven Greb <[email protected]> |
| 4 | + * |
| 5 | + * Project: Nord Docs |
| 6 | + * Repository: https://github.com/arcticicestudio/nord-docs |
| 7 | + * License: MIT |
| 8 | + */ |
| 9 | + |
| 10 | +import React from "react"; |
| 11 | +import PropTypes from "prop-types"; |
| 12 | +import styled from "styled-components"; |
| 13 | + |
| 14 | +import LogosLayerBottom from "./styled/LogosLayerBottom"; |
| 15 | +import LogosLayerMiddle from "./styled/LogosLayerMiddle"; |
| 16 | +import LogosLayerTop from "./styled/LogosLayerTop"; |
| 17 | +import Window from "./styled/Window"; |
| 18 | + |
| 19 | +const Svg = styled.svg` |
| 20 | + display: block; |
| 21 | + overflow: visible; |
| 22 | +`; |
| 23 | + |
| 24 | +const transformLogosBottom = (x, y) => `translate3d(${-x * 0.008}px, ${-y * 0.009}px, 0)`; |
| 25 | +const transformLogosMiddle = (x, y) => `translate3d(${-x * 0.015}px, ${-y * 0.02}px, 0)`; |
| 26 | +const transformLogosTop = (x, y) => `translate3d(${-x * 0.03}px, ${-y * 0.038}px, 0)`; |
| 27 | + |
| 28 | +/** |
| 29 | + * An interactive illustration with a 3D depth effect that reacts and animates floating port project logos based on the |
| 30 | + * current mouse poiner position. |
| 31 | + * The animation is computed with react-spring through the exported `useFloatingLogos` hook. |
| 32 | + * |
| 33 | + * @author Arctic Ice Studio <[email protected]> |
| 34 | + * @author Sven Greb <[email protected]> |
| 35 | + * @since 0.9.0 |
| 36 | + * @see https://www.react-spring.io |
| 37 | + */ |
| 38 | +const PortProjectsWindow = ({ logoLayerTransformer, ...passProps }) => ( |
| 39 | + <Svg {...passProps} viewBox="0 0 1678.836 503.798" xmlns="http://www.w3.org/2000/svg"> |
| 40 | + <LogosLayerBottom style={{ transform: logoLayerTransformer(transformLogosBottom) }} /> |
| 41 | + <LogosLayerMiddle style={{ transform: logoLayerTransformer(transformLogosMiddle) }} /> |
| 42 | + <LogosLayerTop style={{ transform: logoLayerTransformer(transformLogosTop) }} /> |
| 43 | + <Window /> |
| 44 | + </Svg> |
| 45 | +); |
| 46 | + |
| 47 | +PortProjectsWindow.propTypes = { |
| 48 | + logoLayerTransformer: PropTypes.func.isRequired |
| 49 | +}; |
| 50 | + |
| 51 | +export default PortProjectsWindow; |
0 commit comments