Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

style: format code with Prettier and StandardJS #516

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 34 additions & 39 deletions src/components/hooks/useRect/index.tsx
Original file line number Diff line number Diff line change
@@ -1,60 +1,55 @@
import { useCallback, useLayoutEffect, useRef, useState } from "react";
import { useCallback, useLayoutEffect, useRef, useState } from 'react'

Check failure on line 1 in src/components/hooks/useRect/index.tsx

View workflow job for this annotation

GitHub Actions / Qodana for JS

ESLint

ESLint: Install the 'eslint' package

import ResizeObserver from 'resize-observer-polyfill'

type RectResult = {
bottom: number;
height: number;
left: number;
right: number;
top: number;
width: number;
} | null;
bottom: number
height: number
left: number
right: number
top: number
width: number
} | null

const getRect = (element: HTMLElement | null): RectResult | null => {
if (!element) return null;
return element.getBoundingClientRect();
};

const useRect = (): [
RectResult,
React.MutableRefObject<HTMLDivElement | null>
] => {
const ref = useRef<HTMLDivElement | null>(null);
const current = ref.current || null;
const [rect, setRect] = useState(getRect(current));
if (!element) return null
return element.getBoundingClientRect()
}

const useRect = (): [RectResult, React.MutableRefObject<HTMLDivElement | null>] => {
const ref = useRef<HTMLDivElement | null>(null)
const current = ref.current || null
const [rect, setRect] = useState(getRect(current))

const handleResize = useCallback(() => {
if (!ref.current) return;
if (!ref.current) return

// Update client rect
setRect(getRect(ref.current));
}, [ref]);
setRect(getRect(ref.current))
}, [ref])

useLayoutEffect(() => {
const element = ref.current;
if (!element) return;
const element = ref.current
if (!element) return

handleResize();
if (typeof ResizeObserver === "function") {
let resizeObserver: ResizeObserver | null = new ResizeObserver(() =>
handleResize()
);
resizeObserver.observe(element);
handleResize()
if (typeof ResizeObserver === 'function') {
let resizeObserver: ResizeObserver | null = new ResizeObserver(() => handleResize())
resizeObserver.observe(element)

return () => {
if (!resizeObserver) return;
resizeObserver.disconnect();
resizeObserver = null;
};
if (!resizeObserver) return
resizeObserver.disconnect()
resizeObserver = null
}
}
// set resize listener
window.addEventListener("resize", handleResize);
window.addEventListener('resize', handleResize)
// remove resize listener
return () => window.removeEventListener("resize", handleResize);
}, [handleResize]);
return () => window.removeEventListener('resize', handleResize)
}, [handleResize])

return [rect, ref];
};
return [rect, ref]
}

export default useRect
80 changes: 56 additions & 24 deletions src/pages/home/index.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { version, useState, useRef } from 'react'

Check failure on line 1 in src/pages/home/index.jsx

View workflow job for this annotation

GitHub Actions / Qodana for JS

ESLint

ESLint: Install the 'eslint' package
import { Input, Flex, Button } from 'antd'
import { SendOutlined } from '@ant-design/icons'
import { Atom, Merge, GitMerge, GitPullRequestArrow } from 'lucide-react'
Expand All @@ -6,9 +6,9 @@
// import { PinInput } from 'react-input-pin-code'
import SpotlightCard from '@stateless/Spotlight'
import Typewriter from 'typewriter-effect'
import Marquee from "react-fast-marquee"
import Masonry, { ResponsiveMasonry } from "react-responsive-masonry"
import useDetectScroll, { Direction } from "@smakss/react-scroll-direction"
import Marquee from 'react-fast-marquee'
import Masonry, { ResponsiveMasonry } from 'react-responsive-masonry'
import useDetectScroll, { Direction } from '@smakss/react-scroll-direction'

Check warning on line 11 in src/pages/home/index.jsx

View workflow job for this annotation

GitHub Actions / Qodana for JS

Unused import

Unused ``` import useDetectScroll, { Direction } from '@smakss/react-scroll-direction' ```
import FixTabPanel from '@stateless/FixTabPanel'
import TypedText from '@stateless/TypedText'
import ReMarkdown from '@stateless/ReMarkdown'
Expand Down Expand Up @@ -64,7 +64,7 @@
}
}

const [pinValues, setPinValues] = useState(['', '', '', '', '', '', ''])

Check warning on line 67 in src/pages/home/index.jsx

View workflow job for this annotation

GitHub Actions / Qodana for JS

Unused local symbol

Unused constant setPinValues

Check warning on line 67 in src/pages/home/index.jsx

View workflow job for this annotation

GitHub Actions / Qodana for JS

Unused local symbol

Unused constant pinValues

