Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -10,46 +10,84 @@ def display_html(html_code):
|
|
| 10 |
</div>
|
| 11 |
"""
|
| 12 |
|
| 13 |
-
#
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
).set(
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
|
|
|
| 27 |
block_background_fill="white",
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
|
| 32 |
)
|
| 33 |
|
| 34 |
|
| 35 |
-
|
|
|
|
| 36 |
gr.Markdown(
|
| 37 |
"""
|
| 38 |
# HTML Viewer
|
| 39 |
|
| 40 |
入力されたHTMLコードを、プレビュー表示します。
|
| 41 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
""")
|
| 43 |
with gr.Row():
|
| 44 |
-
|
| 45 |
with gr.Column(scale=1):
|
| 46 |
-
|
| 47 |
input_textbox = gr.Textbox(
|
| 48 |
label="HTMLコードを入力",
|
| 49 |
placeholder="ここにHTMLコードを貼り付けてください...",
|
| 50 |
lines=10
|
| 51 |
)
|
| 52 |
-
submit_button = gr.Button("表示")
|
| 53 |
with gr.Column(scale=3):
|
| 54 |
output_html = gr.HTML(label="プレビュー",)
|
| 55 |
|
|
@@ -58,6 +96,7 @@ with gr.Blocks(theme=theme, title="HTML Viewer") as demo: #themeを指定
|
|
| 58 |
inputs=input_textbox,
|
| 59 |
outputs=output_html
|
| 60 |
)
|
|
|
|
| 61 |
#サンプル
|
| 62 |
gr.Examples(
|
| 63 |
[["<h1>Hello world</h1>"],["""
|
|
|
|
| 10 |
</div>
|
| 11 |
"""
|
| 12 |
|
| 13 |
+
# カスタムテーマ (大幅改良)
|
| 14 |
+
theme = gr.themes.Default(
|
| 15 |
+
primary_hue=gr.themes.colors.indigo, # メインカラーを洗練されたインディゴに
|
| 16 |
+
secondary_hue=gr.themes.colors.blue,
|
| 17 |
+
neutral_hue=gr.themes.colors.gray,
|
| 18 |
+
font=[gr.themes.GoogleFont('Inter'), 'ui-sans-serif', 'system-ui', 'sans-serif'], # モダンなフォント
|
|
|
|
| 19 |
).set(
|
| 20 |
+
# 全体的なスタイルの微調整
|
| 21 |
+
body_background_fill="linear-gradient(to bottom right, #f5f5f5, #e0e7ff)", # 美しいグラデーション背景
|
| 22 |
+
body_text_color="rgba(0, 0, 0, 0.8)", # ほんのり透明感のある黒
|
| 23 |
+
body_text_size="*text_md",
|
| 24 |
+
body_text_color_subdued="rgba(0, 0, 0, 0.6)",
|
| 25 |
+
|
| 26 |
+
# ブロック要素のスタイル
|
| 27 |
block_background_fill="white",
|
| 28 |
+
block_border_color="rgba(0, 0, 0, 0.1)", # 非常に薄い境界線
|
| 29 |
+
block_border_width="1px",
|
| 30 |
+
block_border_radius="*radius_lg", # 大きめの角丸
|
| 31 |
+
block_title_text_weight="600",
|
| 32 |
+
block_label_background_fill="rgba(0, 0, 0, 0.04)", #ラベルの背景色
|
| 33 |
+
block_label_text_color="*primary_500", #ラベルの色
|
| 34 |
+
block_label_text_size="*text_sm",
|
| 35 |
+
block_label_margin="0.5rem",
|
| 36 |
+
|
| 37 |
+
# ボタンのスタイル
|
| 38 |
+
button_primary_background_fill="*primary_500", #ボタンの背景色
|
| 39 |
+
button_primary_background_fill_hover="*primary_600",
|
| 40 |
+
button_primary_text_color="white",
|
| 41 |
+
button_primary_border_radius="*radius_lg",
|
| 42 |
+
button_secondary_background_fill="white",
|
| 43 |
+
button_secondary_border_color="*primary_500",
|
| 44 |
+
button_secondary_text_color="*primary_500",
|
| 45 |
+
# 影
|
| 46 |
+
button_shadow="*shadow_drop_lg",
|
| 47 |
+
button_shadow_hover="*shadow_drop_lg",
|
| 48 |
+
|
| 49 |
+
# テキストボックス
|
| 50 |
+
input_background_fill="#f9fafb",
|
| 51 |
+
input_border_color="rgba(0, 0, 0, 0.2)",
|
| 52 |
+
input_border_width="1px",
|
| 53 |
+
input_text_size="*text_md",
|
| 54 |
+
input_placeholder_color="rgba(0, 0, 0, 0.4)",
|
| 55 |
+
|
| 56 |
+
# その他
|
| 57 |
+
background_fill_secondary="white", #背景色
|
| 58 |
+
border_color_accent="*primary_500",
|
| 59 |
+
border_color_primary="rgba(0, 0, 0, 0.2)",
|
| 60 |
+
|
| 61 |
+
#リンクの色
|
| 62 |
+
link_text_color = "*secondary_500",
|
| 63 |
+
link_hover_color = "*secondary_600",
|
| 64 |
+
link_visited_color = "*secondary_700",
|
| 65 |
+
|
| 66 |
|
| 67 |
)
|
| 68 |
|
| 69 |
|
| 70 |
+
|
| 71 |
+
with gr.Blocks(theme=theme, title="HTML Viewer") as demo:
|
| 72 |
gr.Markdown(
|
| 73 |
"""
|
| 74 |
# HTML Viewer
|
| 75 |
|
| 76 |
入力されたHTMLコードを、プレビュー表示します。
|
| 77 |
|
| 78 |
+
* 横スクロール禁止、縦スクロール許可
|
| 79 |
+
* レスポンシブデザイン (Gradio デフォルト)
|
| 80 |
+
* スマホでの表示は、PC版を縮小したようなイメージ
|
| 81 |
+
* インターコンチネンタル石垣島のクラブラウンジ風の、白く爽やかな外観(インディゴブルーでスタイリッシュに)
|
| 82 |
""")
|
| 83 |
with gr.Row():
|
|
|
|
| 84 |
with gr.Column(scale=1):
|
|
|
|
| 85 |
input_textbox = gr.Textbox(
|
| 86 |
label="HTMLコードを入力",
|
| 87 |
placeholder="ここにHTMLコードを貼り付けてください...",
|
| 88 |
lines=10
|
| 89 |
)
|
| 90 |
+
submit_button = gr.Button("表示", variant="primary") # プライマリボタンに
|
| 91 |
with gr.Column(scale=3):
|
| 92 |
output_html = gr.HTML(label="プレビュー",)
|
| 93 |
|
|
|
|
| 96 |
inputs=input_textbox,
|
| 97 |
outputs=output_html
|
| 98 |
)
|
| 99 |
+
|
| 100 |
#サンプル
|
| 101 |
gr.Examples(
|
| 102 |
[["<h1>Hello world</h1>"],["""
|