diff --git a/build/lib/gradio/static/css/gradio.css b/build/lib/gradio/static/css/gradio.css index 872608f9f9..f5f39cb8a8 100644 --- a/build/lib/gradio/static/css/gradio.css +++ b/build/lib/gradio/static/css/gradio.css @@ -3,10 +3,15 @@ flex: 1 1 0; display: inline-block; box-sizing: border-box; - margin: 0 30px 14px 0; +} +.panel:first-child { + margin-right: 24px; +} +.panel:last-child { + margin-left: 8px; } .panel_header, .interface { - background-color: #EEEEEE; + background-color: whitesmoke; } .panel_header { text-transform: uppercase; @@ -31,7 +36,6 @@ } .loading img { display: none; - height: 18px; } .panel_buttons { display: flex; @@ -44,7 +48,7 @@ display: none; } .submit, .clear, .panel_button { - background-color: #EEEEEE !important; + background-color: whitesmoke !important; flex-grow: 1; padding: 8px !important; box-sizing: border-box; @@ -62,7 +66,7 @@ } .flag_message { padding: 8px !important; - background-color: #EEEEEE !important; + background-color: whitesmoke !important; } .upload_zone { @@ -111,7 +115,7 @@ .flag.flagged { background-color: pink !important; } -#loading { +.loading { justify-content: center; align-items: center; } diff --git a/build/lib/gradio/static/css/interfaces/input/csv.css b/build/lib/gradio/static/css/interfaces/input/csv.css index e186abab65..afbc4e6ff6 100644 --- a/build/lib/gradio/static/css/interfaces/input/csv.css +++ b/build/lib/gradio/static/css/interfaces/input/csv.css @@ -22,5 +22,5 @@ padding: 2px 4px; } .csv_preview td:nth-child(even) { - background-color: #EEEEEE; + background-color: whitesmoke; } diff --git a/build/lib/gradio/static/css/style.css b/build/lib/gradio/static/css/style.css index cc33f6d1aa..ce100507eb 100644 --- a/build/lib/gradio/static/css/style.css +++ b/build/lib/gradio/static/css/style.css @@ -14,9 +14,6 @@ button, input[type="submit"], input[type="reset"], input[type="text"], input[typ -webkit-appearance: none; border-radius: 0; } -nav, #panels, #share_row { - margin-left: 30px; -} nav { text-align: center; padding: 16px 0 4px; @@ -48,11 +45,14 @@ nav img { #share_row, #share_complete, #share_form { display: none; } -#panels { +.panels { display: flex; flex-flow: row; flex-wrap: wrap; justify-content: center; + max-width: 1028px; + width: 100%; + margin: 0 auto; } button.primary { color: white; @@ -67,7 +67,7 @@ button.secondary { } #featured_table { border-collapse: collapse; - border: solid 2px #EEEEEE; + border: solid 2px whitesmoke; margin-bottom: 20px; table-layout: fixed; } @@ -81,7 +81,7 @@ button.secondary { overflow-y: auto; } #featured_table div:nth-child(even) { - background-color: #EEEEEE; + background-color: whitesmoke; } #featured_table div:hover { background-color: #EEA45D; diff --git a/build/lib/gradio/static/js/all_io.js b/build/lib/gradio/static/js/all_io.js index 31212910b6..aff7a19430 100644 --- a/build/lib/gradio/static/js/all_io.js +++ b/build/lib/gradio/static/js/all_io.js @@ -1,4 +1,4 @@ -var io_master = { +var io_master_template = { gather: function() { this.clear(); for (let iface of this.input_interfaces) { @@ -17,45 +17,32 @@ var io_master = { } }, submit: function() { - var post_data = { - 'data': this.last_input - }; - if (!config.live) { - $("#loading").removeClass("invisible"); - $("#loading_in_progress").show(); - $("#loading_failed").hide(); - $(".output_interface").addClass("invisible"); + let io = this; + if (!this.config.live) { + this.target.find(".loading").removeClass("invisible"); + this.target.find(".loading_in_progress").show(); + this.target.find(".loading_failed").hide(); + this.target.find(".output_interface").addClass("invisible"); + this.target.find(".output_interfaces .panel_header").addClass("invisible"); } - $.ajax({type: "POST", - url: "/api/predict/", - data: JSON.stringify(post_data), - success: function(output){ - if (output['action'] == 'output') { - io_master.output(output); - } - }, - error: function(XMLHttpRequest, textStatus, errorThrown) { - $("#loading_in_progress").hide(); - $("#loading_failed").show(); - console.log(XMLHttpRequest); - console.log(textStatus); - console.log(errorThrown); - } - }); + this.fn(this.last_input).then((output) => { + io.output(output); + }).catch(() => { + this.target.find(".loading_in_progress").hide(); + this.target.find(".loading_failed").show(); + }) }, output: function(data) { this.last_output = data["data"]; for (let i = 0; i < this.output_interfaces.length; i++) { this.output_interfaces[i].output(data["data"][i]); } - // if (this.input_interface.output && data["saliency"]) { - // this.input_interface.output(data["saliency"]); - // } - if (config.live) { + if (this.config.live) { this.gather(); } else { - $("#loading").addClass("invisible"); - $(".output_interface").removeClass("invisible"); + this.target.find(".loading").addClass("invisible"); + this.target.find(".output_interface").removeClass("invisible"); + this.target.find(".output_interfaces .panel_header").removeClass("invisible"); } }, flag: function(message) { diff --git a/build/lib/gradio/static/js/gradio.js b/build/lib/gradio/static/js/gradio.js new file mode 100644 index 0000000000..16e0d9d5e8 --- /dev/null +++ b/build/lib/gradio/static/js/gradio.js @@ -0,0 +1,130 @@ +function gradio(config, fn, target) { + target = $(target); + target.html(` +