const onSubmit = () => {
if (chatText.trim() === '') {
Expand Down Expand Up @@ -184,7 +184,7 @@
<section style={{ marginBottom: 40 }}>
<AutoLink text="foo bar baz http://example.org bar https://github.com/wkylin/pro-react-admin" />
</section>
<section className={styles.line}></section>
<section className={styles.line} />
<section>
<AvatarCard avatar="https://picsum.photos/seed/picsum/300/160" text="Hi, I'm a developer." />
</section>
Expand All @@ -202,13 +202,11 @@
</p>
</section> */}
<section style={{ marginBottom: 40, fontSize: 16 }}>
<h3>
React Animate On Scroll.
</h3>
<h3>React Animate On Scroll.</h3>
<h3>
<AutoLink text="https://motion.dev/ https://gsap.com/ https://www.react-spring.dev/ https://use-gesture.netlify.app/" />
</h3>
<h3 style={{marginBottom: 40}}>
<h3 style={{ marginBottom: 40 }}>
<AutoLink text="https://www.npmjs.com/package/react-animate-on-scroll https://www.npmjs.com/package/react-scroll https://github.com/wellyshen/react-cool-inview" />
</h3>
<ScrollAnimation>
Expand Down Expand Up @@ -267,24 +265,36 @@
<AnimateOnScreen.DiyAnimation
from={{ opacity: 0, transform: 'translate(-100%, 0)' }}
to={{ opacity: 1, transform: 'translate(0, 0)' }}
triggerOnce={true}
triggerOnce
>
<img src="https://picsum.photos/360/200.jpg" alt="" />
</AnimateOnScreen.DiyAnimation>
</section>
<section style={{ marginBottom: 40, display: 'flex' }}>
<SpotlightCard className="my-spot" style={{ width: 360, height: 200, color: '#fff'}}>
<section></section>
<SpotlightCard className="my-spot" style={{ width: 360, height: 200, color: '#fff' }}>
<section />
</SpotlightCard>
</section>
<section className={styles.box} style={{ marginBottom: 10, width: 360, height: 200, position: 'relative', backgroundColor: 'rgba(0, 0,0, 0.9)', borderRadius:8 }}>
<section
className={styles.box}
style={{
marginBottom: 10,
width: 360,
height: 200,
position: 'relative',
backgroundColor: 'rgba(0, 0,0, 0.9)',
borderRadius: 8,
}}
>
<section className={styles.dotMask} ref={barRef}>
dot mask
</section>
</section>
<section style={{ marginBottom: 40, fontSize: 18 }}>
<section>RectResult.</section>
width: {parseInt(barRect?.width)} height: {parseInt(barRect?.height)} top: {parseInt(barRect?.top)} bottom: {parseInt(barRect?.bottom)} right: {parseInt(barRect?.right)} left: {parseInt(barRect?.left)}</section>
width: {parseInt(barRect?.width)} height: {parseInt(barRect?.height)} top: {parseInt(barRect?.top)} bottom:{' '}
{parseInt(barRect?.bottom)} right: {parseInt(barRect?.right)} left: {parseInt(barRect?.left)}
</section>
<section style={{ marginBottom: 40, height: 200, width: 360, overflow: 'hidden' }}>
<MeshGradientBackground />
</section>
Expand All @@ -299,17 +309,17 @@
<section className={styles.watermark}>water mark</section>
mask
</section>
<section style={{ marginBottom: 40 }} >
<button className={styles['button']} onClick={fireConfetti}>
<section style={{ marginBottom: 40 }}>
<button className={styles.button} onClick={fireConfetti}>
<span className={styles['button-label']}>Click Me</span>
</button>
</section>

<section style={{ position: 'relative', margin: '80px 0 160px 100px' }}>
<div className={styles['circle-1']}></div>
<div className={styles['circle-2']}></div>
<div className={styles['circle-3']}></div>
<div className={styles['circle-4']}></div>
<div className={styles['circle-1']} />
<div className={styles['circle-2']} />
<div className={styles['circle-3']} />
<div className={styles['circle-4']} />
</section>

<section style={{ margin: 20 }} className={styles.eHElAY}>
Expand All @@ -333,7 +343,7 @@
<Input defaultValue={apiKey} placeholder="api key" onChange={changeApiKey} style={{ marginBottom: 20 }} />
<Flex align="center">
{/* <LinearWrap> */}
<Input.TextArea

Check notice on line 346 in src/pages/home/index.jsx

View workflow job for this annotation

GitHub Actions / Qodana for JS

Unresolved JSX component

Unresolved component Input.TextArea
ref={textareaRef}
defaultValue={chatText}
placeholder="来,说点什么呗...Meta + Enter发送"
Expand Down Expand Up @@ -367,9 +377,7 @@
<AnimateWave />
</section>
<section style={{ margin: 20 }}>
<ResponsiveMasonry
columnsCountBreakPoints={{350: 1, 750: 2, 900: 6}}
>
<ResponsiveMasonry columnsCountBreakPoints={{ 350: 1, 750: 2, 900: 6 }}>
<Masonry gutter="10px">
<LazyLoadImage src="https://picsum.photos/id/1/300/100" alt="Strawberries" />
<LazyLoadImage src="https://picsum.photos/id/2/300/200" alt="Strawberries" />
Expand All @@ -391,12 +399,36 @@
</section>
<section style={{ margin: 20 }}>
<Marquee autoFill direction="left" gradient gradientColor="rgba(255, 255, 255, 0.8)">
<div style={{ width: 200, height: 40, lineHeight: '40px', textAlign: 'center', background: '#aaa', margin: '0 10px', borderRadius: 4 }}>React</div>
<div
style={{
width: 200,
height: 40,
lineHeight: '40px',
textAlign: 'center',
background: '#aaa',
margin: '0 10px',
borderRadius: 4,
}}
>
React
</div>
</Marquee>
</section>
<section style={{ margin: 20 }}>
<Marquee autoFill direction="right" gradient gradientColor="rgba(255, 255, 255, 0.8)">
<div style={{ width: 200, height: 40, lineHeight: '40px', textAlign: 'center', background: '#aaa', margin: '0 10px', borderRadius: 4 }}>Vue</div>
<div
style={{
width: 200,
height: 40,
lineHeight: '40px',
textAlign: 'center',
background: '#aaa',
margin: '0 10px',
borderRadius: 4,
}}
>
Vue
</div>
</Marquee>
</section>
</FixTabPanel>
Expand Down
Loading