Skip to content

Commit

Permalink
feature(frontend): improve styling
Browse files Browse the repository at this point in the history
  • Loading branch information
Data5tream committed Apr 5, 2023
1 parent 3a1017c commit 3c41858
Show file tree
Hide file tree
Showing 6 changed files with 143 additions and 6 deletions.
2 changes: 1 addition & 1 deletion frontend/src/app.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@
%sveltekit.head%
</head>
<body data-sveltekit-preload-data="hover">
<div style="display: contents">%sveltekit.body%</div>
<div class="app">%sveltekit.body%</div>
</body>
</html>
29 changes: 29 additions & 0 deletions frontend/src/lib/components/PageFooter.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<footer>
<div class="content">
&copy; {new Date().getFullYear()}, Simon Stefan Barth | <a href='https://github.com/Data5tream' target='_blank' rel='noreferrer'>Github</a>
</div>
</footer>

<style>
footer {
width: 100%;
padding: 16px 0 8px;
background: var(--c-black);
color: var(--c-white);
}
.content {
max-width: 1400px;
margin: 0 auto;
font-family: monospace;
font-size: 16px;
}
a, a:visited {
color: var(--c-white);
}
a:hover, a:active {
background: var(--c-white);
color: var(--c-black);
}
</style>
23 changes: 19 additions & 4 deletions frontend/src/lib/components/StatusEntry.svelte
Original file line number Diff line number Diff line change
@@ -1,23 +1,38 @@
<script lang="ts">
import type { Watchpoint } from '../dataprovider';
import StatusIcon from './StatusIcon.svelte';
export let data: Watchpoint;
</script>

<div class="watchpoint">
<h4>{data.watchpoint.name}</h4>
Status: {data.status}<br />
URL: <a href={data.watchpoint.url} class="url">{data.watchpoint.url}</a>
<div class="content">
Status: <StatusIcon status={data.status} />
{data.status}<br />
URL: <a href={data.watchpoint.url} class="url">{data.watchpoint.url}</a>
</div>
</div>

<style>
.watchpoint {
flex: 1 0 0;
border: 1px solid #343434;
padding: 8px;
border: 1px solid var(--c-black);
min-width: 300px;
}
h4 {
background: var(--c-black);
color: var(--c-white);
letter-spacing: 0.15em;
margin: 0;
padding: 8px;
}
.content {
padding: 16px 8px 8px;
}
.url {
font-family: monospace;
}
Expand Down
43 changes: 43 additions & 0 deletions frontend/src/lib/components/StatusIcon.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<script lang="ts">
let iconClass = '';
export let status;
const getStatusClass = (status: number): string => {
let classString = '';
if (status === 200) {
classString += ' green';
} else if (status >= 201 && status < 400) {
classString += ' yellow';
} else if (status >= 400) {
classString += ' red';
}
return classString;
};
$: if (status) iconClass = getStatusClass(status);
</script>

<span class={iconClass} />

<style>
span {
display: inline-block;
height: 0.8em;
width: 0.8em;
border-radius: 50%;
background: var(--c-gray);
}
.green {
background: var(--c-green);
}
.yellow {
background: var(--c-yellow);
}
.red {
background: var(--c-red);
}
</style>
33 changes: 33 additions & 0 deletions frontend/src/lib/main.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
:root {
--c-white: #ddd;
--c-black: #333;
--c-gray: #666;
--c-green: #4caf50;
--c-yellow: #ffeb3b;
--c-red: #f44336;
}

html,
body {
margin: 0;
padding: 0;
font-family: 'Open Sans', sans-serif;
}

.app {
display: grid;
min-height: 100vh;
grid-template-rows: 1fr auto;
}

@keyframes blink {
0% {
opacity: 1;
}
50% {
opacity: 0;
}
100% {
opacity: 1;
}
}
19 changes: 18 additions & 1 deletion frontend/src/routes/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
<script lang="ts">
import type { StatusData } from '$lib/dataprovider';
import StatusList from '$lib/components/StatusList.svelte';
import PageFooter from '$lib/components/PageFooter.svelte';
import '$lib/main.css';
export let data: { status: StatusData };
</script>
Expand All @@ -13,14 +15,29 @@
<StatusList bind:data={data.status.watchpoints} />
{/if}
</main>
<PageFooter />

<style>
main {
width: 100%;
max-width: 1400px;
margin: 0 auto;
}
h1 {
display: inline-block;
background: var(--c-black);
color: var(--c-white);
padding: 8px 16px 8px 8px;
font-family: monospace;
}
h1:after {
content: '_';
animation: blink 2s infinite;
}
.error {
color: #870606;
color: var(--c-red);
font-size: 64px;
}
</style>

0 comments on commit 3c41858

Please sign in to comment.