Skip to content

Commit c1824db

Browse files
committed
feat(): Adding music feature
1 parent ff0e839 commit c1824db

11 files changed

Lines changed: 158 additions & 85 deletions

File tree

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
"@react-three/drei": "^9.121.2",
3232
"@react-three/fiber": "^8.17.12",
3333
"@react-three/postprocessing": "^2.16.6",
34+
"@tailwindcss/typography": "^0.5.16",
3435
"@testing-library/jest-dom": "^5.17.0",
3536
"@testing-library/react": "^13.4.0",
3637
"@testing-library/user-event": "^13.5.0",

public/bg.mp3

4.53 MB
Binary file not shown.

src/assets/icons/Common/Music.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { SVGProps } from 'react';
2+
3+
function MusicIcon(props: SVGProps<SVGSVGElement>) {
4+
return (
5+
<svg
6+
xmlns="http://www.w3.org/2000/svg"
7+
viewBox="0 0 24 24"
8+
width="1em"
9+
height="1em"
10+
{...props}
11+
>
12+
<path
13+
fill="currentColor"
14+
d="M12 3v10.55c-.59-.34-1.27-.55-2-.55c-2.21 0-4 1.79-4 4s1.79 4 4 4s4-1.79 4-4V7h4V3z"
15+
></path>
16+
</svg>
17+
);
18+
}
19+
20+
export default MusicIcon;
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { SVGProps } from 'react';
2+
3+
function MusicOffIcon(props: SVGProps<SVGSVGElement>) {
4+
return (
5+
<svg
6+
xmlns="http://www.w3.org/2000/svg"
7+
viewBox="0 0 24 24"
8+
width="1em"
9+
height="1em"
10+
{...props}
11+
>
12+
<path
13+
fill="currentColor"
14+
d="M4.27 3L3 4.27l9 9v.28c-.59-.34-1.27-.55-2-.55c-2.21 0-4 1.79-4 4s1.79 4 4 4s4-1.79 4-4v-1.73L19.73 21L21 19.73zM14 7h4V3h-6v5.18l2 2z"
15+
></path>
16+
</svg>
17+
);
18+
}
19+
20+
export default MusicOffIcon;

src/assets/icons/Common/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
export { SearchIcon } from './Search';
22
export { ThreeDIcon } from './3D';
33
export { TwoDIcon } from './2D';
4+
export { default as MusicIcon } from './Music';
5+
export { default as MusicOffIcon } from './MusicOff';
46
export { default as ArrowIcon } from './ArrowIcon';
57
export { default as RobotIcon } from './Robot';
68
export { default as LinkedInIcon } from './LinkedInIcon';

