Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make Custom Metrics Data a <dl> not a <table> #2509

Merged
merged 4 commits into from
Jan 9, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion www/assets/css/pagestyle2.css
Original file line number Diff line number Diff line change
@@ -8633,8 +8633,14 @@ wpt-header .wptheader_nav_menu_section a.banner_lfwp:hover {
}

.glossary dt {
font-weight: bold;
padding: 10px 0;
font-weight: 300;
font-size: 0.8em;
text-transform: uppercase;
}

.glossary dd {
margin-left: 0;
}

.glossary li {
@@ -8652,6 +8658,13 @@ wpt-header .wptheader_nav_menu_section a.banner_lfwp:hover {
.table-cell-error {
background: red;
}

.scrollableLine {
overflow: scroll;
height: 2em;
white-space: nowrap;
}

/* Prism.js overwrite */
pre[class*="language-"] {
background: none !important;
35 changes: 6 additions & 29 deletions www/details.php
Original file line number Diff line number Diff line change
@@ -145,37 +145,14 @@ function createForm($formName, $btnText, $id, $owner, $secret)
echo $userTimingTable->create(true);


// Full custom metrics (formerly in custommetrics.php)

if (
isset($pageData) &&
is_array($pageData) &&
array_key_exists($run, $pageData) &&
is_array($pageData[$run]) &&
array_key_exists($cached, $pageData[$run]) &&
array_key_exists('custom', $pageData[$run][$cached]) &&
is_array($pageData[$run][$cached]['custom']) &&
count($pageData[$run][$cached]['custom'])
) {
echo '<details class="details_custommetrics"><summary>Custom Metrics Data</summary>';
echo '<div class="scrollableTable"><table class="pretty details">';
foreach ($pageData[$run][$cached]['custom'] as $metric) {
if (array_key_exists($metric, $pageData[$run][$cached])) {
echo '<tr><th>' . htmlspecialchars($metric) . '</th><td>';
$val = $pageData[$run][$cached][$metric];
if (!is_string($val) && !is_numeric($val)) {
$val = json_encode($val);
}
echo htmlspecialchars($val);
echo '</td></tr>';
}
}
echo '</table></details>';
// Full custom metrics
$customPageData = @$pageData[$run][$cached]['custom'];
if (!empty($customPageData) && is_array($customPageData)) {
echo view('snippets.custommetrics', [
'data' => $pageData[$run][$cached],
]);
}




if (isset($testRunResults)) {
echo '<div class="cruxembed">';
require_once(INCLUDES_PATH . '/include/CrUX.php');
17 changes: 17 additions & 0 deletions www/resources/views/snippets/custommetrics.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<details class="details_custommetrics">
<summary>Custom Metrics Data</summary>
<dl class="glossary">
@foreach ($data['custom'] as $metric)
@if (array_key_exists($metric, $data))
<dt>{{ $metric }}</dt>
<dd class="scrollableLine">
@if (!is_string($data[$metric]) && !is_numeric($data[$metric]))
{{ json_encode($data[$metric]) }}
@else
{{ $data[$metric] }}
@endif
</dd>
@endif
@endforeach
</dl>
</details>