Combines 2 PRs for testing (#1540)

* mount custom css to the web component (#1536)

* set configurable min height prior to loading (#1532)

* set configurable minheight prio to loading

* formatting

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>

* release beta version for testing (#1541)

Co-authored-by: pngwn <hello@pngwn.io>
This commit is contained in:
Abubakar Abid 2022-06-10 20:11:40 -07:00 committed by GitHub
parent 00e4b1436f
commit cf027b68f4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 54 additions and 6 deletions

View File

@ -1 +1 @@
3.0.10b16
3.0.13b13

View File

@ -20,7 +20,46 @@
<title>Vite App</title>
</head>
<body>
<gradio-app space="nateraw/animegan-v2-for-videos"></gradio-app>
<gradio-app space="gradio/Echocardiogram-Segmentation"></gradio-app>
<h1>Hello title</h1>
<h2>hello subtitle</h2>
<p>
Hello text. Hello text. Hello text. Hello text. Hello text. Hello text.
Hello text. Hello text. Hello text. Hello text. Hello text. Hello text.
Hello text. Hello text.
</p>
<p>
Hello text. Hello text. Hello text. Hello text. Hello text. Hello text.
Hello text. Hello text. Hello text. Hello text. Hello text. Hello text.
Hello text. Hello text.
</p>
<p>
Hello text. Hello text. Hello text. Hello text. Hello text. Hello text.
Hello text. Hello text. Hello text. Hello text. Hello text. Hello text.
Hello text. Hello text.
</p>
<gradio-app
space="nateraw/animegan-v2-for-videos"
initial_height="800px"
></gradio-app>
<h2>hello subtitle</h2>
<p>
Hello text. Hello text. Hello text. Hello text. Hello text. Hello text.
Hello text. Hello text. Hello text. Hello text. Hello text. Hello text.
Hello text. Hello text.
</p>
<p>
Hello text. Hello text. Hello text. Hello text. Hello text. Hello text.
Hello text. Hello text. Hello text. Hello text. Hello text. Hello text.
Hello text. Hello text.
</p>
<p>
Hello text. Hello text. Hello text. Hello text. Hello text. Hello text.
Hello text. Hello text. Hello text. Hello text. Hello text. Hello text.
Hello text. Hello text.
</p>
<gradio-app
space="gradio/Echocardiogram-Segmentation"
initial_height="400px"
></gradio-app>
</body>
</html>

View File

@ -102,16 +102,21 @@ async function get_config(space_id: string | null) {
}
}
function mount_css(
url: string,
function mount_custom_css(
target: ShadowRoot | HTMLElement,
css_string?: string
): Promise<void> {
) {
if (css_string) {
let style = document.createElement("style");
style.innerHTML = css_string;
target.appendChild(style);
}
}
function mount_css(
url: string,
target: ShadowRoot | HTMLElement
): Promise<void> {
if (BUILD_MODE === "dev") Promise.resolve();
const link = document.createElement("link");
@ -137,6 +142,8 @@ async function handle_config(
mount_css(ENTRY_CSS, target)
]);
mount_custom_css(target, config.css);
if (config.dev_mode) {
reload_check(config.root);
}
@ -219,6 +226,8 @@ function create_custom_element() {
async connectedCallback() {
const space = this.getAttribute("space");
const initial_height = this.getAttribute("initial_height");
this.wrapper.style.minHeight = initial_height || "300px";
const config = await handle_config(this.root, space);
mount_app(config, this.root, this.wrapper, this._id);