src/screens/articleEditor/AllPlugins.tsx

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
import {
22
toolbarPlugin,
3-
KitchenSinkToolbar,
43
listsPlugin,
54
quotePlugin,
65
headingsPlugin,
76
linkPlugin,
87
linkDialogPlugin,
8+
UndoRedo,
9+
BoldItalicUnderlineToggles,
910
imagePlugin,
1011
tablePlugin,
1112
thematicBreakPlugin,
@@ -16,18 +17,21 @@ import {
1617
markdownShortcutPlugin,
1718
AdmonitionDirectiveDescriptor,
1819
directivesPlugin,
20+
KitchenSinkToolbar,
1921
} from '@mdxeditor/editor';
2022

2123
export const ALL_PLUGINS = [
22-
toolbarPlugin({ toolbarContents: () => <KitchenSinkToolbar /> }),
23-
listsPlugin(),
24-
quotePlugin({
25-
quoteAutocompleteSuggestions: [
26-
'https://via.placeholder.com/150',
27-
'https://via.placeholder.com/150',
28-
],
24+
toolbarPlugin({
25+
toolbarContents: () => (
26+
<>
27+
<UndoRedo />
28+
<BoldItalicUnderlineToggles />
29+
<KitchenSinkToolbar />
30+
</>
31+
),
2932
}),
30-
headingsPlugin({ allowedHeadingLevels: [1, 2, 3] }),
33+
quotePlugin({ quoteTypes: ['blockquote', 'pullquote'], pullquote: true }),
34+
headingsPlugin(),
3135
linkPlugin(),
3236
linkDialogPlugin(),
3337
imagePlugin({
@@ -38,11 +42,15 @@ export const ALL_PLUGINS = [
3842
imageUploadHandler: async () =>
3943
Promise.resolve('https://picsum.photos/200/300'),
4044
}),
45+
listsPlugin({
46+
orderedList: true,
47+
unorderedList: true,
48+
taskList: true,
49+
}),
4150
tablePlugin(),
4251
thematicBreakPlugin(),
4352
frontmatterPlugin(),
44-
codeBlockPlugin({ defaultCodeBlockLanguage: '' }),
45-
// sandpackPlugin({ sandpackConfig: virtuosoSampleSandpackConfig }),
53+
codeBlockPlugin({ defaultCodeBlockLanguage: 'js' }),
4654
codeMirrorPlugin({
4755
codeBlockLanguages: {
4856
js: 'JavaScript',

src/screens/articleEditor/ArticleEditor.tsx

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,21 @@ import '@mdxeditor/editor/style.css';
55
import { useCursor } from '@components';
66
import { useLayoutEffect } from 'react';
77

8+
const MD_Example = `
9+
# Hello world
10+
This is a paragraph
11+
12+
- This is a list
13+
- This is another list
14+
15+
\`\`\`js
16+
console.log('Hello world');
17+
\`\`\`
18+
19+
This is a code block
20+
21+
`;
22+
823
const ArticleEditor = () => {
924
const { setCursorType } = useCursor();
1025
useLayoutEffect(() => {
@@ -15,21 +30,23 @@ const ArticleEditor = () => {
1530
}, [setCursorType]);
1631
return (
1732
<VStack px={10} pt={20} width={'100vw'} rowGap={4} bg={'black'}>
18-
<Input placeholder="Title" />
19-
<Input placeholder="Description" />
33+
<VStack w={'50%'} rowGap={4}>
34+
<Input placeholder="Title" />
35+
<Input placeholder="Subtitle" />
36+
</VStack>
2037
<Box
2138
width={'100%'}
22-
bg={'black'}
2339
border={'1px solid white'}
2440
borderRadius={'md'}
2541
p={2}
42+
className=" min-h-[100vh]"
2643
>
2744
<MDXEditor
28-
className="w-full"
29-
markdown="# Hello world"
45+
className="bg-white"
46+
markdown={MD_Example}
3047
plugins={ALL_PLUGINS}
3148
spellCheck={true}
32-
contentEditableClassName="w-[100%] h-96 text-white"
49+
contentEditableClassName="min-h-[100vh] px-6 py-6 prose"
3350
/>
3451
</Box>
3552
</VStack>

src/screens/articleEditor/darkeditor.css

Lines changed: 0 additions & 64 deletions
This file was deleted.

src/screens/mainFlow/components/SocialNavigation.tsx

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ import {
33
InstagramIcon,
44
LinkedInIcon,
55
MediumIcon,
6+
MusicIcon,
7+
MusicOffIcon,
68
RobotIcon,
79
} from '@assets';
810
import {
@@ -16,7 +18,7 @@ import {
1618
VStack,
1719
} from '@chakra-ui/react';
1820
import { useCursor } from '@components';
19-
import { RefObject, useRef } from 'react';
21+
import { RefObject, useEffect, useRef, useState } from 'react';
2022
import { CharacterType } from '../scene';
2123
import { CONTACT } from '@data';
2224

@@ -39,10 +41,22 @@ const SocialNavigation = ({
3941
handleCharacterClick: (type: CharacterType) => void;
4042
}) => {
4143
const ref = useRef<HTMLDivElement>(null);
44+
const [isPlaying, setIsPlaying] = useState(true);
45+
46+
useEffect(() => {
47+
if (isPlaying) {
48+
document.querySelector('audio')?.play();
49+
} else {
50+
document.querySelector('audio')?.pause();
51+
}
52+
}, [isPlaying]);
53+
4254
const menuButtonRef = useRef<HTMLDivElement>(null);
55+
const musicRef = useRef<HTMLButtonElement>(null);
4356
const { setCursorInsets } = useCursor();
4457
const onMouseEnter =
45-
(ref: RefObject<HTMLDivElement>, radius: string) => () => {
58+
(ref: RefObject<HTMLDivElement | HTMLButtonElement>, radius: string) =>
59+
() => {
4660
const { width, height, top, left } =
4761
ref.current?.getBoundingClientRect() || {
4862
width: 56,
@@ -60,7 +74,34 @@ const SocialNavigation = ({
6074
};
6175

6276
return (
63-
<VStack position={'fixed'} bottom={20} right={14} rowGap={10} zIndex={1}>
77+
<VStack position={'fixed'} bottom={20} right={14} rowGap={6} zIndex={1}>
78+
<IconButton
79+
ref={musicRef}
80+
aria-label={'music'}
81+
borderColor={'gray'}
82+
boxShadow={'0px 0px 10px 3px gray'}
83+
bg={'rgba(255, 255, 255, 0.1)'}
84+
backdropFilter={'blur(20px)'}
85+
transition={'background-color 0.3s'}
86+
padding={2}
87+
borderRadius={'10px'}
88+
icon={
89+
isPlaying ? (
90+
<MusicIcon width={'1.5em'} height={'1.5em'} color="white" />
91+
) : (
92+
<MusicOffIcon width={'1.5em'} height={'1.5em'} color="white" />
93+
)
94+
}
95+
onClick={() => setIsPlaying(!isPlaying)}
96+
onMouseEnter={onMouseEnter(musicRef, '10px')}
97+
onMouseLeave={onMouseLeave}
98+
/>
99+
<audio src="bg.mp3" loop hidden autoPlay>
100+
<p>
101+
If you are reading this, it is because your browser does not support
102+
the audio element.
103+
</p>
104+
</audio>
64105
<Box
65106
ref={menuButtonRef}
66107
zIndex={1}

tailwind.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ module.exports = {
44
theme: {
55
extend: {},
66
},
7-
plugins: [],
7+
plugins: [require('@tailwindcss/typography')],
88
};

0 commit comments

Comments
 (0)