Skip to content

Commit

Permalink
added new option logo
Browse files Browse the repository at this point in the history
  • Loading branch information
cenfun committed Nov 23, 2024
1 parent ea47bae commit 70bf7f7
Show file tree
Hide file tree
Showing 9 changed files with 50 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## Changelog

* 2.9.11
- added new option `logo`

* 2.9.10
- fixed UI highlight
- fixed UI icons
Expand Down
Binary file added docs/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
17 changes: 17 additions & 0 deletions docs/logo.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 lib/default/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ module.exports = () => ({
// the report name
name: '',

// image url (supports data url)
logo: null,

// the output html file path (relative process.cwd)
outputFile: './monocart-report/index.html',

Expand Down
1 change: 1 addition & 0 deletions lib/generate-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ const generateData = async (results) => {
const reportData = {
// for report title
name: reportName,
logo: options.logo,

date,
dateH,
Expand Down
6 changes: 6 additions & 0 deletions lib/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ export type MonocartReporterOptions = {
/** the report name */
name?: string;

/**
* image url, supports data url:
* `data:image/png;base64,${fs.readFileSync('path-to/your-logo.png').toString('base64')}`
*/
logo?: string;

/** the output file path (relative process.cwd) */
outputFile?: string;

Expand Down
2 changes: 2 additions & 0 deletions lib/merge-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ const mergeDataList = async (dataList, options) => {
});

const reportName = options.name || mergedData.name;
const reportLogo = options.logo || mergedData.logo;

const date = Math.min.apply(null, startDates);
const dateH = new Date(date).toLocaleString();
Expand All @@ -342,6 +343,7 @@ const mergeDataList = async (dataList, options) => {

Object.assign(mergedData, {
name: reportName,
logo: reportLogo,

date,
dateH,
Expand Down
14 changes: 14 additions & 0 deletions packages/app/src/app.vue
Original file line number Diff line number Diff line change
Expand Up @@ -498,6 +498,7 @@ const init = async () => {
state.columns = cloneColumns;
state.title = reportData.name;
state.logo = reportData.logo;
state.date = reportData.dateH;
state.duration = reportData.durationH;
state.mermaid = reportData.mermaid;
Expand Down Expand Up @@ -654,6 +655,13 @@ window.addEventListener('message', (e) => {
gap="10px"
wrap
>
<img
v-if="state.logo"
class="mcr-logo"
:src="state.logo"
alt=""
>

<div class="mcr-title">
<a href="./">{{ state.title }}</a>
</div>
Expand Down Expand Up @@ -1174,6 +1182,12 @@ a:not([href], [class]):hover {
color: #fff;
background-color: #24292f;
.mcr-logo {
display: block;
max-height: 32px;
overflow: hidden;
}
.mcr-title {
height: 22px;
font-size: 18px;
Expand Down
4 changes: 4 additions & 0 deletions tests/playwright.config.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const EC = require('eight-colors');
const fs = require('fs');

// for local test
process.env.PASSWORD = 'my-password';
Expand Down Expand Up @@ -91,6 +92,9 @@ module.exports = {

zip: '.temp/monocart-zip/mr.zip',

// image url (supports data url)
logo: `data:image/png;base64,${fs.readFileSync('docs/logo.png').toString('base64')}`,

attachmentPath: (currentPath, extras) => {
// console.log(currentPath, extras);
// return `https://cenfun.github.io/monocart-reporter/${relativePath}`;
Expand Down

0 comments on commit 70bf7f7

Please sign in to comment.