-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
285 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
.main { | ||
margin: 10px; | ||
.body { | ||
padding: 10px; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
.input { | ||
border: 1px solid #999999; | ||
height: 40px; | ||
box-sizing: border-box; | ||
padding: 1px 10px; | ||
outline: none; | ||
transition: 0.2s ease-in-out; | ||
width: 100%; | ||
border-radius: 20px; | ||
margin-bottom: 5px; | ||
} | ||
|
||
.input:focus { | ||
transition: 0.2s ease-in-out; | ||
border: 1px solid #1fdf64; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
.header { | ||
display: table; | ||
width: 100%; | ||
background-color: #1fdf64; | ||
padding: 5px 10px 5px 10px; | ||
margin: 0; | ||
} | ||
|
||
.header div { | ||
display: table-row; | ||
} | ||
|
||
.header div div { | ||
display: table-cell; | ||
width: auto; | ||
} | ||
|
||
.header .icon { | ||
width: 25px; | ||
height: 25px; | ||
vertical-align: middle; | ||
display: inline-block; | ||
} | ||
|
||
.header .title { | ||
width: 100%; | ||
padding: 0 20px 0 20px; | ||
vertical-align: middle; | ||
display: inline-block; | ||
} | ||
|
||
.header button { | ||
width: 100px; | ||
vertical-align: middle; | ||
display: inline-block; | ||
} | ||
|
||
.modal { | ||
width: 90%; | ||
height: 90%; | ||
margin: 2% 5% 5% 5%; | ||
border-width: 1px; | ||
border-color: black; | ||
padding: 10px; | ||
border-radius: 20px; | ||
} | ||
|
||
.modal::backdrop { | ||
background: rgba(0, 0, 0, 0.6); | ||
backdrop-filter: blur(10px); | ||
} | ||
|
||
.modal_header { | ||
width: 100%; | ||
display: table; | ||
padding-bottom: 10px; | ||
} | ||
|
||
.modal_header div { | ||
display: table-cell; | ||
width: auto; | ||
} | ||
|
||
.modal_header h1 { | ||
width: 100%; | ||
vertical-align: middle; | ||
display: inline-block; | ||
} | ||
|
||
.modal_header button { | ||
width: 25px; | ||
height: 25px; | ||
vertical-align: middle; | ||
display: inline-block; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
"use client"; | ||
import { | ||
useRef, | ||
useEffect, | ||
useState, | ||
DispatchWithoutAction, | ||
ReactNode, | ||
MouseEvent, | ||
} from "react"; | ||
import Image from "next/image"; | ||
import styles from "./titlebar.module.css"; | ||
import Search from "./search"; | ||
|
||
interface Props { | ||
title: string | undefined; | ||
children: ReactNode; | ||
isOpen: boolean; | ||
handleClose: DispatchWithoutAction; | ||
} | ||
|
||
function Modal({ title, children, isOpen, handleClose }: Props) { | ||
const dialogRef = useRef<HTMLDialogElement>(null); | ||
|
||
const close = () => { | ||
dialogRef.current?.close(); | ||
}; | ||
|
||
function handleClickOutside(event: MouseEvent) { | ||
if (!dialogRef.current) { | ||
return; | ||
} | ||
|
||
const box = dialogRef.current?.getBoundingClientRect(); | ||
if ( | ||
event.pageX < box.left || | ||
event.pageX > box.right || | ||
event.pageY < box.top + window.scrollY || | ||
event.pageY > box.bottom + window.scrollY | ||
) { | ||
close(); | ||
} | ||
} | ||
|
||
useEffect(() => { | ||
const dialog = dialogRef.current; | ||
if (isOpen && !dialogRef.current?.open) { | ||
dialog?.showModal(); | ||
document.body.style.overflow = "hidden"; | ||
} else { | ||
dialog?.close(); | ||
document.body.style.overflow = ""; | ||
} | ||
}, [isOpen]); | ||
|
||
return ( | ||
<dialog | ||
className={styles.modal} | ||
ref={dialogRef} | ||
onClose={handleClose} | ||
onClick={handleClickOutside} | ||
> | ||
<div className={styles.modal_header}> | ||
<div style={{ width: "100%" }}> | ||
<h1>{title}</h1> | ||
</div> | ||
<div style={{ width: "25px" }}> | ||
<button type="button" onClick={close} title="close"> | ||
╳ | ||
</button> | ||
</div> | ||
</div> | ||
{children} | ||
</dialog> | ||
); | ||
} | ||
|
||
export default function TitleBar() { | ||
const [isOpen, setIsOpen] = useState(false); | ||
const showSongModel = () => { | ||
setIsOpen(true); | ||
}; | ||
const hideSongModel = () => { | ||
setIsOpen(false); | ||
}; | ||
|
||
return ( | ||
<div style={{ width: "100%" }}> | ||
<header className={styles.header}> | ||
<div> | ||
<div style={{ width: "25px" }}> | ||
<Image | ||
alt="icon" | ||
className={styles.icon} | ||
src="/favicon.ico" | ||
width={50} | ||
height={50} | ||
></Image> | ||
</div> | ||
<div style={{ width: "100%" }}> | ||
<h2 className={styles.title}>Spotify collab</h2> | ||
</div> | ||
<div style={{ width: "100px" }}> | ||
<button onClick={showSongModel}>+ Add a song</button> | ||
</div> | ||
</div> | ||
</header> | ||
<Modal title="Add a song" isOpen={isOpen} handleClose={hideSongModel}> | ||
<Search /> | ||
</Modal> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.