Skip to content
Open
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
37 changes: 36 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,31 @@
<title>Azure Speed Test 2.0</title>
<link rel="icon" type="image/png" href="/favicon.png" />
<style>
:root {
--background-color: #ffffff;
--text-color: #000000;
--table-background-color: #ffffff;
--table-header-background-color: #f8f9fa;
--table-row-background-color: #ffffff;
--table-row-hover-background-color: #f1f1f1;
}

@media (prefers-color-scheme: dark) {
:root {
--background-color: #121212;
--text-color: #ffffff;
--table-background-color: #1e1e1e;
--table-header-background-color: #2c2c2c;
--table-row-background-color: #1e1e1e;
--table-row-hover-background-color: #333333;
}
}

body {
background-color: var(--background-color);
color: var(--text-color);
}

.container {
/*width: 970px;*/
}
Expand All @@ -23,11 +48,21 @@

.results-table {
margin-bottom: 75px;
background-color: var(--table-background-color);
}

tr {
display: flex;
width: 100%;
background-color: var(--table-row-background-color);
}

tr:hover {
background-color: var(--table-row-hover-background-color);
}

th {
background-color: var(--table-header-background-color);
}

td,
Expand Down Expand Up @@ -68,4 +103,4 @@ <h1 class="display-4">Azure Speed Test 2.0</h1>
<script src="index.min.js"></script>
</body>

</html>
</html>
33 changes: 32 additions & 1 deletion index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,36 @@ function render(jsx) {
const Table = class extends React.Component {
constructor(props) {
super(props)
this.state = {
darkMode: window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches
}
this.renderButton = this.renderButton.bind(this)
this.renderFlag = this.renderFlag.bind(this)
this.renderRow = this.renderRow.bind(this)
this.renderError = this.renderError.bind(this)
this.toggleDarkMode = this.toggleDarkMode.bind(this)
}

componentDidMount() {
if (window.matchMedia) {
window.matchMedia('(prefers-color-scheme: dark)').addEventListener('change', this.handleSystemDarkModeChange)
}
}

componentWillUnmount() {
if (window.matchMedia) {
window.matchMedia('(prefers-color-scheme: dark)').removeEventListener('change', this.handleSystemDarkModeChange)
}
}

handleSystemDarkModeChange = (e) => {
this.setState({ darkMode: e.matches })
}

toggleDarkMode() {
this.setState(prevState => ({ darkMode: !prevState.darkMode }))
}

renderButton() {
let item = this.props.history[0]

Expand Down Expand Up @@ -113,9 +138,15 @@ const Table = class extends React.Component {
}

render() {
const { darkMode } = this.state
const tableClassName = darkMode ? 'table results-table dark-mode' : 'table results-table'

return (
<div>
<table className="table results-table">
<button onClick={this.toggleDarkMode} className="btn btn-secondary">
Toggle Dark Mode
</button>
<table className={tableClassName}>
<thead>
<tr>
<th>Data Center</th>
Expand Down