diff --git a/src/index.css b/src/index.css index 407252ce4ca09c2f30d0cca2b94cbbe1c08e52d6..5e2d30bacbfbe4a82ff7fad5d494346b48e9f7bb 100644 --- a/src/index.css +++ b/src/index.css @@ -8,3 +8,7 @@ grid-template-rows: repeat(auto-fill, 45px); grid-gap: 30px; } + +.bg-lower-gradient { + background-image: linear-gradient(180deg, rgba(24, 24, 27, 0) 0%, rgba(24, 24, 27, 0.70) 60%, rgba(24, 24, 27, 1.00) 100%) +} diff --git a/src/panels/Bild.tsx b/src/panels/Bild.tsx new file mode 100644 index 0000000000000000000000000000000000000000..ae0b93741af55295e80ccf661a8ca5a13a0a8810 --- /dev/null +++ b/src/panels/Bild.tsx @@ -0,0 +1,56 @@ +import React from 'react'; +import PanelWrapper from "../meta/PanelWrapper"; +import classNames from "../util/classNames"; +import PanelContent from "../meta/PanelContent"; + +export type BildPanelDefinition = { + url: string, + fit?: "fill" | "fit", + title?: string, + description?: string +} + +const BildPanel = (props: {definition: BildPanelDefinition}) => { + return ( + <PanelWrapper className={"relative"}> + <div + className={"absolute inset-0 h-full w-full bg-cover blur-lg backdrop-brightness-75"} + style={{backgroundImage: `url('${props.definition.url}')`}} + > + </div> + + <div className={"absolute inset-0 h-full w-full flex"}> + <div + className={classNames( + "bg-no-repeat bg-center flex-1 relative", + (props.definition.fit === "fit") ? "bg-contain" : "bg-cover" + )} + style={{ + backgroundImage: `url('${props.definition.url}')` + }} + > + {props.definition.title && ( + <> + <div className={"absolute inset-0 w-full h-full bg-lower-gradient"}> + </div> + + <PanelContent className={"absolute inset-0 w-full h-full flex flex-col justify-end"}> + <h2 className={"text-xl font-semibold"}> + {props.definition.title} + </h2> + + {props.definition.description && ( + <p className={"pr-6 leading-tight mt-1"}> + {props.definition.description} + </p> + )} + </PanelContent> + </> + )} + </div> + </div> + </PanelWrapper> + ); +}; + +export default BildPanel; diff --git a/src/panels/_Panels.tsx b/src/panels/_Panels.tsx index 386d19f1218e5a05385b50c2391a2488d080b0df..d5db7ec75ccefb38908d2c70dae1de771feaf092 100644 --- a/src/panels/_Panels.tsx +++ b/src/panels/_Panels.tsx @@ -6,13 +6,14 @@ import React from "react"; import FahrplanPanel from "./Fahrplan/FahrplanPanel"; import {PanelDefinition} from "../types/LayoutConfig"; +import BildPanel from "./Bild"; /* * First, please claim a unique id for your panel here. Convention is that it is all lowercase, in snake-case to be * precise. So if you want to call your panel "My awesome Panel", please claim "my-awesome-panel". Add it by adding * `| "my-awesome-panel"` before the semicolon in the type below this comment. */ -export type PanelTypes = "fahrplan"; +export type PanelTypes = "fahrplan" | "bild"; /* * Next, add your renderer. You'll get the definition that was written in the layout config as a prop. If you'd like to @@ -21,15 +22,7 @@ export type PanelTypes = "fahrplan"; */ export const PanelRenderers: {[panelType: string]: React.FC<any & {definition: PanelDefinition<any>}>} = { "fahrplan": FahrplanPanel, - "test": () => ( - <h1>Test!</h1> - ), - "demo": () => ( - <p>Demo!</p> - ), - "foobar": () => ( - <p>FooBar!</p> - ) + "bild": BildPanel };