Skip to content

Commit

Permalink
Merge pull request #197 from Narastro/feat/tadak-room-fix
Browse files Browse the repository at this point in the history
폰트 파일 로딩 버벅임 감소를 위한 작업
  • Loading branch information
Narastro authored Nov 18, 2021
2 parents 5b9a8ef + a11f1d0 commit 479d3e7
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 14 deletions.
3 changes: 0 additions & 3 deletions client/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,4 @@
<body>
<div id="root"></div>
</body>
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link href="https://fonts.googleapis.com/css2?family=Dongle:wght@400;700&display=swap" rel="stylesheet" />
</html>
1 change: 1 addition & 0 deletions client/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import './styles/fonts.css';
import { useCallback, useEffect } from 'react';
import { BrowserRouter, Route, Redirect, Switch } from 'react-router-dom';
import GlobalStyles from './styles/GlobalStyles';
Expand Down
30 changes: 22 additions & 8 deletions client/src/components/VideoBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
} from 'agora-rtc-react';
import styled from 'styled-components';
import defaultImage from '@assets/default-avatar.jpeg';
import { useEffect, useState } from 'react';
import { useEffect, useState, useRef, useCallback } from 'react';

const VIDEO_WIDTH = 30;
const VIDEO_HEIGHT = 20;
Expand All @@ -31,11 +31,11 @@ const VolumeVisualizer = styled.div`
height: ${VIDEO_HEIGHT}rem;
position: absolute;
right: 0;
border: 3px solid ${({ theme }) => theme.colors.primary};
border: 3px solid ${({ theme }) => theme.colors.blue};
border-radius: ${BORDER_RADIUS};
`;

const SPEAK_VOLUME = 0.1;
const SPEAK_VOLUME = 0.2;
const VOLUME_VISUAL_TIME = 1000;

interface VideoBoxProps {
Expand All @@ -45,13 +45,27 @@ interface VideoBoxProps {

const VideoBox = ({ videoTrack, audioTrack }: VideoBoxProps): JSX.Element => {
const [isSpeak, setIsSpeak] = useState(false);
const isInterval = useRef(false);

const initInterval = useCallback(
function () {
if (!isInterval.current) {
setInterval(() => {
if (audioTrack) {
setIsSpeak(audioTrack?.getVolumeLevel() > SPEAK_VOLUME);
}
}, VOLUME_VISUAL_TIME);
}
isInterval.current = true;
},
[isInterval, audioTrack],
);

useEffect(() => {
if (audioTrack)
setInterval(() => {
setIsSpeak(audioTrack?.getVolumeLevel() > SPEAK_VOLUME);
}, VOLUME_VISUAL_TIME);
}, [audioTrack]);
if (audioTrack) {
initInterval();
}
}, [audioTrack, initInterval]);

return (
<VideoWrap>
Expand Down
4 changes: 2 additions & 2 deletions client/src/pages/Introduction/Introduction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ const IntroContainer = styled.div<IntroContainerProps>`
`}
transition: background-color 1500ms linear;
padding: ${({ theme }) => theme.paddings.base};
font-family: 'Dongle', sans-serif;
font-family: 'Dongle';
`;

const IntroTitle = styled.div`
z-index: 2;
color: white;
font-size: 200px;
font-size: 250px;
`;
const IntroDescription = styled.div`
z-index: 2;
Expand Down
1 change: 1 addition & 0 deletions client/src/pages/Room/style.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ export const RoomWrapper = styled.div`

export const RoomContainer = styled.div`
height: 100%;
width: 100%;
padding: ${({ theme }) => theme.paddings.lg};
`;
2 changes: 1 addition & 1 deletion client/src/styles/GlobalStyles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const GlobalStyles = createGlobalStyle`
font-size : 62.5%; // 1rem === 10px
}
body {
font-family: 'Dongle', sans-serif;
font-family: 'Dongle';
}
a {
text-decoration: none;
Expand Down
7 changes: 7 additions & 0 deletions client/src/styles/fonts.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
@font-face {
font-family: 'Dongle';
font-style: normal;
font-weight: 700;
src: url('./fonts/dongle-v4-korean-700.woff2') format('woff2'),
url('./fonts/dongle-v4-korean-700.woff') format('woff');
} ;
Binary file not shown.
Binary file not shown.

0 comments on commit 479d3e7

Please sign in to comment.