mirror of
https://github.com/KevinMidboe/k9e.no.git
synced 2026-01-10 03:05:54 +00:00
Initital commit simple bio page
This commit is contained in:
3
src/lib/colors.ts
Normal file
3
src/lib/colors.ts
Normal file
@@ -0,0 +1,3 @@
|
||||
const colors = ['#24d05a', '#eb4888', '#10a2f5', '#e9bc3f'];
|
||||
|
||||
export default colors;
|
||||
50
src/lib/images.svelte
Normal file
50
src/lib/images.svelte
Normal file
@@ -0,0 +1,50 @@
|
||||
<script lang="ts">
|
||||
import type IImage from '$lib/interfaces/IImage';
|
||||
|
||||
let images: IImage[] = [
|
||||
{ url: 'IMG_5613.jpeg', alt: 'Kevin at beach' },
|
||||
{ url: 'IMG_4551.jpeg', alt: 'Kevin fishing' },
|
||||
{ url: 'IMG_1925.jpeg', alt: 'Kevin in a boat with dog' }
|
||||
];
|
||||
|
||||
function cycle() {
|
||||
images.push(images.shift() || images[0]);
|
||||
images = images;
|
||||
}
|
||||
</script>
|
||||
|
||||
<div
|
||||
class="images"
|
||||
on:click={cycle}
|
||||
on:keydown={(e) => e.key === 'Enter'}
|
||||
role="button"
|
||||
tabindex="0"
|
||||
>
|
||||
{#each images as image (image.url)}
|
||||
<img src={image.url} alt={image.alt} />
|
||||
{/each}
|
||||
</div>
|
||||
|
||||
<style lang="scss">
|
||||
div.images {
|
||||
position: relative;
|
||||
display: flex;
|
||||
user-select: none;
|
||||
-webkit-user-select: none;
|
||||
margin-left: 40px;
|
||||
|
||||
img {
|
||||
position: absolute;
|
||||
margin-top: 10vh;
|
||||
max-height: 80vh;
|
||||
transition: all 0.51s ease;
|
||||
}
|
||||
|
||||
@for $i from 0 through 4 {
|
||||
img:nth-of-type(#{$i}) {
|
||||
left: calc(-10px * $i);
|
||||
top: calc(-10px * $i);
|
||||
}
|
||||
}
|
||||
}
|
||||
</style>
|
||||
6
src/lib/interfaces/IImage.ts
Normal file
6
src/lib/interfaces/IImage.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
interface IImage {
|
||||
url: string;
|
||||
alt: string;
|
||||
}
|
||||
|
||||
export type { IImage };
|
||||
6
src/lib/interfaces/ILink.ts
Normal file
6
src/lib/interfaces/ILink.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
interface ILink {
|
||||
title: string;
|
||||
url: string;
|
||||
}
|
||||
|
||||
export default ILink;
|
||||
6
src/lib/interfaces/IPersonalia.ts
Normal file
6
src/lib/interfaces/IPersonalia.ts
Normal file
@@ -0,0 +1,6 @@
|
||||
interface IPersonalia {
|
||||
length: string;
|
||||
text: string;
|
||||
}
|
||||
|
||||
export type { IPersonalia };
|
||||
25
src/lib/linkColor.svelte
Normal file
25
src/lib/linkColor.svelte
Normal file
@@ -0,0 +1,25 @@
|
||||
<script lang="ts">
|
||||
import { onMount } from 'svelte';
|
||||
import colors from './colors';
|
||||
|
||||
function getRandomColor() {
|
||||
return colors[Math.floor(Math.random() * colors.length)];
|
||||
}
|
||||
|
||||
function setRandomLinkColor() {
|
||||
Array.from(document.getElementsByTagName('a')).forEach((e) => {
|
||||
e.style.color = getRandomColor();
|
||||
});
|
||||
}
|
||||
|
||||
function setColorHoverListener() {
|
||||
Array.from(document.querySelectorAll('a, button')).forEach((e) => {
|
||||
e.addEventListener('mouseover', setRandomLinkColor);
|
||||
});
|
||||
}
|
||||
|
||||
onMount(() => {
|
||||
setRandomLinkColor();
|
||||
setColorHoverListener();
|
||||
});
|
||||
</script>
|
||||
71
src/lib/personalia.svelte
Normal file
71
src/lib/personalia.svelte
Normal file
@@ -0,0 +1,71 @@
|
||||
<script lang="ts">
|
||||
import colors from './colors';
|
||||
import type IPersonalia from '$lib/interfaces/IPersonalia';
|
||||
|
||||
const personalias: IPersonalia[] = [
|
||||
{
|
||||
length: 'short bio',
|
||||
text: 'Hello 👋 I currently work at Aller Media as DevOps Lead. I enjoy building things with my hands & head, bouldering and teaching in my free time.'
|
||||
},
|
||||
{
|
||||
length: 'long bio',
|
||||
text: 'Hello longer 👋 I currently work at Aller Media as DevOps Lead. I enjoy building things with my hands & head, bouldering and teaching in my free time.'
|
||||
}
|
||||
];
|
||||
|
||||
let selectedPersonalia = personalias[0];
|
||||
|
||||
function setSelectedPersonalia(personalia: IPersonalia) {
|
||||
selectedPersonalia = personalia;
|
||||
|
||||
const color = colors[Math.floor(Math.random() * colors.length)];
|
||||
document.documentElement.style.setProperty('--selected-color', color);
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="personalia-toggles">
|
||||
{#each personalias as p}
|
||||
<button
|
||||
on:click={() => setSelectedPersonalia(p)}
|
||||
class={selectedPersonalia.length === p.length ? 'selected' : ''}
|
||||
>
|
||||
{p.length}
|
||||
</button>
|
||||
{/each}
|
||||
</div>
|
||||
|
||||
<p>{selectedPersonalia.text}</p>
|
||||
|
||||
<style lang="scss">
|
||||
.personalia-toggles {
|
||||
margin-top: 3rem;
|
||||
}
|
||||
|
||||
button {
|
||||
width: 120px;
|
||||
height: 30px;
|
||||
border: 2px solid gray;
|
||||
border-radius: 15px;
|
||||
box-sizing: border-box;
|
||||
color: gray;
|
||||
font-size: 1rem;
|
||||
background-color: white;
|
||||
overflow: auto;
|
||||
transition: 0.2s ease all;
|
||||
|
||||
&:not(&:last-of-type) {
|
||||
margin-right: 1rem;
|
||||
}
|
||||
|
||||
&.selected {
|
||||
font-weight: bold;
|
||||
border-color: var(--selected-color);
|
||||
color: var(--selected-color);
|
||||
}
|
||||
|
||||
&:hover {
|
||||
background: rgba(150, 151, 156, 0.1);
|
||||
cursor: pointer;
|
||||
}
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user