Skip to content

Commit

Permalink
add link popup
Browse files Browse the repository at this point in the history
  • Loading branch information
stCarolas committed Mar 21, 2024
1 parent 1c6eb93 commit fc1fc5e
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 15 deletions.
16 changes: 11 additions & 5 deletions src/components/MediaWidget/MediaWidget.css
Original file line number Diff line number Diff line change
Expand Up @@ -82,15 +82,21 @@

.link-popup {
position: absolute;
width: 90%;
min-height: 30px;
background-color: white;
width: 100%;
height: 100%;
bottom: 0px;
background: rgba(30, 30, 30, 0.9);
z-index: 3;
display: flex;
flex-wrap: wrap;
flex-direction: column;
justify-content: center;
align-items: center;
}

.link-popup input {
position: absolute;
top: 50%;
width: 100%;
width: 98%;
}

.item-buttons {
Expand Down
25 changes: 17 additions & 8 deletions src/components/MediaWidget/PlaylistComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import { Song } from "./types";
import { WidgetData } from "../../types/WidgetData";

export default function PlaylistComponent({
playlist
playlist,
}: {
playlist: Playlist
playlist: Playlist;
}) {
const { settings, widgetId } = useLoaderData() as WidgetData;
const activeRef = useRef<HTMLDivElement>(null);
const [current, setCurrent] = useState<number|null>(null);
const [current, setCurrent] = useState<number | null>(null);
const [songs, setSongs] = useState<Song[]>([]);
const [urlToCopy, setUrlToCopy] = useState<string>("");

Expand All @@ -36,13 +36,13 @@ export default function PlaylistComponent({
useEffect(() => {
playlist.addListener({
id: `${widgetId}_playlist`,
trigger(playlist: Playlist){
trigger(playlist: Playlist) {
setSongs(playlist.songs());
setCurrent(playlist.index());
}
},
});
// todo cleanup function
},[playlist]);
}, [playlist]);

useEffect(() => {
if (activeRef.current) {
Expand Down Expand Up @@ -96,7 +96,7 @@ export default function PlaylistComponent({
<button
className="btn btn-outline-light play"
onClick={() => {
const id = playlist.song()?.id
const id = playlist.song()?.id;
if (id) {
playlist.markListened(id);
}
Expand All @@ -110,7 +110,7 @@ export default function PlaylistComponent({
<button
className="btn btn-outline-light share"
onClick={() => {
navigator.clipboard.writeText(song.src)
navigator.clipboard.writeText(song.src);
setUrlToCopy(song.src);
}}
>
Expand Down Expand Up @@ -167,6 +167,15 @@ export default function PlaylistComponent({
<span className="material-symbols-sharp">add</span>
</button>
</div>
<div className={`link-popup ${urlToCopy ? "" : "hidden"}`}>
<input value={urlToCopy} />
<button
id="close-add-media-popup"
onClick={() => setUrlToCopy("")}
>
<span className="material-symbols-sharp">close</span>
</button>
</div>
<AddMediaPopup playlist={playlist} />
</div>
)}
Expand Down
4 changes: 2 additions & 2 deletions src/components/Tabs/Tabs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default function Tabs({

useEffect(() => {
const settings = config.get(widgetId);
log.debug({settings: settings},"trying to find first tab");
log.debug({ settings: settings }, "trying to find first tab");
if (!settings) {
return;
}
Expand All @@ -25,7 +25,7 @@ export default function Tabs({
onChange(firstTab.value);
setTab(firstTab.value);
}
},[config]);
}, [config]);

const tabs = () => {
const settings = config.get(widgetId);
Expand Down

0 comments on commit fc1fc5e

Please sign in to comment.