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

report(flow): navigation sidebar #12929

Merged
merged 154 commits into from Aug 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
154 commits
Select commit Hold shift + click to select a range
b506309
WIP: standalone flow report with preact
patrickhulce Jul 28, 2021
5bd54ba
basic flow report display
adamraine Aug 2, 2021
fdb8e4f
better style
adamraine Aug 2, 2021
63eaa13
reee
adamraine Aug 2, 2021
541e3e1
add report features
adamraine Aug 2, 2021
7bb3482
key
adamraine Aug 3, 2021
d0a1b95
Merge branch 'master' into fr-flow-report-maybe
adamraine Aug 3, 2021
f4bb351
rm tsconfig changes
adamraine Aug 3, 2021
43003e9
rm t
adamraine Aug 3, 2021
f8dbda0
no sm
adamraine Aug 3, 2021
f206c8e
cache reports
adamraine Aug 3, 2021
d7a924a
Merge branch 'master' into fr-flow-report-maybe
adamraine Aug 3, 2021
471060a
update fixtures
adamraine Aug 3, 2021
d6d20f7
cache features
adamraine Aug 3, 2021
9e4b774
comment
adamraine Aug 3, 2021
dd03b77
add time to option
adamraine Aug 3, 2021
7670345
remove actual report
adamraine Aug 3, 2021
140a4bf
date
adamraine Aug 3, 2021
00121ea
todo
adamraine Aug 3, 2021
1494787
lint
adamraine Aug 3, 2021
f02a48e
eh
adamraine Aug 4, 2021
84a99b8
Update types/lhr.d.ts
adamraine Aug 4, 2021
31b9624
extract
adamraine Aug 4, 2021
8bd68a8
basic
adamraine Aug 4, 2021
d83615e
icons
adamraine Aug 4, 2021
d7bb712
tsx
adamraine Aug 5, 2021
895fc89
Merge branch 'fr-flow-shell-report' into fr-flow-report-sidebar
adamraine Aug 5, 2021
7fdcbc3
sidebar flow
adamraine Aug 5, 2021
6fc7fef
hbar
adamraine Aug 5, 2021
9273e27
hbar
adamraine Aug 5, 2021
462d1a5
better position
adamraine Aug 5, 2021
d0bb9e4
better segments
adamraine Aug 6, 2021
9c357e4
highlight
adamraine Aug 6, 2021
3f60287
no z
adamraine Aug 6, 2021
34e218b
add summary
adamraine Aug 6, 2021
820d2f5
summary again
adamraine Aug 6, 2021
9173f6a
css
adamraine Aug 6, 2021
28c8c5c
fonts
adamraine Aug 6, 2021
09df709
colors
adamraine Aug 6, 2021
1399aa0
hbar margin
adamraine Aug 6, 2021
48a1824
section title
adamraine Aug 6, 2021
9746e5d
titles
adamraine Aug 6, 2021
28be410
layout
adamraine Aug 6, 2021
08e483b
r
adamraine Aug 6, 2021
0e51163
flow icon component
adamraine Aug 6, 2021
c6c3dd2
idk
adamraine Aug 6, 2021
505db64
current step
adamraine Aug 6, 2021
d00c6f4
organize
adamraine Aug 6, 2021
d59bd75
basic runtime settings
adamraine Aug 6, 2021
f3be8e9
color
adamraine Aug 6, 2021
e48b5ac
i am very proud of myself
adamraine Aug 6, 2021
d4bb90d
rm grid
adamraine Aug 9, 2021
77612d0
some content
adamraine Aug 9, 2021
e2a6015
title date
adamraine Aug 9, 2021
81265ce
isCurrent
adamraine Aug 9, 2021
9da3ddd
font
adamraine Aug 9, 2021
7dc7ef9
padding
adamraine Aug 9, 2021
61815c3
summary padding
adamraine Aug 11, 2021
8298e4e
report(fr): add tsx to shell report (#12889)
adamraine Aug 12, 2021
c11523e
Merge branch 'master' into fr-flow-shell-report
adamraine Aug 12, 2021
6821d53
fix merge whitespace
adamraine Aug 12, 2021
b0c7785
rm htm
adamraine Aug 12, 2021
3e495a4
window types
adamraine Aug 12, 2021
3ce8b8e
rn
adamraine Aug 12, 2021
544cb5f
sample
adamraine Aug 12, 2021
25d6b62
test
adamraine Aug 12, 2021
f0f7664
proto
adamraine Aug 12, 2021
6cc95a8
unit commands
adamraine Aug 13, 2021
eb44c56
jest root projects
adamraine Aug 13, 2021
965b793
rm templates
adamraine Aug 13, 2021
0807be2
modify test
adamraine Aug 13, 2021
6ca47f6
rn
adamraine Aug 13, 2021
d47b765
license
adamraine Aug 13, 2021
162f82f
gather_mode
adamraine Aug 13, 2021
da3108e
GatherContext
adamraine Aug 13, 2021
c048f0c
mv template
adamraine Aug 13, 2021
4d520e6
rn
adamraine Aug 13, 2021
1688412
types
adamraine Aug 13, 2021
6efe5ec
Merge branch 'master' into fr-flow-shell-report
adamraine Aug 13, 2021
451a4c0
ope
adamraine Aug 13, 2021
28a9746
Merge branch 'fr-flow-shell-report' into fr-flow-report-sidebar
adamraine Aug 13, 2021
ead3e49
package
adamraine Aug 13, 2021
0b250c7
update types
adamraine Aug 16, 2021
462c004
fix hanging build-report
adamraine Aug 16, 2021
6b77fc4
rn
adamraine Aug 16, 2021
78c9b9a
legacy condition
adamraine Aug 16, 2021
a5ea53b
npmignore
adamraine Aug 16, 2021
d74925e
fix unit
adamraine Aug 16, 2021
be59ef1
flowResult
adamraine Aug 16, 2021
1246ca3
todo comment
adamraine Aug 16, 2021
68ce354
trim lr bundle
adamraine Aug 17, 2021
1731d2e
fix test type
adamraine Aug 17, 2021
3bda62e
LH_ROOT
adamraine Aug 17, 2021
3fe834d
fix viewer
adamraine Aug 17, 2021
b18c617
Merge branch 'fr-flow-shell-report' into fr-flow-report-sidebar
adamraine Aug 17, 2021
7611d61
no
adamraine Aug 17, 2021
35aa958
sidebar file
adamraine Aug 17, 2021
e768820
fs root
adamraine Aug 17, 2021
cb54559
comment
adamraine Aug 17, 2021
0100e48
rn
adamraine Aug 17, 2021
957ea7f
mv
adamraine Aug 17, 2021
c00434a
npmignore
adamraine Aug 17, 2021
6cb3a1d
utf-8
adamraine Aug 17, 2021
0ea93f8
unneeded eslint disable
adamraine Aug 17, 2021
29be0aa
Merge branch 'fr-flow-shell-report' into fr-flow-report-sidebar
adamraine Aug 17, 2021
5977047
app tests
adamraine Aug 17, 2021
42a017b
eslint
adamraine Aug 17, 2021
217dfbf
no ?
adamraine Aug 17, 2021
6f0e7c4
sidebar tests
adamraine Aug 18, 2021
66713dc
hooks test
adamraine Aug 18, 2021
8c5a21b
ok
adamraine Aug 18, 2021
7c574b1
format
adamraine Aug 18, 2021
2267466
Merge branch 'master' into fr-flow-report-sidebar
adamraine Aug 18, 2021
089f053
a
adamraine Aug 18, 2021
33bffd8
findby
adamraine Aug 18, 2021
65ca3a6
findby
adamraine Aug 18, 2021
8d6dcf8
more
adamraine Aug 18, 2021
735a799
context
adamraine Aug 18, 2021
87240f4
TZ
adamraine Aug 18, 2021
af6e78b
async
adamraine Aug 18, 2021
34e5d96
inline css
adamraine Aug 18, 2021
0fdbf66
style
adamraine Aug 18, 2021
2248d23
norm
adamraine Aug 18, 2021
ca2fa40
license
adamraine Aug 18, 2021
c61da58
Separator
adamraine Aug 18, 2021
7fb889b
role
adamraine Aug 18, 2021
dbb5adc
class helper
adamraine Aug 18, 2021
20883ed
ope
adamraine Aug 18, 2021
2ca3076
warn
adamraine Aug 18, 2021
641f5ba
sidebar current
adamraine Aug 18, 2021
9dd3230
oem
adamraine Aug 18, 2021
f87132c
flow step icon
adamraine Aug 18, 2021
d959b60
k
adamraine Aug 18, 2021
0a5a6f5
k
adamraine Aug 18, 2021
69b60f9
context
adamraine Aug 19, 2021
6a40242
locale
adamraine Aug 19, 2021
9570d87
hash navigation
adamraine Aug 19, 2021
24fb938
hash param
adamraine Aug 19, 2021
b6248cc
restructure
adamraine Aug 19, 2021
7ba39a6
split
adamraine Aug 19, 2021
1e124e1
throw error
adamraine Aug 19, 2021
a51185d
top
adamraine Aug 19, 2021
09ab06f
Merge branch 'master' into fr-flow-report-sidebar
adamraine Aug 19, 2021
b4aa39b
Merge branch 'master' into fr-flow-report-sidebar
adamraine Aug 19, 2021
ad10138
empty hash
adamraine Aug 19, 2021
d5dc935
license
adamraine Aug 23, 2021
236923b
css
adamraine Aug 23, 2021
b75a908
inline
adamraine Aug 23, 2021
0458f11
comment
adamraine Aug 23, 2021
352f1aa
Merge branch 'master' into fr-flow-report-sidebar
adamraine Aug 23, 2021
cdb1097
types
adamraine Aug 23, 2021
8ad429a
flex gap workaround
adamraine Aug 23, 2021
ea110d6
fix ts build
adamraine Aug 23, 2021
f6862bb
tz comment
adamraine Aug 23, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 0 additions & 7 deletions build/build-report.js
Expand Up @@ -41,13 +41,6 @@ async function buildFlowReport() {
commonjs(),
typescript({
tsconfig: 'flow-report/tsconfig.json',
// rollup-plugin-commonjs 10.1.0 does not work here.
// https://github.com/ezolenko/rollup-plugin-typescript2#plugin-options
tsconfigOverride: {
compilerOptions: {
module: 'ES6',
},
},
}),
terser(),
],
Expand Down
3 changes: 2 additions & 1 deletion flow-report/assets/standalone-flow-template.html
Expand Up @@ -22,8 +22,9 @@
<link rel="icon" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAEhklEQVR4AWJxL/BhIAesev1U5tcflpncgNrKIsqNIwzC9feMpDUzs70kOczMzMzJJcxwCTMzncPMnOwtzBwzMzPb0vRfeZPp0VhPS5I39V5fdiXV1/VD+9QC7OVn9BsyH1XIoEI1PfmJvLFowVV564+34DFUHudbmfDh4kVXh//7XwE+WjS/YfXZe3yr4j2rqj1AIhSB7hZ8ZtPZu/zw8cK523U4wE1/rvPfWrz4zs0m9ZdC9yUJAlASdBAgocRegfF/f3/h/PuaFsxMdwjAR0vm1+06eMMfIrhLqTWqdH4EumU2SPfMhigJAlRQbZrgrRsl9U+Y2DYDFCz3ILC9kiAiqSrMwbWT0nceEnR+9Kggc2zjOJCASDENkg0a5HfZZgDP81CM3CrQs2Z1+o7DJ6ePr8sK0AOCHv5Jjdt3evyYSaZ351VIStIxPRAUtrBYbxC6w+BZ0ivVSBKkIhJhemSyZpfB00EiPO2VjzYkxhcqXQqCWCShGplvi3y0QxqbuBurMjyJeWnkHZuAEgIQGsUBqwrfjZ+IlBgKyRJzVVYF8O6qFWdh86YzQzMrZigYmxAyfvHgLZQ/LC1CbeniW2Hkqr/PH16SgvGuf2/uzNMBwJA/njxizGPtSyAf7EziJCMGRDRdhoAC4PL1A/SrKQMAAQkEfpJAcRQdrBJ7gNwjSpJsdwK+CANBkqa1LgQB4IicV9nYUct7gaxuDJUErQIiEAiMxLVOFlKzIktPpT0ggpdpC/8YAHnxbgkUY4tAAFSR7AAXNyAAWHJrA/kHGjzg5nleuwFO7Nd/IoDw4Pm58+4jNLmYG0wRA5bErc2Mr3Y+dXTDW1VvwqbJkzMCHQ4S1GTCBOIgUHJrGdEwqzR+jAp/o2qAZelUDoQnruEEdDclJI6576AlNVfc+22XN/+Y1vnJD0Yind6UpEEvn/Hqq15EYjCW7jZCJEpnNvDgkyelDjs106kuux2AAXCSobULOWP8mLhYlpoDMK4qAFXJGk+grtH8YXVz5KJblqaG1+VUdTc0I290bmUQAriGITRbdQnom0aoFj8kx1+wMD2ifncAXUQE4SkDqN1hE0jEophs1SUwZAOhUAiMCLwRtamtTZtbbmZErSAUHbSysaoEmnrsakiMiUAURi283gN6wans9oX8rOCrj7/JP35DFD+iQ7Au/K2KE1jzx6ujjUnXFH9KjEq6ZlhsTBICrNLJf47Pv/pkHzvup1w4dmUbEei0+bcXRqJuh5kVARQ8byyYxOwNGr7A87xh1tp8sGT+uMInrwi++Xj7TQz2d27NvwEkrOflAFQGIDA5khASBCGdO2/Z/MnLPwYfv5TFhjW7QhVKAB6afwe2LpFlFsCnlQEosgQgDsdOG1/LKeNqJS4JCSPJ/i+TakwEARor7gER1Iva5JmPOJK0RUqmoPnnlzFCtmIAhAAQEIQRgDaiYPIauNXcnDlRIrWNFY3hm7PG9YRqr7IV7HrCgAC17befjEvRq2nGhAHtBqDpOuI/I1diUUAMYIxEdyejBJqLnNoszGZtfiX/CztGv2mq+sdaAAAAAElFTkSuQmCC">
<title>Lighthouse Flow Report</title>
<style>/*%%LIGHTHOUSE_CSS%%*/</style>
<style>/*%%LIGHTHOUSE_FLOW_CSS%%*/</style>
</head>
<body class="lh-root lh-vars">
<body class="flow-vars lh-root lh-vars">
<noscript>Lighthouse report requires JavaScript. Please enable.</noscript>

<main><!-- report populated here --></main>
Expand Down
158 changes: 158 additions & 0 deletions flow-report/assets/styles.css
@@ -0,0 +1,158 @@
/**
* @license Copyright 2021 The Lighthouse Authors. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
*/

.flow-vars {
--app-font-size: 12px;
--sidebar-title-font-size: 16px;
--sidebar-summary-font-size: 14px;
--sidebar-flow-step-navigation-font-size: 14px;
--base-spacing: 16px;
}

.App {
adamraine marked this conversation as resolved.
Show resolved Hide resolved
display: grid;
grid-template-areas: "side report";
grid-template-columns: min-content auto;
height: 100vh;
max-width: 100vw;
font-size: var(--app-font-size);
}
.App a {
color: var(--color-gray-800);
text-decoration: none;
}

.Separator {
height: 1px;
width: 100%;
background-color: var(--color-gray-300);
margin-top: 12px;
margin-bottom: 12px;
}

.Sidebar {
border-right: 1px solid var(--color-gray-300);
}

.Sidebar--current {
background-color: var(--color-gray-200);
font-weight: bold;
}

.SidebarSectionTitle {
height: 16px;
margin: 32px 16px 0px 16px;
color: var(--color-gray-700);
}

.SidebarHeader {
margin: var(--base-spacing);
}
.SidebarHeader__title {
font-size: var(--sidebar-title-font-size);
font-weight: bold;
width: max-content;
}
.SidebarHeader__date {
color: var(--color-gray-700);
width: max-content;
}

.SidebarRuntimeSettings > summary {
padding: 4px 16px;
adamraine marked this conversation as resolved.
Show resolved Hide resolved
list-style: none;
color: var(--color-gray-700);
}

.SidebarSummary {
width: 100%;
display: flex;
padding: 8px 16px;
align-items: center;
}

.SidebarSummary__icon {
display: flex;
height: 16px;
width: 16px;
align-items: center;
justify-content: center;
/* Flex column-gap workaround for safari */
margin-right: var(--base-spacing);
}
.SidebarSummary__icon::before {
content: '☰';
font-weight: normal;
color: var(--color-blue-A700);
}

.SidebarSummary__label {
font-size: var(--sidebar-summary-font-size);
}

.SidebarFlowStep {
display: flex;
padding-left: var(--base-spacing);
padding-right: var(--base-spacing);
}

.SidebarFlowStep__label {
grid-column: 2;
margin-top: 14px;
margin-bottom: 14px;
justify-self: left;
}
.SidebarFlowStep__label--navigation {
font-size: var(--sidebar-flow-step-navigation-font-size);
}

.SidebarFlowStep__icon {
grid-column: 1;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
width: 16px;
/* Flex column-gap workaround for safari */
margin-right: var(--base-spacing);
}
.SidebarFlowStep__icon--line {
width: 2px;
flex-grow: 1;
background-color: var(--color-blue-A700);
}

.FlowStepIcon {
display: flex;
width: 16px;
height: 16px;
align-items: center;
justify-content: center;
}
.FlowStepIcon--navigation::before {
content: '';
width: 16px;
height: 16px;
border-radius: 50%;
border: 2px solid var(--color-blue-A700);
display: block;
}
.FlowStepIcon--timespan::before {
content: '';
width: 4px;
height: 4px;
border-radius: 50%;
background-color: var(--color-blue-A700);
display: block;
}
.FlowStepIcon--snapshot::before {
content: '';
width: 8px;
height: 8px;
border-radius: 50%;
background-color: var(--color-blue-A700);
display: block;
}
2 changes: 2 additions & 0 deletions flow-report/jest.config.js
Expand Up @@ -7,7 +7,9 @@
module.exports = {
testEnvironment: 'jsdom',
preset: 'ts-jest',
globalSetup: './test/setup/global-setup.ts',
testMatch: [
'**/test/**/*-test.ts',
'**/test/**/*-test.tsx',
],
};
38 changes: 20 additions & 18 deletions flow-report/App.tsx → flow-report/src/app.tsx
Expand Up @@ -5,38 +5,40 @@
*/

import {FunctionComponent} from 'preact';
import {useState} from 'preact/hooks';
import {Sidebar} from './sidebar/sidebar';
import {FlowResultContext, useCurrentLhr} from './util';

export const Report: FunctionComponent<{lhr: LH.Result}> = ({lhr}) => {
const Report: FunctionComponent<{lhr: LH.Result}> = ({lhr}) => {
// TODO(FR-COMPAT): Render an actual report here.
return (
<div>
<div data-testid="Report">
<h1>{lhr.finalUrl}</h1>
{
Object.values(lhr.categories).map((category) =>
<h2>{category.id}: {category.score}</h2>
<h2 key={category.id}>{category.id}: {category.score}</h2>
)
}
</div>
);
};

const Summary: FunctionComponent = () => {
// TODO(FR-COMPAT): Design summary page.
return <h1 data-testid="Summary">SUMMARY</h1>;
};

const Content: FunctionComponent = () => {
const currentLhr = useCurrentLhr();
return currentLhr ? <Report lhr={currentLhr.value}/> : <Summary/>;
};

export const App: FunctionComponent<{flowResult: LH.FlowResult}> = ({flowResult}) => {
const [currentLhrIndex, setCurrentLhrIndex] = useState(0);
return (
<>
<select onChange={e => setCurrentLhrIndex(Number(e.currentTarget.value))}>
{
flowResult.lhrs.map((lhr, i) =>
<option key={lhr.fetchTime} value={i}>
[{lhr.fetchTime}] [{lhr.gatherMode}] {lhr.finalUrl}
</option>
)
}
</select>
<div>
<Report lhr={flowResult.lhrs[currentLhrIndex]}/>
<FlowResultContext.Provider value={flowResult}>
<div className="App">
<Sidebar/>
<Content/>
</div>
</>
</FlowResultContext.Provider>
);
};
82 changes: 82 additions & 0 deletions flow-report/src/sidebar/flow.tsx
@@ -0,0 +1,82 @@
/**
* @license Copyright 2021 The Lighthouse Authors. All Rights Reserved.
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
*/

import {FunctionComponent} from 'preact';
import {classNames, useCurrentLhr, useFlowResult} from '../util';

const FlowStepIcon: FunctionComponent<{mode: LH.Result.GatherMode}> = ({mode}) => {
return <div className={`FlowStepIcon FlowStepIcon--${mode}`}></div>;
};

const SidebarFlowStep: FunctionComponent<{
mode: LH.Result.GatherMode,
href: string,
label: string,
hideTopLine: boolean,
hideBottomLine: boolean,
isCurrent: boolean,
}> = ({href, label, mode, hideTopLine, hideBottomLine, isCurrent}) => {
return (
<a
className={classNames('SidebarFlowStep', {'Sidebar--current': isCurrent})}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

seems like Sidebar--current should be SidebarFlowStep--current?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sidebar--current is also used for SidebarSummary

href={href}
>
<div className="SidebarFlowStep__icon">
<div
className="SidebarFlowStep__icon--line"
style={hideTopLine ? {background: 'transparent'} : undefined}
/>
<FlowStepIcon mode={mode}/>
<div
className="SidebarFlowStep__icon--line"
style={hideBottomLine ? {background: 'transparent'} : undefined}
/>
</div>
<div className={`SidebarFlowStep__label SidebarFlowStep__label--${mode}`}>{label}</div>
</a>
);
};

export const SidebarFlow: FunctionComponent = () => {
const flowResult = useFlowResult();
const currentLhr = useCurrentLhr();

let numNavigation = 1;
let numTimespan = 1;
let numSnapshot = 1;

return (
<>
{flowResult.lhrs.map((lhr, index) => {
let name;
switch (lhr.gatherMode) {
case 'navigation':
name = `Navigation (${numNavigation++})`;
break;
case 'timespan':
name = `Timespan (${numTimespan++})`;
break;
case 'snapshot':
name = `Snapshot (${numSnapshot++})`;
break;
}
const url = new URL(location.href);
url.hash = `#index=${index}`;
return (
<SidebarFlowStep
key={lhr.fetchTime}
mode={lhr.gatherMode}
href={url.href}
label={name}
hideTopLine={index === 0}
hideBottomLine={index === flowResult.lhrs.length - 1}
isCurrent={index === (currentLhr && currentLhr.index)}
/>
);
})}
</>
);
};