Feat: add Tailwind CSS and Prettier configuration, create reusable components for Title, Description, and Button

This commit is contained in:
mr. M 2024-11-21 00:21:16 +01:00
parent 7bb60fdf2a
commit 8612d6da90
No known key found for this signature in database
GPG key ID: CBD57A2AEDBDA1FB
11 changed files with 1384 additions and 227 deletions

9
.prettierrc.mjs Normal file
View file

@ -0,0 +1,9 @@
/** @type {import('prettier').Config} */
export default {
printWidth: 80,
tabWidth: 2,
semi: false,
singleQuote: true,
endOfLine: "lf",
plugins: ["prettier-plugin-astro", "prettier-plugin-tailwindcss"],
};

View file

@ -1,5 +1,9 @@
// @ts-check // @ts-check
import { defineConfig } from 'astro/config'; import { defineConfig } from 'astro/config';
import tailwind from '@astrojs/tailwind';
// https://astro.build/config // https://astro.build/config
export default defineConfig({}); export default defineConfig({
integrations: [tailwind()]
});

1264
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -3,15 +3,24 @@
"type": "module", "type": "module",
"version": "0.0.1", "version": "0.0.1",
"scripts": { "scripts": {
"dev": "astro dev", "dev": "astro dev --port 3000",
"start": "astro dev", "start": "astro preview --port 3000",
"build": "astro check && astro build", "build": "astro check && astro build",
"preview": "astro preview", "preview": "astro preview --port 3000",
"astro": "astro" "astro": "astro"
}, },
"dependencies": { "dependencies": {
"astro": "^4.16.13",
"@astrojs/check": "^0.9.4", "@astrojs/check": "^0.9.4",
"@astrojs/tailwind": "^5.1.2",
"astro": "^4.16.13",
"autoprefixer": "10.4.14",
"motion": "^11.11.17",
"postcss": "8.4.21",
"prettier": "^3.3.3",
"prettier-plugin-astro": "^0.14.1",
"prettier-plugin-tailwindcss": "^0.6.6",
"sharp": "^0.33.5",
"tailwindcss": "^3.4.15",
"typescript": "^5.6.3" "typescript": "^5.6.3"
} }
} }

View file

@ -0,0 +1,15 @@
---
const { class: className, isPrimary, } = Astro.props;
---
<button class:list={['px-4 py-2 rounded-full scale-100 transition-transform duration-200', className, isPrimary ? 'bg-coral/70 text-paper hover:!transform hover:!scale-105' : 'hover:bg-coral/10']}>
<slot />
</button>
<style>
button {
font-family: "Bricolage Grotesque", sans-serif !important;
font-optical-sizing: auto;
font-style: normal;
font-variation-settings: "wdth" 100;
}
</style>

View file

@ -1,61 +0,0 @@
---
interface Props {
title: string;
body: string;
href: string;
}
const { href, title, body } = Astro.props;
---
<li class="link-card">
<a href={href}>
<h2>
{title}
<span>&rarr;</span>
</h2>
<p>
{body}
</p>
</a>
</li>
<style>
.link-card {
list-style: none;
display: flex;
padding: 1px;
background-color: #23262d;
background-image: none;
background-size: 400%;
border-radius: 7px;
background-position: 100%;
transition: background-position 0.6s cubic-bezier(0.22, 1, 0.36, 1);
box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
}
.link-card > a {
width: 100%;
text-decoration: none;
line-height: 1.4;
padding: calc(1.5rem - 1px);
border-radius: 8px;
color: white;
background-color: #23262d;
opacity: 0.8;
}
h2 {
margin: 0;
font-size: 1.25rem;
transition: color 0.6s cubic-bezier(0.22, 1, 0.36, 1);
}
p {
margin-top: 0.5rem;
margin-bottom: 0;
}
.link-card:is(:hover, :focus-within) {
background-position: 0;
background-image: var(--accent-gradient);
}
.link-card:is(:hover, :focus-within) h2 {
color: rgb(var(--accent-light));
}
</style>

View file

