-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
--------- Co-authored-by: shamoon <[email protected]>
- Loading branch information
1 parent
5512d05
commit ebd384c
Showing
7 changed files
with
111 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,35 @@ | ||
--- | ||
title: iFrame | ||
Description: Add a custom iFrame Widget | ||
--- | ||
|
||
A basic iFrame widget to show external content, see the [MDN docs](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe) for more details about some of the options. | ||
|
||
!!! warning | ||
|
||
Requests made via the iFrame widget are inherently **not proxied** as they are made from the browser itself. | ||
|
||
## Basic Example | ||
|
||
```yaml | ||
widget: | ||
type: iframe | ||
name: myIframe | ||
src: http://example.com | ||
``` | ||
## Full Example | ||
```yaml | ||
widget: | ||
type: iframe | ||
name: myIframe | ||
src: http://example.com | ||
classes: h-60 sm:h-60 md:h-60 lg:h-60 xl:h-60 2xl:h-72 # optional, use tailwind height classes, see https://tailwindcss.com/docs/height | ||
referrerPolicy: same-origin # optional, no default | ||
allowPolicy: autoplay fullscreen gamepad # optional, no default | ||
allowFullscreen: false # optional, default: true | ||
loadingStrategy: eager # optional, default: eager | ||
allowScrolling: no # optional, default: yes | ||
refreshInterval: 2000 # optional, no default | ||
``` |
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
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,50 @@ | ||
import { useState, useEffect } from "react"; | ||
import classNames from "classnames"; | ||
|
||
import Container from "components/services/widget/container"; | ||
|
||
export default function Component({ service }) { | ||
const [refreshTimer, setRefreshTimer] = useState(0); | ||
|
||
const { widget } = service; | ||
|
||
useEffect(() => { | ||
if (widget?.refreshInterval) { | ||
setInterval( | ||
() => setRefreshTimer(refreshTimer + 1), | ||
widget?.refreshInterval < 1000 ? 1000 : widget?.refreshInterval, | ||
); | ||
} | ||
}, [refreshTimer, widget?.refreshInterval]); | ||
|
||
const scrollingDisableStyle = widget?.allowScrolling === "no" ? { pointerEvents: "none", overflow: "hidden" } : {}; | ||
|
||
const classes = widget?.classes || "h-60 sm:h-60 md:h-60 lg:h-60 xl:h-60 2xl:h-72"; | ||
|
||
return ( | ||
<Container service={service}> | ||
<div | ||
className={classNames( | ||
"bg-theme-200/50 dark:bg-theme-900/20 rounded m-1 flex-1 flex flex-col items-center justify-center text-center", | ||
"service-block", | ||
)} | ||
> | ||
<iframe | ||
src={widget?.src} | ||
key={`${widget?.name}-${refreshTimer}`} | ||
name={widget?.name} | ||
title={widget?.name} | ||
allow={widget?.allowPolicy} | ||
allowFullScreen={widget?.allowfullscreen} | ||
referrerPolicy={widget?.referrerPolicy} | ||
loading={widget?.loadingStrategy} | ||
scrolling={widget?.allowScrolling} | ||
style={{ | ||
scrollingDisableStyle, | ||
}} | ||
className={`rounded w-full ${classes}`} | ||
/> | ||
</div> | ||
</Container> | ||
); | ||
} |
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,3 @@ | ||
const widget = {}; | ||
|
||
export default widget; |
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