채지성

sidechat-demo-inner

1 +*{
2 + margin:0%;
3 + padding:0%;
4 +
5 + border-color: black;
6 + border-width: 1px;
7 +}
8 +
1 .SideChat { 9 .SideChat {
2 - color: yellow; 10 + color: black;
3 background-color: gray; 11 background-color: gray;
4 position: absolute; 12 position: absolute;
5 z-index: 999; 13 z-index: 999;
6 - right:100px; 14 + right:3%;
7 - top:0px; 15 + top:0%;
8 transition: 0ms; 16 transition: 0ms;
17 +
18 + width:20%;
19 + min-width: 150px;
20 + max-width: 200px;
21 + height:35%;
22 + min-height: 200px;
23 + max-height: 300px;
24 +
25 + display: grid;
26 + grid-template-rows: 4.3fr 1fr;
27 +
28 + font-size: 90%;
29 +
30 + border-color: black;
31 + border-radius: 5px;
32 +
33 + align-items: center;
34 + justify-items: center;
35 +}
36 +
37 +.SideChat .innerChat1 {
38 + background-color: white;
39 + width: 87%;
40 + height: 90%;
41 + margin-top: 3%;
42 +
43 + vertical-align: bottom;
44 +}
45 +
46 +.SideChat .innerChat2 {
47 + grid-template-rows: 1fr 2fr;
48 + height: 100%;
49 + width: 100%;
50 +
51 + padding-left: 3%;
52 + padding-right: 3%;
53 +}
54 +
55 +.SideChat .innerChat2 .innerBtnCover{
56 + grid-template-columns: 1fr 1.2fr 1fr;
57 + height:30%;
58 + padding-left: 0%;
59 + padding-right: 0%;
60 +}
61 +
62 +.SideChat .innerChat2 .innerBtnCover .innerBtn{
63 + width:33%;
64 + height:100%;
65 + min-height: 20px;
66 + margin-bottom: 4%;
67 +
68 + font-size:70%;
69 + overflow: hidden;
9 } 70 }
10 71
11 .scrollmake{ 72 .scrollmake{
......
...@@ -3,47 +3,71 @@ import axios from "axios"; ...@@ -3,47 +3,71 @@ import axios from "axios";
3 import { useEffect } from 'react'; 3 import { useEffect } from 'react';
4 import './SideChat.css' 4 import './SideChat.css'
5 5
6 -const scrollChat = () => {
7 - let scrollY;
8 -
9 - const sideChat = document.getElementsByClassName('SideChat')[0];
10 -
11 - scrollY = window.scrollY + window.outerHeight / 2;
12 - sideChat.style.top = scrollY +"px";
13 -
14 - document.addEventListener('scroll', ()=>{
15 - sideChat.style.transition = '800ms';
16 - scrollY = window.scrollY + window.outerHeight / 2;
17 - sideChat.style.top = scrollY +"px";
18 6
19 - });
20 -
21 -
22 -}
23 7
24 function SideChat() { 8 function SideChat() {
25 const callApi = async()=>{ 9 const callApi = async()=>{
26 axios.get("/api").then((res)=>{console.log(res.data.test)}); 10 axios.get("/api").then((res)=>{console.log(res.data.test)});
11 +
27 }; 12 };
28 13
29 useEffect(()=>{ 14 useEffect(()=>{
30 callApi(); 15 callApi();
16 + //addChat();
31 scrollChat(); 17 scrollChat();
32 }, []); 18 }, []);
33 19
34 return ( 20 return (
35 <div> 21 <div>
36 - <div className='SideChat' height="100px" width="100px" style={{background:"gray"}}> 22 + <div className='SideChat'>
37 - 하이 23 + <div className='innerChat1'>
38 - 24 +
25 + </div>
26 + <div className='innerChat2'>
27 + <div>
28 + 대기시간
29 + </div>
30 + <div className='innerBtnCover'>
31 + <button className='innerBtn' id='under5'>5 이내</button>
32 + <button className='innerBtn' id='5to10'>5~10</button>
33 + <button className='innerBtn' id='over10'>10 이상</button>
34 + </div>
35 + </div>
39 </div> 36 </div>
40 37
41 -
42 - <div className='scrollmake'>
43 - 바보
44 - </div>
45 </div> 38 </div>
46 ); 39 );
47 } 40 }
48 41
42 +
43 +// <div className='scrollmake'>
44 +// 바보
45 +// </div>
46 +
47 +
48 +const scrollChat = () => {
49 + let scrollY;
50 +
51 + const sideChat = document.getElementsByClassName('SideChat')[0];
52 +
53 + scrollY = window.scrollY + document.body.scrollHeight / 5 - 50;
54 + sideChat.style.top = scrollY +"px";
55 +
56 + const reposition = ()=>{ // 화면 크기 바뀔때도 이래야함--> 추후수정
57 + sideChat.style.transition = '800ms';
58 + scrollY = window.scrollY + document.body.scrollHeight / 5 - 50;
59 + sideChat.style.top = scrollY +"px";
60 + }
61 +
62 + document.addEventListener('scroll', reposition);
63 + document.addEventListener('resize', reposition);
64 +
65 +
66 +}
67 +
68 +// 각 버튼마다 서버에 알맞은 요청 전송
69 +// 받아온 응답을 배열에 넣기 --> 채팅창은 한정되어있으므로 배열 크기는 한정
70 +// 응답은 {id, 대기시간, 현재시간}을 모아놓은 배열로
71 +// innerChat1은 아래쪽 정렬
72 +
49 export default SideChat; 73 export default SideChat;
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -15,16 +15,16 @@ function TopBanner() { ...@@ -15,16 +15,16 @@ function TopBanner() {
15 15
16 return ( 16 return (
17 17
18 - <Navbar bg="#ff0000" expand="lg" style={{ background:'#9E1915'}} > 18 + <Navbar bg="#ff0000" expand="lg" style={{ background:'#9E1915', padding:'0%', margin:'0 auto'}} >
19 - <Container> 19 + <Container style={{margin:'0 auto'}}>
20 <img src = {khuimg} height="40px" width="40px" /> 20 <img src = {khuimg} height="40px" width="40px" />
21 - <Navbar.Brand href="#home">2 학식 커뮤니티</Navbar.Brand> 21 + <Navbar.Brand href="#home"><p style={{color:'white'}}>2 학식 커뮤니티</p></Navbar.Brand>
22 <Navbar.Toggle aria-controls="basic-navbar-nav" /> 22 <Navbar.Toggle aria-controls="basic-navbar-nav" />
23 <Navbar.Collapse id="basic-navbar-nav"> 23 <Navbar.Collapse id="basic-navbar-nav">
24 <Nav className="me-auto"> 24 <Nav className="me-auto">
25 - <Nav.Link href="#home">메뉴</Nav.Link> 25 + <Nav.Link href="#home"><p style={{color:'white'}}>메뉴</p></Nav.Link>
26 - <Nav.Link href="#link">메뉴에 대한 이야기</Nav.Link> 26 + <Nav.Link href="#link"><p style={{color:'white'}}>메뉴에 대한 이야기</p></Nav.Link>
27 - <Nav.Link href="#link"> 작성</Nav.Link> 27 + <Nav.Link href="#link"><p style={{color:'white'}}> 작성</p></Nav.Link>
28 </Nav> 28 </Nav>
29 </Navbar.Collapse> 29 </Navbar.Collapse>
30 </Container> 30 </Container>
......
...@@ -9,7 +9,7 @@ import 'bootstrap/dist/css/bootstrap.min.css'; ...@@ -9,7 +9,7 @@ import 'bootstrap/dist/css/bootstrap.min.css';
9 const root = ReactDOM.createRoot(document.getElementById('root')); 9 const root = ReactDOM.createRoot(document.getElementById('root'));
10 root.render( 10 root.render(
11 <React.StrictMode> 11 <React.StrictMode>
12 - <div className='Screen' style={{width: '100vw', height:'100vh' }}> 12 + <div className='Screen' style={{width: '100vw', height:'100vh', margin:'0%', padding:'0%', }}>
13 <TopBanner /> 13 <TopBanner />
14 <SideChat /> 14 <SideChat />
15 </div> 15 </div>
......