-
Notifications
You must be signed in to change notification settings - Fork 30
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
[feat] Add vanilla extract and restyle UI #86
Merged
Merged
Changes from 9 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
a5ffb20
[feat] Add vanilla extract and restyle UI
2Steaks 8b8c47d
[refactor] Add license headers
2Steaks f859ec9
[refactor] Clean up Chart component
2Steaks 7022cc1
[fix] build package
2Steaks f80c767
[fix] Remove uplot chart title
2Steaks de5914e
[fix] Add new build
2Steaks e0915e9
[fix] Remove redundant type
2Steaks 9ef4c63
Merge branch 'master' into feat/report-ui
2Steaks 1226ed9
[feat] Add test date to title
2Steaks 2a10e19
[fix] Add license headers
2Steaks 33e5051
mage generate
szkiba 980005c
added license headers
szkiba c9571a7
[fix] Update grid spacing
2Steaks File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
dashboard/assets/packages/report/dist/assets/circle-5a1f9f5e.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
dashboard/assets/packages/report/dist/assets/logo-fd36a8d6.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// SPDX-FileCopyrightText: 2023 Raintank, Inc. dba Grafana Labs | ||
// | ||
// SPDX-License-Identifier: AGPL-3.0-only | ||
|
||
import { style } from "@vanilla-extract/css" | ||
|
||
import { vars } from "theme" | ||
import { sizes } from "theme/sizes.css" | ||
|
||
export const main = style({ | ||
padding: vars.sizes.size5, | ||
"@media": { | ||
[`(min-width: ${sizes.lg})`]: { | ||
padding: vars.sizes.size11 | ||
} | ||
} | ||
}) | ||
|
||
export const usage = style({ | ||
color: vars.colors.text.secondary, | ||
fontStyle: "italic" | ||
}) |
25 changes: 15 additions & 10 deletions
25
...ackages/report/src/components/App/App.tsx → ...rd/assets/packages/report/src/App/App.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,33 +1,38 @@ | ||
// SPDX-FileCopyrightText: 2023 Iván Szkiba | ||
// SPDX-FileCopyrightText: 2023 Raintank, Inc. dba Grafana Labs | ||
// | ||
// SPDX-License-Identifier: AGPL-3.0-only | ||
// SPDX-License-Identifier: MIT | ||
|
||
import React from "react" | ||
import { Digest } from "@xk6-dashboard/model" | ||
|
||
import Tab from "components/Tab" | ||
import "./App.css" | ||
import "theme/global.css" | ||
import { theme } from "theme" | ||
import { toClassName } from "utils" | ||
import { Flex } from "components/Flex" | ||
import { Header } from "components/Header" | ||
import { Tab } from "components/Tab/Tab" | ||
|
||
import * as styles from "./App.css" | ||
|
||
interface AppProps { | ||
digest: Digest | ||
} | ||
|
||
export default function App({ digest }: AppProps) { | ||
return ( | ||
<article className="container-fluid report"> | ||
<h1>k6 report</h1> | ||
<Flex as="main" className={toClassName(theme, styles.main)} direction="column" gap={4}> | ||
<Header digest={digest} /> | ||
|
||
{digest.config.tabs.map((tab) => ( | ||
<Tab tab={tab} digest={digest} key={tab.id} /> | ||
<Tab key={tab.id} tab={tab} digest={digest} /> | ||
))} | ||
<section className="usage"> | ||
|
||
<section> | ||
<hr /> | ||
<p className="usage"> | ||
<p className={styles.usage}> | ||
Select a time interval by holding down the mouse on any graph to zoom. To cancel zoom, double click on any graph. | ||
</p> | ||
</section> | ||
</article> | ||
</Flex> | ||
) | ||
} |
File renamed without changes.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
dashboard/assets/packages/report/src/assets/icons/circle.svg.license
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
SPDX-FileCopyrightText: 2023 Raintank, Inc. dba Grafana Labs | ||
|
||
SPDX-License-Identifier: AGPL-3.0-only |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
dashboard/assets/packages/report/src/assets/icons/logo.svg.license
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
SPDX-FileCopyrightText: 2023 Raintank, Inc. dba Grafana Labs | ||
|
||
SPDX-License-Identifier: AGPL-3.0-only |
16 changes: 0 additions & 16 deletions
16
dashboard/assets/packages/report/src/components/App/App.css
This file was deleted.
Oops, something went wrong.
27 changes: 0 additions & 27 deletions
27
dashboard/assets/packages/report/src/components/Chart/Chart.css
This file was deleted.
Oops, something went wrong.
21 changes: 21 additions & 0 deletions
21
dashboard/assets/packages/report/src/components/Chart/Chart.css.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// SPDX-FileCopyrightText: 2023 Raintank, Inc. dba Grafana Labs | ||
// | ||
// SPDX-License-Identifier: AGPL-3.0-only | ||
|
||
import { style } from "@vanilla-extract/css" | ||
|
||
import { vars } from "theme" | ||
|
||
export const uplot = style({ | ||
breakInside: "avoid" | ||
}) | ||
|
||
export const title = style({ | ||
color: vars.colors.text.secondary, | ||
fontWeight: vars.fontWeights.weight500 | ||
}) | ||
|
||
export const chart = style({ | ||
marginTop: vars.sizes.size1, | ||
marginBottom: vars.sizes.size1 | ||
}) |
23 changes: 23 additions & 0 deletions
23
dashboard/assets/packages/report/src/components/Chart/Chart.hooks.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { useLayoutEffect, useState } from "preact/hooks" | ||
|
||
type Width = number | ||
|
||
export const useElementWidth = <T extends HTMLElement = HTMLDivElement>(): [(node: T | null) => void, Width] => { | ||
const [ref, setRef] = useState<T | null>(null) | ||
const [width, setWidth] = useState(0) | ||
|
||
useLayoutEffect(() => { | ||
const updateWidth = () => { | ||
if (ref) { | ||
setWidth(ref.offsetWidth) | ||
} | ||
} | ||
|
||
updateWidth() | ||
window.addEventListener("resize", updateWidth) | ||
|
||
return () => window.removeEventListener("resize", updateWidth) | ||
}) | ||
|
||
return [setRef, width] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
73 changes: 73 additions & 0 deletions
73
dashboard/assets/packages/report/src/components/Chart/Chart.utils.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import uPlot, { type Axis, type Options, type Series } from "uplot" | ||
import { type UnitType } from "@xk6-dashboard/model" | ||
import { format, tooltipPlugin, type SeriesPlot } from "@xk6-dashboard/view" | ||
|
||
import { common, grey } from "theme/colors.css" | ||
|
||
import * as styles from "./Chart.css" | ||
|
||
const AXIS_SIDE = 1 | ||
const AXIS_SIZE = 70 | ||
|
||
const sync = uPlot.sync("chart") | ||
|
||
const dateFormats = [ | ||
[3600 * 24 * 365, null, null, null, null, null, null, null, 1], | ||
[3600 * 24 * 28, null, null, null, null, null, null, null, 1], | ||
[3600 * 24, null, null, null, null, null, null, null, 1], | ||
[3600, "{HH}", null, null, null, null, null, null, 1], | ||
[60, "{HH}:{mm}", null, null, null, null, null, null, 1], | ||
[1, ":{ss}", null, null, null, null, null, null, 1], | ||
[0.001, ":{ss}.{fff}", null, null, null, null, null, null, 1] | ||
] | ||
|
||
const getAxisValues = (unit: UnitType, index: number) => { | ||
if (index === 0) { | ||
return dateFormats | ||
} | ||
|
||
return (_: uPlot, ticks: number[]) => ticks.map((val) => format(unit, val)) | ||
} | ||
|
||
const createAxis = (length: number) => { | ||
return (unit: UnitType, index: number) => { | ||
const axis: Axis = { | ||
stroke: common.black, | ||
grid: { stroke: grey[100] }, | ||
ticks: { stroke: grey[100] }, | ||
values: getAxisValues(unit, index), | ||
scale: unit | ||
} | ||
|
||
if (index === 2 && length > 2) { | ||
axis.side = AXIS_SIDE | ||
} | ||
|
||
if (index !== 0) { | ||
axis.size = AXIS_SIZE | ||
} | ||
|
||
return axis | ||
} | ||
} | ||
|
||
interface CreateOptionsProps { | ||
plot: SeriesPlot | ||
width: number | ||
} | ||
|
||
export const createOptions = ({ plot, width }: CreateOptionsProps): Options => { | ||
const units = plot.samples.units | ||
const axes = units.map(createAxis(units.length)) | ||
|
||
return { | ||
class: styles.uplot, | ||
width: width, | ||
height: 250, | ||
cursor: { sync: { key: sync.key } }, | ||
legend: { live: false }, | ||
series: plot.series as Series[], | ||
axes: axes, | ||
plugins: [tooltipPlugin(common.white)] | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@szkiba I've messed around with these formats to remove the date, could you take a look at this and confirm whether it's okay?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seem ok for me