Skip to content

Instantly share code, notes, and snippets.

@bholmesdev
Last active August 13, 2022 17:56
Show Gist options
  • Save bholmesdev/03be27b9a671340bebdfc487da8fd487 to your computer and use it in GitHub Desktop.
Save bholmesdev/03be27b9a671340bebdfc487da8fd487 to your computer and use it in GitHub Desktop.
Prismic x Astro newsletter challenge
<style is:global>
:root {
--font-size-base: clamp(1rem, 0.34vw + 0.91rem, 1.19rem);
--font-size-lg: clamp(1.2rem, 0.7vw + 1.2rem, 1.5rem);
--font-size-xl: clamp(2.44rem, 2.38vw + 1.85rem, 3.75rem);
--color-text: #F4E7FF;
--color-text-secondary: #C3B6FE;
--grey-1: #0F172A;
--grey-2: #1D293B;
--grey-3: #344155;
--box-shadow-glow: #6A21A7 0 1px 5px;
--space-gradient: linear-gradient(#0F172A 70%, #240240);
}
html {
font-family: system-ui, sans-serif;
font-size: var(--font-size-base);
color: var(--color-text);
background-size: 100% max(100vh, 100%);
}
body {
margin: 0;
background: url('https://astro.build/stars.png'), var(--space-gradient);
height: 100%;
min-height: 100vh;
}
a, a:visited {
color: var(--color-text-secondary);
text-decoration: none;
transition: background-color 0.2s;
border-radius: 0.2rem;
}
a:hover, a:focus-visible {
background-color: var(--grey-2);
}
</style>
---
import Layout from '../layouts/Layout.astro';
---
<Layout title="Welcome to Astro.">
<main>
<h1>Welcome to <span class="text-gradient">Star Gazers</span></h1>
</main>
</Layout>
<style>
:root {
--astro-gradient: linear-gradient(0deg, #4f39fa, #da62c4);
}
h1 {
margin: 2rem 0;
}
main {
margin: auto;
padding: 1em;
max-width: 60ch;
}
.text-gradient {
font-weight: 900;
background-image: var(--astro-gradient);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-size: 100% 200%;
background-position-y: 100%;
border-radius: 0.4rem;
animation: pulse 4s ease-in-out infinite;
}
@keyframes pulse {
0%,
100% {
background-position-y: 0%;
}
50% {
background-position-y: 80%;
}
}
</style>
<!--src/components/Image.svelte-->
<script>
export let title = '';
export let url = '';
export let alt = '';
export let media_type = 'image';
</script>
<figure>
{#if media_type === 'image'}
<img class="media" src={url} alt={alt} />
{:else}
<!--for videos and other media, embed with an iframe-->
<iframe class="media" title={title} width="500" height="300" src={url}></iframe>
{/if}
<figcaption>
<!--slot extra information like a "learn more" link or image description-->
<slot name="figcaption" />
</figcaption>
</figure>
<style>
figure {
background: var(--grey-1);
border: 2px solid var(--grey-2);
box-shadow: var(--box-shadow-glow);
border-radius: 0.5rem;
margin: 0;
padding-bottom: 1rem;
}
figcaption {
padding-inline: 1rem;
}
.media {
width: 100%;
height: auto;
aspect-ratio: 16 / 10;
object-fit: cover;
border-radius: inherit;
border: none;
}
</style>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment