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

refactor(front): remove CSS libs and evolve feed and header design #414

Merged
merged 6 commits into from
Nov 22, 2020
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
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: lint
uses: golangci/golangci-lint-action@v0.1.7
uses: golangci/golangci-lint-action@v2
with:
version: v1.28
github-token: ${{ secrets.GITHUB_TOKEN }}
Expand Down
1 change: 1 addition & 0 deletions web/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@
npm-debug.log*
yarn-debug.log*
yarn-error.log*
*.tmp*
4 changes: 2 additions & 2 deletions web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"axios": "^0.21.0",
"classnames": "^2.2.6",
"dayjs": "^1.9.4",
"fontsource-open-sans": "^3.0.9",
"js-cookie": "^2.2.1",
"qrcode.react": "^1.0.0",
"react": "^17.0.1",
Expand All @@ -22,7 +23,6 @@
"react-js-pull-to-refresh": "^1.2.2",
"react-router-dom": "^5.2.0",
"react-scripts": "4.0.0",
"tabler-react": "^1.30.1",
"web-vitals": "^0.2.4"
},
"scripts": {
Expand All @@ -45,7 +45,7 @@
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 firefox versions",
"last 1 safari version"
]
},
Expand Down
30 changes: 27 additions & 3 deletions web/public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,24 @@
s.parentNode.insertBefore(g, s);
})();
</script>
<script type="text/javascript">
var theme = window.localStorage.getItem("theme");
if (document.body) {
if (theme) {
document.body.setAttribute("data-theme", theme);
} else if (window.matchMedia("prefers-color-scheme: light").matches) {
document.body.setAttribute("data-theme", "light");
} else {
document.body.setAttribute("data-theme", "dark");
}
}
</script>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<a

<!-- <a
href="https://github.com/berty/yolo"
class="github-corner"
aria-label="View source on GitHub"
Expand All @@ -80,6 +93,7 @@
top: 0;
border: 0;
right: 0;
z-index: 2;
"
aria-hidden="true"
>
Expand All @@ -94,8 +108,18 @@
d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z"
fill="currentColor"
class="octo-body"
></path></svg></a
><style>
></path>
</svg>
</a> -->
<style>
.github-corner {
display: none;
}
@media (min-width: 688px) {
.github-corner {
display: initial;
}
}
.github-corner:hover .octo-arm {
animation: octocat-wave 560ms ease-in-out;
}
Expand Down
38 changes: 0 additions & 38 deletions web/src/App.css

This file was deleted.

55 changes: 20 additions & 35 deletions web/src/App.js
Original file line number Diff line number Diff line change
@@ -1,53 +1,38 @@
/* eslint-disable import/no-named-as-default */
import React, { useContext, useEffect } from "react";
import React, { useContext } from "react";
import {
BrowserRouter as Router,
Redirect,
Route,
Switch,
} from "react-router-dom";
import Error404 from "./ui/pages/Error404/Error404";
import "tabler-react/dist/Tabler.css";
import "./assets/main.scss";
import { GlobalStore, GlobalContext } from "./store/GlobalStore";
import { ThemeContext, ThemeStore } from "./store/ThemeStore";
import { ThemeStore } from "./store/ThemeStore";
import Home from "./ui/pages/Home/Home";
import { getMobileOperatingSystem } from "./util/browser";
import Header from "./ui/components/Header/Header";
import AuthedHeaderContents from "./ui/components/AuthedHeaderContents/AuthedHeaderContents";
import { PullToRefreshWrapper } from "./ui/components/PullToRefresh";

const AppRouter = () => {
const {
theme: {
bg: { page: pageBgColor },
},
} = useContext(ThemeContext);
const {
state: { userAgent },
updateState,
} = useContext(GlobalContext);
useEffect(() => {
document.body.style.backgroundColor = pageBgColor;
}, [pageBgColor]);
useEffect(() => {
if (!userAgent) {
updateState({
userAgent: getMobileOperatingSystem(),
});
}
}, [userAgent, updateState]);
const { state } = useContext(GlobalContext);

return (
<Router>
<Switch>
<Route exact path="/">
<Home />
</Route>
<Route path="/404.html">
<Error404 />
</Route>
<Route>
<Redirect to="/404.html" />
</Route>
</Switch>
<PullToRefreshWrapper>
<Header>{state.isAuthed && <AuthedHeaderContents />}</Header>
<Switch>
<Route exact path="/">
<Home />
</Route>
<Route path="/404.html">
<Error404 />
</Route>
<Route>
<Redirect to="/404.html" />
</Route>
</Switch>
</PullToRefreshWrapper>
</Router>
);
};
Expand Down
17 changes: 0 additions & 17 deletions web/src/App.test.js

This file was deleted.

30 changes: 19 additions & 11 deletions web/src/api/apiResponseGetters.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
import { getStrUpperCase, getIsArrayWithN, getIsArray } from '../util/getters'
import { BRANCH, BUILD_STATE } from '../constants'
import { BUILD_STATE } from "../constants";
import { isArray, isNonEmptyArray } from "../util/getters";

export const buildBranchIsMaster = (build) => (getStrUpperCase(build.branch) === BRANCH.MASTER)
export const oneBuildResultHasBranchMaster = (builds) =>
isArray(builds) && builds.find((build) => build.branch === "master");

export const oneBuildResultHasBranchMaster = (builds) => (getIsArray(builds) && builds.find((build) => buildBranchIsMaster(build)))
export const buildStateIsRunning = (build) =>
build &&
build.state &&
build.state.toString() === BUILD_STATE.Running.toString();

export const buildStateIsRunning = (build) => (build && build.state && build.state.toString() === BUILD_STATE.Running.toString())

export const buildsStateIsRunning = (allBuildsForMr, originalBuildList) => getIsArray(allBuildsForMr) && getIsArrayWithN(originalBuildList)
? allBuildsForMr
.filter((buildIndex) => (typeof buildIndex === 'number' && !!originalBuildList[buildIndex]))
.filter((buildIndex) => (buildStateIsRunning(originalBuildList[buildIndex])))
: []
export const buildsStateIsRunning = (allBuildsForMr, originalBuildList) =>
isArray(allBuildsForMr) && isNonEmptyArray(originalBuildList)
? allBuildsForMr
.filter(
(buildIndex) =>
typeof buildIndex === "number" && !!originalBuildList[buildIndex]
)
.filter((buildIndex) =>
buildStateIsRunning(originalBuildList[buildIndex])
)
: [];
Loading