Skip to content

Commit

Permalink
Improve styling of demo header (#3022)
Browse files Browse the repository at this point in the history
<!--
Open the PR up as a draft until you feel it is ready for a proper
review.

Do not make PR:s from your own `main` branch, as that makes it difficult
for reviewers to add their own fixes.

Add any improvements to the branch as new commits to make it easier for
reviewers to follow the progress. All commits will be squashed to a
single commit once the PR is merged into `main`.

Make sure you mention any issues that this PR closes in the description,
as well as any other related issues.

To get an auto-generated PR description you can put "copilot:summary" or
"copilot:walkthrough" anywhere.
-->

### What

Fixes #2732
Fixes #2856

Can be tested at https://demo.rerun.io/pr/3022

### Checklist
* [x] I have read and agree to [Contributor
Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and
the [Code of
Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md)
* [x] I've included a screenshot or gif (if applicable)
* [x] I have tested [demo.rerun.io](https://demo.rerun.io/pr/3022) (if
applicable)

- [PR Build Summary](https://build.rerun.io/pr/3022)
- [Docs
preview](https://rerun.io/preview/pr%3Ajan%2Fdemo-header-css/docs)
- [Examples
preview](https://rerun.io/preview/pr%3Ajan%2Fdemo-header-css/examples)

---------

Co-authored-by: Marten Bjork <marten@martenbjork.com>
  • Loading branch information
jprochazk and martenbjork committed Aug 21, 2023
1 parent a55e884 commit 76a4444
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 86 deletions.
8 changes: 6 additions & 2 deletions scripts/ci/build_demo_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,17 +176,21 @@ def main() -> None:
)

parser.add_argument("--skip-build", action="store_true", help="Skip building the Python SDK and web viewer Wasm.")
parser.add_argument("--skip-examples", action="store_true", help="Skip running the examples.")

args = parser.parse_args()

if not args.skip_build:
build_python_sdk()
build_wasm()

shutil.rmtree(f"{BASE_PATH}/examples", ignore_errors=True)
examples = collect_examples()
assert len(examples) > 0, "No examples found"
save_examples_rrd(examples)

if not args.skip_examples:
shutil.rmtree(f"{BASE_PATH}/examples", ignore_errors=True)
save_examples_rrd(examples)

render_examples(examples)
copy_static_assets(examples)
copy_wasm(examples)
Expand Down
2 changes: 1 addition & 1 deletion scripts/ci/demo_assets/static/github-mark-white.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
47 changes: 28 additions & 19 deletions scripts/ci/demo_assets/static/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ body {
background: #0d1011;
}


/* Allow canvas to fill entire web page: */
html,
body {
Expand All @@ -32,27 +31,23 @@ canvas {
}

* {
font-family: 'Inter', sans-serif;
color: #f0f0f0;
font-family: "Inter", sans-serif;
color: #cad8de;
}


/* Match the Rerun header bar. */
.header {
width: 100%;
height: 44px;
/* background: #111415; */
/* Actual value from Rerun Viewer */
background: #141414;

}

/* Create a container filling the remaining space. */
.container {
position: absolute;
height: calc(100vh - 44px);
width: 100vw;

}

/* Centered div inside the container. */
Expand All @@ -78,7 +73,7 @@ p {
/* Rerun styling for strong text. Matches `TextStyle::Heading`. */
.strong {
/*Gray-775*/
color: #ffffff;
color: #cad8de;
/* Match current rerun header value */
font-size: 16px;
}
Expand All @@ -103,7 +98,7 @@ a .button {
display: inline-block;
background: white;
color: black;
padding: .75rem 1rem;
padding: 0.75rem 1rem;
border-radius: 8px;
text-decoration: none;
font-weight: 500;
Expand Down Expand Up @@ -133,6 +128,13 @@ a .button {
display: flex;
flex-direction: row;
gap: 4px;

-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}

.no-select {
user-select: none;
}

.examples {
Expand All @@ -147,20 +149,21 @@ a .button {
border-radius: 33%;
}

.example-description:hover>.example-description-body {
.example-description:hover > .example-description-body {
display: flex;
}

.example-description:hover>.example-description-icon {
.example-description:hover > .example-description-icon {
background: #404040;
border: none;
border-radius: 50%;
border-radius: 5px;
}

.example-description-icon {
display: flex;
justify-content: center;
padding: 6px;
margin: 4px;
padding: 2px;
width: 20px;
height: 20px;
user-select: none;
Expand All @@ -170,20 +173,24 @@ a .button {
display: none;

flex-direction: column;
gap: 3px;
gap: 8px;

position: absolute;
top: 100%;

background: #1c2123;
background: #262626;
border: none;
border-radius: 6px;
padding: 12px;

font-size: 13px;
line-height: 1.33;
letter-spacing: 0;

width: 280px;
}

.example-description-body>p {
.example-description-body > p {
margin: 0;
}

Expand Down Expand Up @@ -225,7 +232,7 @@ img.icon {
line-height: 16px;
}

.dropdown-title>img {
.dropdown-title > img {
width: 16px;
height: 16px;
}
Expand All @@ -248,12 +255,13 @@ img.icon {
top: 100%;
left: 0;

background: #1c2123;
background: #262626;
border: none;
border-radius: 6px;
padding: 6px;

user-select: none;
font-size: 12px;
}

.dropdown-body.visible {
Expand Down Expand Up @@ -287,7 +295,7 @@ a.flat-link {
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
color: #f0f0f0;
color: #cad8de;
font-size: 24px;
font-family: Ubuntu-Light, Helvetica, sans-serif;
text-align: center;
Expand All @@ -302,3 +310,4 @@ a.button {
text-decoration: none;
font-weight: 500;
}

134 changes: 70 additions & 64 deletions scripts/ci/demo_assets/templates/example.html
Original file line number Diff line number Diff line change
@@ -1,82 +1,88 @@
<!DOCTYPE html>
<!-- The version of index.html that will be served by demo.rerun.io -->
<html>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<!-- Disable zooming: -->
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no" />
<!-- Disable zooming: -->
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no" />

<head>
<link rel="icon" href="favicon.svg" />
<title>Rerun Viewer</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@100;500&display=swap" rel="stylesheet">
<link rel="stylesheet" href="index.css" />
</head>
<head>
<link rel="icon" href="favicon.svg" />
<title>Rerun Viewer</title>
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Inter:wght@100;500&display=swap"
rel="stylesheet"
/>
<link rel="stylesheet" href="index.css" />
</head>

<body>
<div class="header">
<div class="demo_header hidden" id="header_bar">
<div class="examples">
<div class="dropdown" id="examples">
<div class="dropdown-title">
Examples
<img class="icon" src="caret-down.svg" />
</div>
<div class="dropdown-body">
{% for entry in examples %}
<a class="flat-link" href="../{{ entry.name }}">
<div class="dropdown-entry" data-link="{{ entry.name }}">{{ entry.title }}</div>
</a>
{% endfor %}
<body>
<div class="header">
<div class="demo_header hidden" id="header_bar">
<div class="examples">
<div class="dropdown no-select" id="examples">
<div class="dropdown-title">
Examples
<img class="icon" src="caret-down.svg" />
</div>
<div class="dropdown-body">
{% for entry in examples %}
<a class="flat-link" href="../{{ entry.name }}">
<div class="dropdown-entry" data-link="{{ entry.name }}">{{ entry.title }}</div>
</a>
{% endfor %}
</div>
</div>
</div>
<div class="example-description">
<div class="example-description-icon no-select">?</div>
<div class="example-description-body">{{ example.description }}</div>
</div>
<a class="icon-link no-select" href="{{ example.source_url }}" target="_blank">
<img class="icon" src="github-mark-white.svg" />
</a>
</div>
<div class="example-description">
<div class="example-description-icon">?</div>
<div class="example-description-body">{{ example.description }}</div>
</div>
<a class="icon-link" href="{{ example.source_url }}" target="_blank">
<img class="icon" src="github-mark-white.svg" />
</a>
</div>
</div>
<div class="container">
<div class="centered hidden" id="center_text"></div>
</div>
<canvas id="the_canvas_id" class="hidden"></canvas>


<script src="https://fifteen-thirtyeight.rerun.io/script.js" data-site="QKMCQFTQ" defer></script>
<div class="container">
<div class="centered hidden" id="center_text"></div>
</div>
<canvas id="the_canvas_id" class="hidden"></canvas>

<script>
// The `--no-modules`-generated JS from `wasm-bindgen` attempts to use
// `WebAssembly.instantiateStreaming` to instantiate the wasm module,
// but this doesn't work with `file://` urls. This example is frequently
// viewed by simply opening `index.html` in a browser (with a `file://`
// url), so it would fail if we were to call this function!
//
// Work around this for now by deleting the function to ensure that the
// `no_modules.js` script doesn't have access to it. You won't need this
// hack when deploying over HTTP.
if (window.location.protocol.startsWith("file")) {
delete WebAssembly.instantiateStreaming;
}
<script
src="https://fifteen-thirtyeight.rerun.io/script.js"
data-site="QKMCQFTQ"
defer
></script>

// always strip `index.html` from the url, so that relative paths in links to examples work
const index_html_pos = window.location.pathname.indexOf("index.html");
if (index_html_pos !== -1) {
window.location.href = window.location.pathname.slice(0, index_html_pos);
}
</script>
<script>
// The `--no-modules`-generated JS from `wasm-bindgen` attempts to use
// `WebAssembly.instantiateStreaming` to instantiate the wasm module,
// but this doesn't work with `file://` urls. This example is frequently
// viewed by simply opening `index.html` in a browser (with a `file://`
// url), so it would fail if we were to call this function!
//
// Work around this for now by deleting the function to ensure that the
// `no_modules.js` script doesn't have access to it. You won't need this
// hack when deploying over HTTP.
if (window.location.protocol.startsWith("file")) {
delete WebAssembly.instantiateStreaming;
}

<!-- this is the JS generated by the `wasm-bindgen` CLI tool -->
<script src="re_viewer.js"></script>
// always strip `index.html` from the url, so that relative paths in links to examples work
const index_html_pos = window.location.pathname.indexOf("index.html");
if (index_html_pos !== -1) {
window.location.href = window.location.pathname.slice(0, index_html_pos);
}
</script>

<script src="index.js"></script>
</body>
<!-- this is the JS generated by the `wasm-bindgen` CLI tool -->
<script src="re_viewer.js"></script>

<script src="index.js"></script>
</body>
</html>

<!-- Powered by egui: https://github.com/emilk/egui/ -->

0 comments on commit 76a4444

Please sign in to comment.