-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
moving react code to experimental folder
- Loading branch information
1 parent
28a4ebd
commit 113d3fa
Showing
24 changed files
with
522 additions
and
6 deletions.
There are no files selected for viewing
63 changes: 63 additions & 0 deletions
63
experimental/reporting-ui/src/main/react/reporting-ui/BUILD.bazel
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,63 @@ | ||
load("@aspect_rules_js//js:defs.bzl", "js_library") | ||
load("@npm//:defs.bzl", "npm_link_all_packages") | ||
load("@aspect_rules_webpack//webpack:defs.bzl", "webpack_bundle", "webpack_devserver") | ||
|
||
npm_link_all_packages() | ||
|
||
js_library( | ||
name = "build_node_deps", | ||
srcs = [ | ||
"//:node_modules/babel-loader", | ||
"//:node_modules/css-loader", | ||
"//:node_modules/html-webpack-plugin", | ||
"//:node_modules/mini-css-extract-plugin", | ||
"//:node_modules/react", | ||
"//:node_modules/react-dom", | ||
"//:node_modules/style-loader", | ||
"//:node_modules/ts-loader", | ||
"//:node_modules/typescript", | ||
"//:node_modules/web-vitals", | ||
"//:node_modules/webpack", | ||
], | ||
visibility = [ | ||
"//experimental/reporting-ui/src/main/react/reporting-ui:__subpackages__", | ||
"//experimental/reporting-ui/src/test/react/reporting-ui:__subpackages__", | ||
], | ||
) | ||
|
||
js_library( | ||
name = "webpack_config", | ||
srcs = ["webpack.config.js"], | ||
visibility = [ | ||
"//experimental/reporting-ui/src/main/react/reporting-ui:__subpackages__", | ||
"//experimental/reporting-ui/src/test/react/reporting-ui:__subpackages__", | ||
], | ||
) | ||
|
||
webpack_bundle( | ||
name = "webpack_bundle", | ||
srcs = [ | ||
":webpack_config", | ||
"//:tsconfig", | ||
"//experimental/reporting-ui/src/main/react/reporting-ui/public", | ||
"//experimental/reporting-ui/src/main/react/reporting-ui/src:src_files", | ||
], | ||
node_modules = "//:node_modules", | ||
output_dir = True, | ||
webpack_config = ":webpack_config", | ||
deps = [ | ||
":build_node_deps", | ||
], | ||
) | ||
|
||
webpack_devserver( | ||
name = "webpack_devserver", | ||
data = [ | ||
":build_node_deps", | ||
"//:tsconfig", | ||
"//experimental/reporting-ui/src/main/react/reporting-ui/public", | ||
"//experimental/reporting-ui/src/main/react/reporting-ui/src:src_files", | ||
], | ||
node_modules = "//:node_modules", | ||
webpack_config = ":webpack_config", | ||
) |
25 changes: 25 additions & 0 deletions
25
experimental/reporting-ui/src/main/react/reporting-ui/README.md
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,25 @@ | ||
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app) and | ||
then Bazelified. | ||
# Main Scripts | ||
|
||
Just like with stock create-react-app, we have the same developer workflow. In the project directory, you can run: | ||
|
||
## Bundle the app | ||
`bazel build //src/main/react/reporting-ui:webpack_bundle` | ||
|
||
This bundles the app into a `app.bundle.js` file to be used in deployment alongside the index.html file. | ||
|
||
## Local deployment | ||
`bazel run //src/main/react/reporting-ui:webpack_devserver` | ||
|
||
This runs the app locally. The previous bundling step is not necessary since webpack will manage the source code. This also makes it a little easier to debug since the app isn't minified (it is still converted to JS). | ||
|
||
# Additional Tools | ||
|
||
## Webpack | ||
We are using webpack to have more control over bundling the app. Other tools like `react-scripts` make some assumptions of the directory structure which don't work with this monorepo. We also have more control with Babel as a transpiler. | ||
|
||
Webpack also lets us add plugins to perform tasks like minification/uglification for bundling. | ||
|
||
## Babel | ||
This gives us more control over transpiling React/Typescript (TSX) into browser supported JS (ECMA). Babel lets us configure specific loaders which is helpful since we have both React and Typescript in addition to CSS. |
30 changes: 30 additions & 0 deletions
30
experimental/reporting-ui/src/main/react/reporting-ui/package.json
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,30 @@ | ||
{ | ||
"browserslist": { | ||
"production": [ | ||
">0.2%", | ||
"not dead", | ||
"not op_mini all" | ||
], | ||
"development": [ | ||
"last 1 chrome version", | ||
"last 1 firefox version", | ||
"last 1 safari version" | ||
] | ||
}, | ||
"pnpm": { | ||
"packageExtensions": { | ||
"@typescript-eslint/eslint-plugin": { | ||
"peerDependencies": { | ||
"eslint": "*" | ||
} | ||
}, | ||
"postcss-loader": { | ||
"peerDependencies": { | ||
"postcss-flexbugs-fixes": "*", | ||
"postcss-preset-env": "*", | ||
"postcss-normalize": "*" | ||
} | ||
} | ||
} | ||
} | ||
} |
7 changes: 7 additions & 0 deletions
7
experimental/reporting-ui/src/main/react/reporting-ui/public/BUILD.bazel
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,7 @@ | ||
load("@aspect_rules_js//js:defs.bzl", "js_library") | ||
|
||
js_library( | ||
name = "public", | ||
srcs = glob(["**"]), | ||
visibility = ["//visibility:public"], | ||
) |
Binary file added
BIN
+3.78 KB
experimental/reporting-ui/src/main/react/reporting-ui/public/favicon.ico
Binary file not shown.
55 changes: 55 additions & 0 deletions
55
experimental/reporting-ui/src/main/react/reporting-ui/public/index.html
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,55 @@ | ||
<!-- 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. --> | ||
|
||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
<meta name="theme-color" content="#000000" /> | ||
<meta | ||
name="description" | ||
content="Web site created using create-react-app" | ||
/> | ||
<!-- | ||
manifest.json provides metadata used when your web app is installed on a | ||
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/ | ||
--> | ||
<!-- | ||
Notice the use of %PUBLIC_URL% in the tags above. | ||
It will be replaced with the URL of the `public` folder during the build. | ||
Only files inside the `public` folder can be referenced from the HTML. | ||
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will | ||
work correctly both with client-side routing and a non-root public URL. | ||
Learn how to configure a non-root public URL by running `npm run build`. | ||
--> | ||
<title>React App</title> | ||
</head> | ||
<body> | ||
<noscript>You need to enable JavaScript to run this app.</noscript> | ||
<div id="root"></div> | ||
<script src="./app.bundle.js"></script> | ||
<!-- | ||
This HTML file is a template. | ||
If you open it directly in the browser, you will see an empty page. | ||
You can add webfonts, meta tags, or analytics to this file. | ||
The build step will place the bundled scripts into the <body> tag. | ||
To begin the development, run `npm start` or `yarn start`. | ||
To create a production bundle, use `npm run build` or `yarn build`. | ||
--> | ||
</body> | ||
</html> |
Binary file added
BIN
+5.22 KB
experimental/reporting-ui/src/main/react/reporting-ui/public/logo192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+9.44 KB
experimental/reporting-ui/src/main/react/reporting-ui/public/logo512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions
25
experimental/reporting-ui/src/main/react/reporting-ui/public/manifest.json
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,25 @@ | ||
{ | ||
"short_name": "React App", | ||
"name": "Create React App Sample", | ||
"icons": [ | ||
{ | ||
"src": "favicon.ico", | ||
"sizes": "64x64 32x32 24x24 16x16", | ||
"type": "image/x-icon" | ||
}, | ||
{ | ||
"src": "logo192.png", | ||
"type": "image/png", | ||
"sizes": "192x192" | ||
}, | ||
{ | ||
"src": "logo512.png", | ||
"type": "image/png", | ||
"sizes": "512x512" | ||
} | ||
], | ||
"start_url": ".", | ||
"display": "standalone", | ||
"theme_color": "#000000", | ||
"background_color": "#ffffff" | ||
} |
3 changes: 3 additions & 0 deletions
3
experimental/reporting-ui/src/main/react/reporting-ui/public/robots.txt
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 @@ | ||
# https://www.robotstxt.org/robotstxt.html | ||
User-agent: * | ||
Disallow: |
52 changes: 52 additions & 0 deletions
52
experimental/reporting-ui/src/main/react/reporting-ui/src/App.css
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,52 @@ | ||
/* 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. */ | ||
|
||
.App { | ||
text-align: center; | ||
} | ||
|
||
.App-logo { | ||
height: 40vmin; | ||
pointer-events: none; | ||
} | ||
|
||
@media (prefers-reduced-motion: no-preference) { | ||
.App-logo { | ||
animation: App-logo-spin infinite 20s linear; | ||
} | ||
} | ||
|
||
.App-header { | ||
background-color: #282c34; | ||
min-height: 100vh; | ||
display: flex; | ||
flex-direction: column; | ||
align-items: center; | ||
justify-content: center; | ||
font-size: calc(10px + 2vmin); | ||
color: white; | ||
} | ||
|
||
.App-link { | ||
color: #61dafb; | ||
} | ||
|
||
@keyframes App-logo-spin { | ||
from { | ||
transform: rotate(0deg); | ||
} | ||
to { | ||
transform: rotate(360deg); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
experimental/reporting-ui/src/main/react/reporting-ui/src/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 |
---|---|---|
@@ -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. | ||
|
||
import React from 'react'; | ||
import Logo from './logo'; | ||
import './App.css'; | ||
|
||
function App() { | ||
return ( | ||
<div className="App"> | ||
<header className="App-header"> | ||
<Logo /> | ||
<p> | ||
Edit <code>src/App.js</code> and save to reload. | ||
</p> | ||
<a | ||
className="App-link" | ||
href="https://reactjs.org" | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
> | ||
Learn React | ||
</a> | ||
</header> | ||
</div> | ||
); | ||
} | ||
|
||
export default App; |
52 changes: 52 additions & 0 deletions
52
experimental/reporting-ui/src/main/react/reporting-ui/src/BUILD.bazel
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,52 @@ | ||
load("@aspect_rules_js//js:defs.bzl", "js_library") | ||
load("@aspect_rules_ts//ts:defs.bzl", "ts_project") | ||
|
||
package( | ||
default_visibility = [ | ||
"//experimental/reporting-ui/src/main/react/reporting-ui:__pkg__", | ||
"//experimental/reporting-ui/src/test/react/reporting-ui:__pkg__", | ||
], | ||
) | ||
|
||
ASSET_PATTERNS = [ | ||
"*.svg", | ||
"*.css", | ||
] | ||
|
||
SRC_PATTERNS = [ | ||
"*.tsx", | ||
"*.ts", | ||
] | ||
|
||
js_library( | ||
name = "entry_point", | ||
srcs = ["index.tsx"], | ||
) | ||
|
||
js_library( | ||
name = "src_files", | ||
srcs = glob( | ||
include = SRC_PATTERNS + ASSET_PATTERNS, | ||
), | ||
) | ||
|
||
ts_project( | ||
name = "src_ts", | ||
srcs = glob(SRC_PATTERNS), | ||
declaration = True, | ||
resolve_json_module = True, | ||
tsconfig = "//:tsconfig", | ||
deps = [ | ||
"//:node_modules/react", | ||
"//:node_modules/react-dom", | ||
"//:node_modules/web-vitals", | ||
], | ||
) | ||
|
||
js_library( | ||
name = "src", | ||
srcs = glob(ASSET_PATTERNS), | ||
deps = [ | ||
":src_ts", | ||
], | ||
) |
27 changes: 27 additions & 0 deletions
27
experimental/reporting-ui/src/main/react/reporting-ui/src/index.css
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,27 @@ | ||
/* 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. */ | ||
|
||
body { | ||
margin: 0; | ||
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', | ||
'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', | ||
sans-serif; | ||
-webkit-font-smoothing: antialiased; | ||
-moz-osx-font-smoothing: grayscale; | ||
} | ||
|
||
code { | ||
font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New', | ||
monospace; | ||
} |
Oops, something went wrong.