Spaces:
Running
Running
CraterView.ai
Leave room above the headline for the badge on a page opened at its own address
8f81c4b Download theme.py from craterviewai/denoise: direct link, hf CLI and curl.
- Browser
- Download file 8.96 kB
-
https://huggingface.co/spaces/craterviewai/denoise/resolve/main/theme.py
- Command line
-
hf download hf://spaces/craterviewai/denoise/theme.py
-
curl -L -o theme.py https://huggingface.co/spaces/craterviewai/denoise/resolve/main/theme.py
8.96 kB
| """CraterView.ai's colours and type for the page: dark in both of the visitor's themes.""" | |
| from __future__ import annotations | |
| import gradio as gr | |
| GROUND, SOFT, PANEL, RULE = "#070b0d", "#0d1417", "#121a1e", "#203037" | |
| INK, QUIET, ACCENT, LIFT, SAND = "#e9f1f3", "#8ea2a9", "#2f7d6a", "#58b39a", "#b29669" | |
| BUTTON = "linear-gradient(135deg, #2f7d6a, #2f6f96)" | |
| _colours = dict( | |
| body_background_fill=GROUND, body_text_color=INK, body_text_color_subdued=QUIET, | |
| background_fill_primary=GROUND, background_fill_secondary=SOFT, | |
| border_color_primary=RULE, border_color_accent=ACCENT, | |
| color_accent_soft=SOFT, link_text_color=LIFT, link_text_color_hover=INK, | |
| link_text_color_active=INK, link_text_color_visited=LIFT, | |
| block_background_fill=PANEL, block_border_color=RULE, block_label_background_fill=PANEL, | |
| block_label_text_color=QUIET, block_title_text_color=INK, block_info_text_color=QUIET, | |
| input_background_fill=SOFT, input_border_color=RULE, | |
| button_primary_background_fill=BUTTON, button_primary_background_fill_hover=BUTTON, | |
| button_primary_text_color="#ffffff", button_primary_border_color=ACCENT, | |
| button_secondary_background_fill=SOFT, button_secondary_background_fill_hover=PANEL, | |
| button_secondary_text_color=INK, button_secondary_border_color=RULE, | |
| checkbox_background_color=SOFT, checkbox_background_color_selected=ACCENT, | |
| checkbox_border_color=QUIET, checkbox_border_color_selected=ACCENT, | |
| checkbox_label_background_fill=SOFT, checkbox_label_background_fill_hover=PANEL, | |
| checkbox_label_background_fill_selected=ACCENT, checkbox_label_border_color=RULE, | |
| checkbox_label_text_color=INK, checkbox_label_text_color_selected="#ffffff", | |
| ) | |
| THEME = gr.themes.Base( | |
| font=[gr.themes.GoogleFont("Inter"), "ui-sans-serif", "system-ui", "sans-serif"], | |
| radius_size=gr.themes.sizes.radius_lg, | |
| ).set( | |
| color_accent=ACCENT, block_radius="14px", button_large_radius="10px", | |
| button_large_text_weight="560", block_border_width="1px", block_shadow="none", | |
| **_colours, **{f"{name}_dark": value for name, value in _colours.items()}, | |
| ) | |
| # The page's own root, named twice (`_raised`). | |
| _ROOT = ".gradio-container.gradio-container" | |
| # Hugging Face draws its name badge, 42 px tall and 12 px from the top, over a Space opened at its | |
| # own address, and not over one framed by huggingface.co. The script marks the page when it is not | |
| # framed, and the headline then has room above it for the badge, there and nowhere else. | |
| UNFRAMED = "cv-unframed" | |
| HEAD = (f'<script>if (window.top === window.self) ' | |
| f'document.documentElement.classList.add("{UNFRAMED}");</script>') | |
| _RULES = f""" | |
| .gradio-container {{ max-width: 1140px !important; margin: 0 auto !important; }} | |
| .cv-headline {{ font-size: clamp(1.75rem, 4.2vw, 2.5rem); line-height: 1.15; font-weight: 700; | |
| letter-spacing: -0.02em; margin: 0 0 8px; color: {INK}; }} | |
| html.{UNFRAMED} {_ROOT} .cv-headline {{ margin-top: 48px; }} | |
| .cv-headline em {{ font-style: normal; color: transparent; background-clip: text; | |
| -webkit-background-clip: text; | |
| background-image: linear-gradient(120deg, #58b39a, #63a9d4 72%); }} | |
| .cv-lede {{ font-size: 1.15rem; line-height: 1.6; color: {QUIET}; margin: 0 0 8px; max-width: 52rem; }} | |
| .cv-card {{ background: {PANEL}; border: 1px solid {RULE}; border-radius: 14px; padding: 20px; | |
| gap: 14px !important; }} | |
| .cv-label {{ font-size: 0.82rem; font-weight: 600; letter-spacing: 0.08em; | |
| text-transform: uppercase; color: {QUIET}; }} | |
| .cv-sub {{ font-size: 0.88rem; font-weight: 600; color: {INK}; }} | |
| .html-container {{ padding: 0 !important; }} | |
| .cv-quiet, .cv-quiet p {{ font-size: 0.88rem; line-height: 1.6; color: {QUIET}; margin: 0; }} | |
| .cv-card .cv-quiet {{ padding: 0 2px; overflow: visible; }} | |
| .cv-photo img {{ border-radius: 10px; }} | |
| .cv-photo {{ border: 1px solid {RULE}; border-radius: 10px; background: {SOFT}; min-height: 180px; }} | |
| .cv-card button {{ min-height: 48px; }} | |
| .cv-card label {{ min-height: 44px; }} | |
| .cv-settings {{ border: 1px solid {RULE} !important; border-radius: 10px !important; | |
| background: {SOFT} !important; }} | |
| .cv-settings {{ padding: 0 14px !important; }} | |
| .cv-settings .label-wrap {{ font-size: 0.82rem; font-weight: 600; letter-spacing: 0.08em; | |
| text-transform: uppercase; color: {QUIET}; align-items: center; min-height: 48px; }} | |
| .cv-settings .label-wrap span {{ display: flex; align-items: center; }} | |
| .cv-settings .label-wrap.open {{ margin-bottom: 6px; }} | |
| .cv-examples, .cv-examples .gallery-container, .cv-examples .grid-wrap {{ height: auto !important; | |
| min-height: 0 !important; max-height: none !important; }} | |
| .cv-examples .grid-container {{ grid-template-columns: repeat(3, minmax(0, 1fr)) !important; | |
| grid-template-rows: none !important; grid-auto-rows: auto !important; height: auto !important; }} | |
| .cv-examples .gallery-item, .cv-examples .thumbnail-item {{ width: 100% !important; | |
| height: auto !important; aspect-ratio: 4 / 3; }} | |
| .cv-field, .cv-fields {{ gap: 6px !important; }} | |
| .cv-hint {{ font-size: 0.88rem; line-height: 1.6; color: {QUIET}; margin: 0 2px 8px; }} | |
| .cv-number {{ align-items: end; gap: 8px; }} | |
| .cv-field .form, .cv-field .block {{ border: 0 !important; background: transparent !important; | |
| box-shadow: none !important; padding: 0 !important; }} | |
| .cv-field .form, .cv-field .block {{ border-radius: 0 !important; overflow: visible !important; }} | |
| .cv-field label {{ min-height: 0; }} | |
| .cv-field span[data-testid="block-info"] {{ font-size: 0.95rem; font-weight: 560; color: {INK}; }} | |
| .cv-field input[type="text"], .cv-field input[type="number"], .cv-field .wrap-inner {{ | |
| min-height: 44px; border: 1px solid {RULE}; border-radius: 8px; background: {GROUND}; }} | |
| .cv-field .min_value, .cv-field .max_value {{ display: none; }} | |
| .cv-field .head input[type="number"] {{ min-height: 0; border: 0; background: transparent; | |
| color: {LIFT}; text-align: right; }} | |
| .cv-number button {{ min-height: 44px; border: 1px solid {RULE}; border-radius: 8px; | |
| background: transparent; color: {INK}; font-weight: 560; }} | |
| .cv-card button.cv-go {{ background: {BUTTON}; color: #ffffff; border-color: {ACCENT}; }} | |
| .cv-card button.cv-go:disabled {{ opacity: 0.55; }} | |
| .cv-panel {{ min-height: 260px; box-sizing: border-box; padding: 24px; border-radius: 10px; | |
| border: 1px dashed {RULE}; background: {SOFT}; display: flex; flex-direction: column; | |
| align-items: center; justify-content: center; gap: 12px; text-align: center; }} | |
| .cv-panel p {{ margin: 0; max-width: 24rem; color: {QUIET}; font-size: 0.95rem; line-height: 1.6; }} | |
| .cv-idle .cv-title {{ color: {QUIET}; font-weight: 400; font-size: 1rem; }} | |
| .cv-title {{ font-size: 1.25rem; font-weight: 700; letter-spacing: -0.02em; line-height: 1.15; | |
| color: {INK}; }} | |
| .cv-step {{ font-size: 0.8rem; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; | |
| color: {QUIET}; }} | |
| .cv-clock {{ font-family: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace; | |
| font-size: 0.95rem; color: {QUIET}; }} | |
| .cv-spinner {{ width: 40px; height: 40px; border-radius: 999px; border: 4px solid {RULE}; | |
| border-top-color: {LIFT}; animation: cv-turn 1s linear infinite; }} | |
| @keyframes cv-turn {{ to {{ transform: rotate(360deg); }} }} | |
| @media (prefers-reduced-motion: reduce) {{ .cv-spinner {{ animation: none !important; }} }} | |
| .cv-sign {{ flex: none; width: 24px; height: 24px; border-radius: 999px; font-weight: 700; | |
| display: inline-flex; align-items: center; justify-content: center; }} | |
| .cv-good {{ color: #57b894; border: 2px solid #57b894; font-size: 0.8rem; }} | |
| .cv-bad {{ color: #d1615a; border: 2px solid #d1615a; }} | |
| .cv-done {{ display: flex; gap: 10px; align-items: flex-start; }} | |
| .cv-done p {{ margin: 0; color: {INK}; font-size: 0.95rem; line-height: 1.6; }} | |
| .cv-about {{ background: {SOFT}; border: 1px solid {RULE}; border-radius: 14px; | |
| padding: 20px 24px; margin-top: 8px; }} | |
| .cv-about p {{ margin: 0 0 6px; color: {INK}; font-size: 0.95rem; line-height: 1.6; }} | |
| .cv-links {{ display: flex; flex-wrap: wrap; gap: 0 24px; font-weight: 560; padding: 0 !important; }} | |
| .cv-links a {{ margin: 0 !important; padding: 0 !important; }} | |
| .cv-links a {{ min-height: 44px; display: inline-flex; align-items: center; color: {LIFT}; }} | |
| .cv-about p.cv-quiet {{ color: {QUIET}; font-size: 0.88rem; margin: 0; }} | |
| """ | |
| def _raised(rules: str) -> str: | |
| """Each rule under the page's own root, named twice. Hugging Face serves a Space's styles | |
| beside Gradio's own at the same weight, and Gradio's then win where both speak. A rule that | |
| names the root itself, as the unframed headline's does, is left as it is.""" | |
| out = [] | |
| for line in rules.split("}\n"): | |
| head, brace, body = line.partition("{") | |
| if brace and not head.lstrip().startswith("@") and ".gradio-container" not in head: | |
| head = ", ".join(f"{_ROOT} {selector.strip()}" for selector in head.split(",")) + " " | |
| out.append(head + brace + body) | |
| return "}\n".join(out) | |
| CSS = _raised(_RULES) | |