@ -0,0 +1,17 @@
---
const { class: className } = Astro.props;
---
<p class:list={[className]}>
<slot />
</p>
<style>
h1 {
font-size: 1.2rem;
line-height: 1;
font-family: "Bricolage Grotesque", sans-serif;
font-optical-sizing: auto;
font-style: normal;
font-variation-settings: "wdth" 100;
}
</style>

View file

@ -0,0 +1,17 @@
---
const { class: className } = Astro.props;
---
<h1 class:list={[className]}>
<slot />
</h1>
<style>
h1 {
font-size: 2.6rem;
line-height: 1.2;
margin-bottom: .4rem;
font-family: "Instrument Serif", serif;
font-weight: 400;
font-style: normal;
}
</style>

View file

@ -15,36 +15,14 @@ const { title } = Astro.props;
<link rel="icon" type="image/svg+xml" href="/favicon.svg" /> <link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<meta name="generator" content={Astro.generator} /> <meta name="generator" content={Astro.generator} />
<title>{title}</title> <title>{title}</title>
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,200..800&family=Instrument+Serif:ital@0;1&display=swap" rel="stylesheet">
</head> </head>
<body> <body class="bg-paper">
<slot /> <slot />
</body> </body>
</html> </html>
<style is:global> <style is:global>
:root {
--accent: 136, 58, 234;
--accent-light: 224, 204, 250;
--accent-dark: 49, 10, 101;
--accent-gradient: linear-gradient(
45deg,
rgb(var(--accent)),
rgb(var(--accent-light)) 30%,
white 60%
);
}
html {
font-family: system-ui, sans-serif;
background: #13151a;
}
code {
font-family:
Menlo,
Monaco,
Lucida Console,
Liberation Mono,
DejaVu Sans Mono,
Bitstream Vera Sans Mono,
Courier New,
monospace;
}
</style> </style>

View file

