Skip to content
Draft
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
2 changes: 1 addition & 1 deletion astro.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export default defineConfig({
delBackground: "color-mix(in oklab, var(--red) 25%, var(--mantle));",
delBorderColor: "var(--surface0)",
},
codePaddingInline: "var(--space-md)",
codePaddingInline: "2ch",
uiFontSize: "1.5rem",
codeFontSize: "1.4rem",
codeBackground: "var(--mantle)",
Expand Down
148 changes: 148 additions & 0 deletions src/components/Button.svelte
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
<script lang="ts">

import type { Snippet } from "svelte";
import { phosphorIcon } from "@data/icons";
import Icon from "@iconify/svelte";


interface Props {
children: Snippet;
style?: 'mauve' | 'peach' | 'blue' | 'green' | 'transparent';
small?: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of taking in small, it'll be better to take in an explicit width and height. We could default those to some number if we want.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

small applies to the button size in general, not just the icon size. I don't think we want to use fixed dimensions for buttons?

Copy link
Contributor

@sgoudham sgoudham Dec 22, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In that case, we should have an enum called ButtonSize or equivalent that can either be small or default.

phIconName?: string;
disabled?: boolean;
}

let { children, style, small, phIconName, disabled }: Props = $props();


let phIcon = {
body: "",
width: 0,
height: 0
}

let phIconSize = 24;

if (phIconName != null) phIcon = phosphorIcon(phIconName);
if (small) phIconSize = 16;


</script>



<button {disabled}
class="
btn
{style == null ? 'btn-default' : ''}
{style == 'mauve' ? 'btn-mauve' : ''}
{style == 'peach' ? 'btn-peach' : ''}
{style == 'green' ? 'btn-green' : ''}
{style == 'blue' ? 'btn-blue' : ''}
{style == 'transparent' ? 'btn-transparent' : ''}
{phIconName != null ? 'btn-has-icon' : ''}
{small ? 'btn-small' : ''}
"
>
{#if phIconName != null}
<Icon
width={phIconSize}
height={phIconSize}
icon={{
body: phIcon.body,
width: phIcon.width,
height: phIcon.height,
}}
/>
{/if}
{@render children()}
</button>



<style lang="scss">

@use "../styles/utils" as *;

:global(.btn-group) {
display: flex;
gap: space(sm);
flex-wrap: wrap;
}

.btn {
padding: space(sm) space(lg);

border-radius: 9999px;
border: none;
background-color: var(--surface0);

font-size: 1.6rem;
font-weight: 500;
color: var(--text);

transition: all 350ms ease-in-out;
cursor: pointer;

&-small {
padding: space(xs);
border-radius: var(--border-radius-normal);
}

&-transparent {
background-color: transparent;
}

&-transparent:hover,
&-transparent:focus {
background-color: color-mix(in srgb, transparent, var(--text) 10%);
}

&-has-icon {
display: flex;
align-items: center;
gap: space(sm);
}

&-peach,
&-mauve,
&-green,
&-blue {
background-size: 150% 100%;
background-position: top left;
font-weight: 600;
color: var(--inverted-text);

&:hover,
&:focus {
background-position: top right;
}
}

&-peach {
background-color: var(--peach);
background-image: linear-gradient(120deg, var(--peach), var(--red));
}

&-mauve {
background-color: var(--mauve);
background-image: linear-gradient(120deg, var(--pink), var(--mauve));
}

&-green {
background-color: var(--green);
background-image: linear-gradient(120deg, var(--teal), var(--green));
}

&-blue {
background-color: var(--blue);
background-image: linear-gradient(120deg, var(--blue), var(--sky));
}
}

.btn {
transition: background-position 350ms ease-in-out;
}

</style>
4 changes: 3 additions & 1 deletion src/components/PageIntro.astro
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ const { title } = Astro.props;
</section>

<style lang="scss">
@use "@styles/utils" as *;

.page-intro {
margin-block-end: var(--space-lg);
margin-block-end: space(xl);
}

.page-intro h1 {
Expand Down
6 changes: 3 additions & 3 deletions src/components/Pills.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@
</ul>

<style lang="scss">
@use "../styles/utils";
@use "../styles/utils" as *;

.pill-list {
@include utils.flex($gap: var(--space-xs));
@include flexbox($gap: space(xs));

margin: 0;
padding: 0;
Expand All @@ -22,7 +22,7 @@
}

.pill {
@include utils.containerPadding(xxs-y);
padding: space(xs) space(sm);

border-radius: 9999px;
background-color: color-mix(in srgb, var(--base), var(--subtext0) 20%);
Expand Down
2 changes: 1 addition & 1 deletion src/data/icons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const phIcons = phIconsJson as IconifyJSONIconsData;

const DEFAULT_VIEWBOX = 16;

const phosphorIcon = (name: string) => {
export const phosphorIcon = (name: string) => {
const icon = phIcons.icons[name];
return {
body: icon.body,
Expand Down
25 changes: 9 additions & 16 deletions src/layouts/Default.astro
Original file line number Diff line number Diff line change
Expand Up @@ -22,28 +22,21 @@ const { title, description, ogImage, accent, enableViewTransition } = Astro.prop
<Skeleton>
<Head slot="seo" {title} {description} {ogImage} {accent} {enableViewTransition} />

<section class="header-container">
<div class="content-wrapper no-padding">
<Navigation />
</div>
</section>
<Navigation />

<div class="content-wrapper main-container">
<slot />
</div>
<slot />

<section class="footer-container">
<div class="content-wrapper no-padding">
<Footer />
</div>
<section class="full-width footer-container">
<Footer />
<AccentBar />
</section>
</Skeleton>

<style lang="scss">
.main-container {
container-type: inline-size;
margin-block-end: var(--space-xl);
min-height: 100vh;
@use "@styles/utils" as *;

.footer-container {
margin-block-start: space(xl);
background-color: var(--mantle);
}
</style>
36 changes: 25 additions & 11 deletions src/layouts/Landing.astro
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const { title, description, ogImage, accent } = Astro.props;

<Skeleton>
<Head slot="seo" title={title} description={description} ogImage={ogImage} accent={accent} />
<div id="hero">
<div id="hero full-width">
<div class="content-wrapper no-padding hero-grid">
<div class="hero-content-wrapper">
<div class="hero-logo">
Expand All @@ -38,16 +38,30 @@ const { title, description, ogImage, accent } = Astro.props;
</div>
</div>

<section class="footer-container">
<div class="content-wrapper no-padding">
<section class="full-width footer-container">
<div class="content-wrapper">
<Footer />
</div>
<AccentBar />
</section>
</Skeleton>

<style lang="scss" is:global>
@use "@styles/utils";
@use "@styles/utils" as *;

.content-wrapper {
container-type: inline-size;
container-name: content-wrapper;
width: 100%;
max-width: calc(2 * var(--padding-body) + var(--website-max-width));
margin-inline: auto;
padding: space(md) var(--padding-body);
}

.footer-container {
margin-block-start: space(xl);
background-color: var(--mantle);
}

#hero {
background-color: color-mix(in srgb, var(--base), var(--mauve) 10%);
Expand All @@ -68,7 +82,7 @@ const { title, description, ogImage, accent } = Astro.props;
}

.hero-logo {
@include utils.flex($gap: var(--space-sm));
@include flexbox($gap: space(md));
align-items: center;

svg + svg {
Expand All @@ -89,7 +103,7 @@ const { title, description, ogImage, accent } = Astro.props;
}

.hero-grid {
@include utils.flex($direction: column, $gap: var(--space-lg));
@include flexbox($direction: column, $gap: space(lg));
justify-content: space-between;
flex-wrap: nowrap;

Expand All @@ -106,14 +120,14 @@ const { title, description, ogImage, accent } = Astro.props;
.hero-content-wrapper {
display: grid;
grid-template-rows: max-content auto;
gap: var(--space-xl);
gap: space(xl);
container-type: inline-size;

padding-block: var(--padding-body);
}

.hero-content {
@include utils.flex($direction: column, $gap: var(--space-md));
@include flexbox($direction: column, $gap: space(lg));
justify-content: center;
align-items: flex-start;

Expand Down Expand Up @@ -143,19 +157,19 @@ const { title, description, ogImage, accent } = Astro.props;
max-height: 40vh;

svg {
padding: var(--space-md);
padding: space(md);
}

@media (min-width: 800px) {
max-height: 100vh;

svg {
@container (min-width: 400px) {
padding-inline-start: var(--space-lg);
padding-inline-start: space(lg);
}

@container (min-width: 500px) {
padding-inline-start: var(--space-xl);
padding-inline-start: space(xl);
}
}
}
Expand Down
Loading