Skip to content

Commit 6154f75

Browse files
committed
feat(): ADding the cursor
1 parent 027340c commit 6154f75

24 files changed

Lines changed: 314 additions & 47 deletions

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
"lodash": "^4.17.21",
4242
"react": "^18.2.0",
4343
"react-dom": "^18.2.0",
44+
"react-helmet-async": "^2.0.5",
4445
"react-i18next": "^14.1.1",
4546
"react-router-dom": "^6.23.1",
4647
"react-scripts": "5.0.1",

src/App.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,17 @@ import {
44
LocalizationProvider,
55
ThemeProvider,
66
} from '@providers';
7+
import { HelmetProvider } from 'react-helmet-async';
78

89
function App() {
910
return (
1011
<ThemeProvider>
1112
<React.StrictMode>
12-
<LocalizationProvider>
13-
<AppRouterProvider />
14-
</LocalizationProvider>
13+
<HelmetProvider>
14+
<LocalizationProvider>
15+
<AppRouterProvider />
16+
</LocalizationProvider>
17+
</HelmetProvider>
1518
</React.StrictMode>
1619
</ThemeProvider>
1720
);

src/components/Cursor/Cursor.tsx

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { motion } from 'framer-motion';
2+
import { useRef } from 'react';
3+
import { useSpringMousePosition } from '../../hooks';
4+
5+
const FollowCursor = () => {
6+
const ref = useRef<HTMLDivElement>(null);
7+
const { x, y } = useSpringMousePosition(ref);
8+
9+
return (
10+
<motion.div
11+
ref={ref}
12+
style={{
13+
x,
14+
y,
15+
backgroundColor: '#fff',
16+
mixBlendMode: 'difference',
17+
boxShadow: '0 0 50px 10px violet',
18+
zIndex: 999,
19+
width: '56px',
20+
height: '56px',
21+
borderRadius: '50%',
22+
}}
23+
/>
24+
);
25+
};
26+
27+
export default FollowCursor;

src/components/Cursor/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default as FollowingCursor } from './Cursor';

src/components/Theme/colors.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
const colors = {
22
transparent: 'transparent',
3+
primary: '#F1F2F3',
4+
secondary: '#00D8FF',
5+
success: '#31CE7B',
6+
danger: '#D82727',
7+
warning: '#D79D28',
8+
info: '#00D8FF',
9+
light: '#F1F2F3',
10+
dark: '#17191C',
311
black: '#000',
412
white: '#fff',
513
gray: {
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import React from 'react';
2+
import { Box } from '@chakra-ui/react';
3+
import { isEqual } from 'lodash';
4+
import { TitleBoxProps } from './types';
5+
import { Helmet } from 'react-helmet-async';
6+
7+
const TitleBoxContainer = ({
8+
title,
9+
icon,
10+
helmetChildren,
11+
...props
12+
}: TitleBoxProps) => {
13+
return (
14+
<Box {...props}>
15+
<Helmet>
16+
<title>{title}</title>
17+
<meta name="description" content={'Coding platform'} />
18+
{helmetChildren}
19+
</Helmet>
20+
{props.children}
21+
</Box>
22+
);
23+
};
24+
25+
export default React.memo(TitleBoxContainer, isEqual);
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import TitleBoxContainer from '../TitleBoxContainer';
2+
import { renderWithProvidersAndRouter } from '../../../testUtils';
3+
4+
const title = 'Test Title';
5+
const icon = 'test-icon';
6+
const props = {
7+
title,
8+
icon,
9+
children: 'Test Children',
10+
};
11+
12+
describe('TitleBoxContainer', () => {
13+
it('should set the document title', () => {
14+
const { container } = renderWithProvidersAndRouter(
15+
<TitleBoxContainer {...props} />,
16+
);
17+
18+
expect(container).toMatchSnapshot();
19+
});
20+
});

src/screens/mainFlow/__tests__/__snapshots__/MainScreen.test.tsx.snap renamed to src/components/TitleBox/__tests__/__snapshots__/TitleBoxContainer.test.tsx.snap

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`MainScreen should render correctly 1`] = `
3+
exports[`TitleBoxContainer should set the document title 1`] = `
44
<div>
55
<script
66
id="chakra-script"
77
>
88
!(function(){try{var a=function(c){var v="(prefers-color-scheme: dark)",h=window.matchMedia(v).matches?"dark":"light",r=c==="system"?h:c,o=document.documentElement,s=document.body,l="chakra-ui-light",d="chakra-ui-dark",i=r==="dark";return s.classList.add(i?d:l),s.classList.remove(i?l:d),o.style.colorScheme=r,o.dataset.theme=r,r},n=a,m="light",e="chakra-ui-color-mode",t=localStorage.getItem(e);t?a(t):localStorage.setItem(e,a(m))}catch(a){}})();
99
</script>
10-
<div>
11-
<h1>
12-
Main Screen
13-
</h1>
10+
<div
11+
class="css-0"
12+
>
13+
Test Children
1414
</div>
1515
<span
1616
hidden=""

src/components/TitleBox/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
export { default as TitleBoxContainer } from './TitleBoxContainer';
2+
export * from './types';

src/components/TitleBox/types.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { BoxProps } from '@chakra-ui/react';
2+
3+
export type TitleBoxProps = {
4+
title: string;
5+
icon?: string;
6+
helmetChildren?: React.ReactNode;
7+
} & BoxProps;

0 commit comments

Comments
 (0)