Improves reusability of stylings and components

This commit is contained in:
Alicia Sykes
2023-04-22 22:23:45 +01:00
parent f39c382a91
commit 9c95bc5e82
8 changed files with 60 additions and 47 deletions

View File

@@ -1,5 +1,7 @@
<script lang="ts"> <script lang="ts">
import { slide } from 'svelte/transition'; import { slide } from 'svelte/transition';
import Button from '$lib/Button.svelte';
export let categories: string[]; export let categories: string[];
export let selectedCategories: string[]; export let selectedCategories: string[];
export let toggleCategory: (category: string) => void; export let toggleCategory: (category: string) => void;
@@ -7,11 +9,12 @@
<div class="categories" transition:slide> <div class="categories" transition:slide>
{#each Object.keys(categories) as category} {#each Object.keys(categories) as category}
<span <Button
on:click={() => toggleCategory(category)} action={() => toggleCategory(category)}
class:selected="{selectedCategories.includes(category)}" selected="{selectedCategories.includes(category)}"
class="cat" >
>{category}</span> {category}
</Button>
{/each} {/each}
</div> </div>
@@ -22,21 +25,7 @@
flex-wrap: wrap; flex-wrap: wrap;
margin: 1rem auto; margin: 1rem auto;
padding: 0 1rem; padding: 0 1rem;
gap: 0.25rem;
max-width: var(--max-width); max-width: var(--max-width);
.cat {
border: 1px solid transparent;
padding: 0 0.3rem;
margin: 0.25rem;
line-height: 2rem;
border-radius: 6px;
text-transform: capitalize;
background: var(--card);
transition: all 0.3s ease-in-out;
cursor: pointer;
font-size: 0.9rem;
&:hover, &.selected {
background: var(--gradient);
}
}
} }
</style> </style>

View File

@@ -1,11 +1,16 @@
<script lang="ts">
import Button from '$lib/Button.svelte';
import { gitHubRepo } from '$src/constants';
</script>
<header> <header>
<a class="title" href="/"> <a class="title" href="/">
<img src="https://i.ibb.co/hMymwH0/portainer-templates-small.png" /> <img src="https://i.ibb.co/hMymwH0/portainer-templates-small.png" />
<h2>Portainer Templates</h2> <h2>Portainer Templates</h2>
</a> </a>
<nav> <nav>
<a href="/">Home</a> <Button to="/">Home</Button>
<a href="https://github.com/lissy93/portainer-templates">View on GitHub</a> <Button to={gitHubRepo} icon="github">GitHub</Button>
</nav> </nav>
</header> </header>
@@ -16,6 +21,7 @@
justify-content: space-between; justify-content: space-between;
background: var(--card); background: var(--card);
padding: 0.25rem 1rem; padding: 0.25rem 1rem;
flex-wrap: wrap;
a.title { a.title {
display: flex; display: flex;
justify-content: center; justify-content: center;
@@ -39,17 +45,6 @@
nav { nav {
display: flex; display: flex;
gap: 1rem; gap: 1rem;
a {
color: var(--foreground);
text-decoration: none;
padding: 0.25rem 0.5rem;
border-radius: 6px;
transition: all 250ms ease-in-out;
&:hover {
background: var(--gradient);
transform: scale(1.05);
}
}
} }
&.fixed { &.fixed {
position: fixed; position: fixed;

View File

@@ -216,6 +216,9 @@
background: var(--card-2); background: var(--card-2);
position: relative; position: relative;
padding: 0.5rem; padding: 0.5rem;
pre {
font-size: 1rem;
}
.docker-command-copy { .docker-command-copy {
position: absolute; position: absolute;
right: 0.5rem; right: 0.5rem;

View File

@@ -1,8 +1,8 @@
<script lang="ts"> <script lang="ts">
import { slide } from 'svelte/transition'; import { slide } from 'svelte/transition';
import snarkdown from 'snarkdown'; import snarkdown from 'snarkdown';
export let content: string; export let content: string | null = null;
export let multiContent: { name: string, content: string, description: string, visible: false }[]; export let multiContent: { name: string, content: string, description: string, visible: false }[] | null = null;
let showDocs = false; let showDocs = false;

View File

@@ -1,5 +1,39 @@
<script lang="ts">
import { browser } from '$app/environment';
import { page, navigating } from '$app/stores';
import { tick } from 'svelte';
import Header from '$lib/Header.svelte';
import Footer from '$lib/Footer.svelte';
let bottom = false;
let showNav = false;
const scrollVisible = (): boolean => {
return browser ?
document.documentElement.clientHeight >= document.documentElement.scrollHeight
: false;
};
$: {
updateFooter();
if($navigating) updateFooter();
showNav = !['/', '/index'].includes($page.url.pathname)
}
async function updateFooter() {
await tick();
bottom = scrollVisible();
}
</script>
{#if showNav}
<Header />
{/if}
<main>
<slot></slot>
</main>
<Footer {bottom} />
<slot></slot>
<style lang="scss"> <style lang="scss">
@import url('https://fonts.googleapis.com/css2?family=Kanit:wght@200;400;800&display=swap'); @import url('https://fonts.googleapis.com/css2?family=Kanit:wght@200;400;800&display=swap');
@@ -21,5 +55,8 @@
background: var(--accent); background: var(--accent);
color: var(--background); color: var(--background);
} }
main {
padding: 2rem;
}
</style> </style>

View File

@@ -90,5 +90,3 @@
<NoResults /> <NoResults />
{/if} {/if}
<!-- Footer showing license and source code links -->
<Footer />

View File

@@ -2,8 +2,6 @@
import { page } from '$app/stores'; import { page } from '$app/stores';
import Header from '$lib/Header.svelte';
import Footer from '$lib/Footer.svelte';
import ServiceStats from '$lib/ServiceStats.svelte'; import ServiceStats from '$lib/ServiceStats.svelte';
import TemplateNotFound from '$lib/TemplateNotFound.svelte'; import TemplateNotFound from '$lib/TemplateNotFound.svelte';
import DockerStats from '$lib/DockerStats.svelte'; import DockerStats from '$lib/DockerStats.svelte';
@@ -31,8 +29,6 @@
</script> </script>
<Header />
{#if template} {#if template}
<section class="summary-section"> <section class="summary-section">
<h1> <h1>
@@ -92,7 +88,6 @@
<TemplateNotFound templateName={urlSlug} /> <TemplateNotFound templateName={urlSlug} />
{/if} {/if}
<Footer />
<style lang="scss"> <style lang="scss">
section { section {

View File

@@ -1,9 +1,5 @@
<script lang="ts"> <script lang="ts">
import InstallationInstructions from '$lib/InstallationInstructions.svelte'; import InstallationInstructions from '$lib/InstallationInstructions.svelte';
import Header from '$lib/Header.svelte';
import Footer from '$lib/Footer.svelte';
</script> </script>
<Header />
<InstallationInstructions /> <InstallationInstructions />
<Footer bottom />