@ -1,123 +1,58 @@
--- ---
import Layout from '../layouts/Layout.astro'; import Layout from '../layouts/Layout.astro';
import Card from '../components/Card.astro'; import Title from '../components/Title.astro';
import Description from '../components/Description.astro';
import Button from '../components/Button.astro';
--- ---
<Layout title="Welcome to Astro."> <Layout title="Welcome to Zen">
<main> <main>
<svg <header id="header" class="h-screen w-full flex flex-col items-center justify-center absolute bg-paper gap-12">
class="astro-a" <div class="flex flex-col items-center">
width="495" <Title class:list={["text-center"]}>The browser made for <i>you</i></Title>
height="623" <Description class:list={["text-center"]}>Beautifully designed, privacy-focused, and packed with features.<br />We care about your experience, not your data.</Description>
viewBox="0 0 495 623" </div>
fill="none" <Button isPrimary>Download</Button>
xmlns="http://www.w3.org/2000/svg" </header>
aria-hidden="true" </main>
>
<path
fill-rule="evenodd"
clip-rule="evenodd"
d="M167.19 364.254C83.4786 364.254 0 404.819 0 404.819C0 404.819 141.781 19.4876 142.087 18.7291C146.434 7.33701 153.027 0 162.289 0H332.441C341.703 0 348.574 7.33701 352.643 18.7291C352.92 19.5022 494.716 404.819 494.716 404.819C494.716 404.819 426.67 364.254 327.525 364.254L264.41 169.408C262.047 159.985 255.147 153.581 247.358 153.581C239.569 153.581 232.669 159.985 230.306 169.408L167.19 364.254ZM160.869 530.172C160.877 530.18 160.885 530.187 160.894 530.195L160.867 530.181C160.868 530.178 160.868 530.175 160.869 530.172ZM136.218 411.348C124.476 450.467 132.698 504.458 160.869 530.172C160.997 529.696 161.125 529.242 161.248 528.804C161.502 527.907 161.737 527.073 161.917 526.233C165.446 509.895 178.754 499.52 195.577 500.01C211.969 500.487 220.67 508.765 223.202 527.254C224.141 534.12 224.23 541.131 224.319 548.105C224.328 548.834 224.337 549.563 224.347 550.291C224.563 566.098 228.657 580.707 237.264 593.914C245.413 606.426 256.108 615.943 270.749 622.478C270.593 621.952 270.463 621.508 270.35 621.126C270.045 620.086 269.872 619.499 269.685 618.911C258.909 585.935 266.668 563.266 295.344 543.933C298.254 541.971 301.187 540.041 304.12 538.112C310.591 533.854 317.059 529.599 323.279 525.007C345.88 508.329 360.09 486.327 363.431 457.844C364.805 446.148 363.781 434.657 359.848 423.275C358.176 424.287 356.587 425.295 355.042 426.275C351.744 428.366 348.647 430.33 345.382 431.934C303.466 452.507 259.152 455.053 214.03 448.245C184.802 443.834 156.584 436.019 136.218 411.348Z"
fill="url(#paint0_linear_1805_24383)"></path>
<defs>
<linearGradient
id="paint0_linear_1805_24383"
x1="247.358"
y1="0"
x2="247.358"
y2="622.479"
gradientUnits="userSpaceOnUse"
>
<stop stop-opacity="0.9"></stop>
<stop offset="1" stop-opacity="0.2"></stop>
</linearGradient>
</defs>
</svg>
<h1>Welcome to <span class="text-gradient">Astro</span></h1>
<p class="instructions">
To get started, open the directory <code>src/pages</code> in your project.<br />
<strong>Code Challenge:</strong> Tweak the "Welcome to Astro" message above.
</p>
<ul role="list" class="link-card-grid">
<Card
href="https://docs.astro.build/"
title="Documentation"
body="Learn how Astro works and explore the official API docs."
/>
<Card
href="https://astro.build/integrations/"
title="Integrations"
body="Supercharge your project with new frameworks and libraries."
/>
<Card
href="https://astro.build/themes/"
title="Themes"
body="Explore a galaxy of community-built starter themes."
/>
<Card
href="https://astro.build/chat/"
title="Community"
body="Come say hi to our amazing Discord community. ❤️"
/>
</ul>
</main>
</Layout> </Layout>
<style> <style is:global>
main { @keyframes welcomeFade {
margin: auto; 0% {
padding: 1rem; opacity: 0;
width: 800px; transform: translateY(-60px) scale(0.9);
max-width: calc(100% - 2rem); }
color: white; 100% {
font-size: 20px; opacity: 1;
line-height: 1.6; transform: translateY(0) scale(1);
}
} }
.astro-a {
position: absolute; @keyframes welcomeText {
top: -32px; 0% {
left: 50%; opacity: 0;
transform: translatex(-50%); transform: translateY(40px) scale(0.9);
width: 220px; }
height: auto; 100% {
z-index: -1; opacity: 1;
transform: translateY(0);
}
} }
h1 {
font-size: 4rem; #header h1 {
font-weight: 700; animation: welcomeFade .7s ease-in-out forwards;
line-height: 1;
text-align: center;
margin-bottom: 1em;
} }
.text-gradient {
background-image: var(--accent-gradient); #header p {
-webkit-background-clip: text; opacity: 0;
-webkit-text-fill-color: transparent; animation: welcomeText .7s ease-in-out forwards;
background-size: 400%; animation-delay: .8s;
background-position: 0%;
} }
.instructions {
margin-bottom: 2rem; #header button {
border: 1px solid rgba(var(--accent-light), 25%); opacity: 0;
background: linear-gradient(rgba(var(--accent-dark), 66%), rgba(var(--accent-dark), 33%)); animation: welcomeText .7s ease-in-out forwards;
padding: 1.5rem; animation-delay: 1.6s;
border-radius: 8px;
} }
.instructions code { </style>
font-size: 0.8em;
font-weight: bold;
background: rgba(var(--accent-light), 12%);
color: rgb(var(--accent-light));
border-radius: 4px;
padding: 0.3em 0.4em;
}
.instructions strong {
color: rgb(var(--accent-light));
}
.link-card-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(24ch, 1fr));
gap: 2rem;
padding: 0;
}
</style>

14
tailwind.config.mjs Normal file
View file

@ -0,0 +1,14 @@
/** @type {import('tailwindcss').Config} */
export default {
content: ['./src/**/*.{astro,html,js,jsx,md,mdx,svelte,ts,tsx,vue}'],
theme: {
extend: {
colors: {
"paper": "#F2F0E3",
"coral": "#F76F53",
"dark": "#202020",
},
},
},
plugins: [],
}