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

adding header, cards, and table to Report view #1203

Merged
merged 8 commits into from
Sep 8, 2023
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ js_library(
"//:node_modules/react-dom",
"//experimental/reporting-ui/src/main/react/reporting-ui/client",
"//experimental/reporting-ui/src/main/react/reporting-ui/model/reporting",
"//experimental/reporting-ui/src/main/react/reporting-ui/public/asset/font",
],
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,6 @@ module.exports = {
plugins: [new MiniCssExtractPlugin()],
devServer: {
static: path.resolve(__dirname, '../../../public'),
historyApiFallback: true,
},
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
load("@aspect_rules_js//js:defs.bzl", "js_library")

package(
default_visibility = [
"//experimental/reporting-ui/src/main/react/reporting-ui:__subpackages__",
],
)

js_library(
name = "card_wrapper",
srcs = [
"card_wrapper.tsx",
],
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
// Copyright 2023 The Cross-Media Measurement Authors
//
// 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 React from 'react';
import Card from 'react-bootstrap/Card';

type props = {
cardId: string,
title: string,
content: string,
};

const COMPONENT_STYLE = Object.freeze({
borderRadius: '12px',
boxShadow: '0px 2px 6px 2px rgba(0, 0, 0, 0.15), 0px 1px 2px 0px rgba(0, 0, 0, 0.30)',
});

export function CardWrapper({cardId, title, content}: props) {
return (
<Card id={cardId} style={COMPONENT_STYLE}>
<Card.Body>
<Card.Title>{title}</Card.Title>
<Card.Text>{content}</Card.Text>
</Card.Body>
</Card>
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ 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. */

@font-face {
font-family: open-sans-light;
src: url(./public/asset/font/open-sans-light.ttf);
}

body {
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@

import React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import {routes} from './route';
import reportWebVitals from './report_web_vitals';
import AppConfig from './client/initialize';
import { ReportingClientImpl } from './client/reporting/client_impl';
import {createBrowserRouter, RouterProvider} from 'react-router-dom';
import './index.css';
import 'bootstrap/dist/css/bootstrap.min.css';

const configProps = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ js_library(
name = "font",
srcs = glob(
include = [
"open-san-light.ttf",
"open-sans-light.ttf",
],
),
)
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
<!DOCTYPE html>
<html lang="en">
<head>
<base href="/" />
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
load("@aspect_rules_js//js:defs.bzl", "js_library")

package(
default_visibility = [
"//experimental/reporting-ui/src/main/react/reporting-ui:__subpackages__",
],
)

js_library(
name = "formatting",
srcs = [
"formatting.ts",
],
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// Copyright 2023 The Cross-Media Measurement Authors
//
// 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.

// In powers of 10
const MAGNITUDES = Object.freeze({
3: 'K',
6: 'M',
9: 'B',
12: 'T',
});

export const formatNumberWithMagnitude = (
num: number,
decimals: number,
trailingZeros: boolean = false,
) => {
let power = 0;
let newNumber = num;
while (newNumber >= 1000) {
newNumber = newNumber / 1000;
power += 3;
}

if (power === 0) {
return num.toString();
} else {
const value = (newNumber.toFixed(decimals));

return trailingZeros ?
value.toString() + MAGNITUDES[power]
: value.toString().replace(/\.0+$/, '') + MAGNITUDES[power]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ js_library(
"report_view.tsx",
],
deps = [
"//experimental/reporting-ui/src/main/react/reporting-ui/view/report/component:terminal_report",
"//experimental/reporting-ui/src/main/react/reporting-ui/view_model/report",
],
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
load("@aspect_rules_js//js:defs.bzl", "js_library")

package(
default_visibility = [
"//experimental/reporting-ui/src/main/react/reporting-ui/view/report:__subpackages__",
],
)

js_library(
name = "terminal_report",
srcs = [
"header.css",
"header.tsx",
"overview.css",
"overview.tsx",
"overview_card.tsx",
"publisher_cell.tsx",
"summary_table.css",
"summary_table.tsx",
"summary_table_row.tsx",
"terminal_report.tsx",
],
deps = [
"//experimental/reporting-ui/src/main/react/reporting-ui/component/card_wrapper",
"//experimental/reporting-ui/src/main/react/reporting-ui/public/asset/icon",
"//experimental/reporting-ui/src/main/react/reporting-ui/util:formatting",
],
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/* Copyright 2023 The Cross-Media Measurement Authors

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. */

#header-title {
color: #000000;
font-family: open-sans-light;
font-size: 22px;
font-style: normal;
font-weight: 400;
line-height: 28px;
}

#get-report-header-menu {
margin: 0px 8px 0px 32px;
}

#header-collapse > svg {
margin-right: 8px;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// Copyright 2023 The Cross-Media Measurement Authors
//
// 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 React from 'react';
import Navbar from 'react-bootstrap/Navbar';
import {
AddIcon,
DownloadIcon,
FilterIcon,
MenuIcon,
TrailingIcon,
} from '../../../public/asset/icon';
import './header.css';

type HeaderProps = {
reportName: string;
};

export function Header({reportName}: HeaderProps) {
return (
<React.Fragment>
<Navbar id="get-report-header" className="bg-body-tertiary">
<div id="get-report-header-menu">
<MenuIcon />
</div>
<Navbar.Brand id="header-title">{reportName}</Navbar.Brand>
<Navbar.Toggle />
<Navbar.Collapse id="header-collapse" className="justify-content-end">
<TrailingIcon />
<FilterIcon />
<AddIcon />
<DownloadIcon />
</Navbar.Collapse>
</Navbar>
</React.Fragment>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/* Copyright 2023 The Cross-Media Measurement Authors

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. */

#report-overview {
margin: 32px 16px 0px 16px;

.col {
margin: 0px 16px 0px 16px;
padding: 0px;
}
}

#report-overview .card-title {
color: #1F1F1F;
font-family: open-sans-light;
font-size: 16px;
font-style: normal;
font-weight: 500;
line-height: 24px;
}

#report-overview .card-text {
color: #1F1F1F;
font-family: open-sans-light;
font-size: 45px;
font-style: normal;
font-weight: 400;
line-height: 52px;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Copyright 2023 The Cross-Media Measurement Authors
//
// 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 React from 'react';
import Row from 'react-bootstrap/Row';
import Col from 'react-bootstrap/Col';
import './overview.css';
import { ReportOverviewCard } from './overview_card';
import { Overview } from '../../../model/reporting';

type ReportTotalsProps = {
reportOverview: Overview;
};

export function ReportOverviewStats({reportOverview}: ReportTotalsProps) {
return (
<Row id="report-overview">
<Col>
<ReportOverviewCard id='report-overview-impressions-card' title='Impressions' value={reportOverview.totalImpressions}/>
</Col>
<Col>
<ReportOverviewCard id='report-overview-total-reach-card' title='Reach' value={reportOverview.totalReach}/>
</Col>
<Col>
<ReportOverviewCard id='report-overview-target-reach-card' title='On Target Reach' value={reportOverview.totalOnTargetReach}/>
</Col>
<Col>
<ReportOverviewCard id='report-overview-frequency-card' title='Average Frequency' value={reportOverview.totalAverageFrequency}/>
</Col>
</Row>
);
}
Loading