Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add online image to backgrounds #656

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/plugins/backgrounds/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import colour from "./colour";
import giphy from "./giphy";
import gradient from "./gradient";
import image from "./image";
import online from "./online";
import unsplash from "./unsplash";

export const backgroundConfigs = [colour, giphy, gradient, image, unsplash];
export const backgroundConfigs = [colour, giphy, gradient, image, online, unsplash];

backgroundConfigs.sort((a, b) => a.name.localeCompare(b.name));
6 changes: 6 additions & 0 deletions src/plugins/backgrounds/online/Online.sass
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
.Online
background-position: 50% 50%
background-size: cover

&.default
background-color: #212121
19 changes: 19 additions & 0 deletions src/plugins/backgrounds/online/Online.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React from "react";
import Backdrop from "../../../views/shared/Backdrop";
import "./Online.sass";
import { defaultData, Props } from "./types";

const Online: React.FC<Props> = ({ data = defaultData }) => {
const url = data.url;

if (!url) return <div className="Online default fullscreen" />;

return (
<Backdrop
className="Online fullscreen"
style={{ backgroundImage: url ? `url(${url})` : undefined }}
/>
);
};

export default Online;
19 changes: 19 additions & 0 deletions src/plugins/backgrounds/online/OnlineSettings.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React from "react";
import { DebounceInput } from "../../shared";
import { defaultData, Props } from "./types";

const OnlineSettings: React.FC<Props> = ({ data = defaultData, setData }) => (
<div className="OnlineSettings">
<label>
Image URL
<DebounceInput
type="text"
value={data.url}
onChange={(value) => setData({ url: value })}
wait={1000}
/>
</label>
</div>
);

export default OnlineSettings;
14 changes: 14 additions & 0 deletions src/plugins/backgrounds/online/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { Config } from "../../types";
import Online from "./Online";
import OnlineSettings from "./OnlineSettings";

const config: Config = {
key: "background/online",
name: "Online Image",
description: "Show online image",
dashboardComponent: Online,
settingsComponent: OnlineSettings,
supportsBackdrop: true,
};

export default config;
9 changes: 9 additions & 0 deletions src/plugins/backgrounds/online/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { API } from "../../types";

export type Data = {
url?: string;
};

export type Props = API<Data>;

export const defaultData: Data = {};