Repository: sambernhardt/ipad-cursor Branch: master Commit: 6ac8a16b2f9c Files: 24 Total size: 21.9 KB Directory structure: gitextract_fk40wx2f/ ├── .gitignore ├── LICENSE ├── README.md ├── components/ │ ├── GoogleAnalytics/ │ │ ├── init.js │ │ └── layout.js │ ├── Providers.js │ └── components/ │ ├── Footer.js │ ├── Header.js │ ├── Hero.js │ ├── NavLink.js │ ├── Text/ │ │ └── index.js │ ├── TextArea.js │ └── Toggle.js ├── cursor/ │ ├── Context.js │ ├── Cursor.js │ ├── Provider.js │ ├── WithHover.js │ └── utils.js ├── package.json ├── pages/ │ ├── _app.js │ ├── _document.js │ ├── index.js │ └── test.js └── theme.js ================================================ FILE CONTENTS ================================================ ================================================ FILE: .gitignore ================================================ /node_modules /.next next.config.js .now ================================================ FILE: LICENSE ================================================ MIT License Copyright (c) 2020 sambernhardt Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: README.md ================================================ `git clone https://github.com/sambernhardt/ipad-cursor.git` `npm i` `npm run start` ![Preview](https://github.com/sambernhardt/ipad-cursor/blob/master/public/preview.gif) # Basic usage ## Add the CursorProvider to a page ```javascript // app.js import App from 'next/app'; import CursorProvider from '../cursor/Provider'; export default class MyApp extends App { render () { const { Component, pageProps } = this.props; return ( ) } } ``` ## Then wrap your components with the `WithHover` function ```javascript // Component.js import WithHover from '../cursor/WithHover'; const Component = () =>

; export default WithHover(, 'block'); ``` ### Caveats: - To move the contents of the hovered component, the component must have a display type of `inline-block` or `block`. CSS transforms don't work on inline elements. ================================================ FILE: components/GoogleAnalytics/init.js ================================================ import ReactGA from "react-ga" export const initGA = () => { ReactGA.initialize(process.env.google_analytics) } export const logPageView = () => { ReactGA.set({ page: window.location.pathname }) ReactGA.pageview(window.location.pathname) } ================================================ FILE: components/GoogleAnalytics/layout.js ================================================ import React, { Component } from "react" import { initGA, logPageView } from "./init.js" export default class Layout extends Component { componentDidMount () { if (!window.GA_INITIALIZED) { initGA() window.GA_INITIALIZED = true } logPageView() } render () { return (
{this.props.children}
) } } ================================================ FILE: components/Providers.js ================================================ import { Fragment, useState, useEffect } from 'react'; import { createGlobalStyle, ThemeProvider } from 'styled-components'; import { Reset } from 'styled-reset'; import useDarkMode from 'use-dark-mode'; import {light, dark} from '../theme'; import CursorProvider from '../cursor/Provider'; export default ({children}) => { const [mounted, setMounted] = useState(false); const {value} = useDarkMode(false, { storageKey: null }); useEffect(() => { setMounted(true) }, []); const body = {children} ; if (!mounted) { return
{body}
} return body; } const GlobalStyle = createGlobalStyle` body { color: ${({theme}) => theme.colors.body}; background: ${({theme}) => theme.colors.background}; font-family: ${({theme}) => theme.fonts.default}; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; } h1 { font-size: ${({theme}) => theme.fontSizes[3]}px; margin-bottom: ${({theme}) => theme.space[3]}px; } `; ================================================ FILE: components/components/Footer.js ================================================ import styled from 'styled-components'; import WithHover from '../../cursor/WithHover'; import Toggle from './Toggle'; const Container = styled.div` display: flex; justify-content: space-between; align-items: center; `; const Link = WithHover(styled.a` color: ${({theme}) => theme.colors.blue}; text-decoration: none; z-index: 99; padding: 8px 2px; &:hover { color: ${({theme}) => theme.colors.body}; } `, 'block'); const Heading = styled.div` font-size: 32px; `; export default () => { return ( Find me on the tweets or check out the code. ) } ================================================ FILE: components/components/Header.js ================================================ import styled from 'styled-components'; import NavLink from './NavLink'; const Container = styled.div` display: flex; justify-content: space-between; align-items: center; `; const Title = styled.h2` font-weight: 600; `; const Links = styled.div` display: flex; font-weight: 600; `; const Header = () => { return ( iPad Cursor Button 1 Button 2 Button 3 ) } export default Header; ================================================ FILE: components/components/Hero.js ================================================ import styled from 'styled-components'; import TextArea from './TextArea'; const Container = styled.div` min-height: 70vh; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; margin-bottom: 24px; `; const Hero = () => { return (