Skip to content

Commit 6af62a7

Browse files
authored
Reproduce actual website (#2)
* Update Astro configuration and package dependencies * Add SearchBar component and integrate it into the Header; update styles and media queries * Update background gradients in SVG and adjust color variables in global CSS for improved theming * Refactor typography and SVG dimensions: update h1 font size and svg dimensions to use medium spacing for consistency * Refactor Header component: improve structure and styling for better responsiveness and consistency * Enhance Header component: implement scroll-based visibility toggle and refine layout structure in Main layout * Update SearchBar placeholder text for clarity * Refactor SearchBar styles: reorganize CSS for improved readability and maintainability * Refactor SearchBar layout: change flex property to width for better responsiveness Enhance Main layout: add margin-top for main section on small screens Update global styles: adjust polaroid photo size and width for improved layout on small devices * Add conditional rendering for SearchBar in Header component * Add authentication page with login and registration forms, including eye icons for password visibility * Update authentication page: enhance password input with visibility toggle icons and improve layout * Add vite-svg-loader to devDependencies in package.json and package-lock.json * Add vite-svg-loader plugin to Astro configuration for SVG support * Refactor icon usage in components: replace Icon component with individual SVG imports for GitHub, Contact, Privacy, Search, and Password visibility icons * Enhance password visibility toggle: add title attribute for accessibility and style adjustments
1 parent 3a952ba commit 6af62a7

16 files changed

Lines changed: 881 additions & 82 deletions

astro.config.mjs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
// @ts-check
22
import { defineConfig } from 'astro/config'
3+
import svgLoader from 'vite-svg-loader'
34

45
// https://astro.build/config
56
export default defineConfig({
6-
output: 'static',
77
build: {
88
format: 'file',
99
assets: 'compressed',
10+
assetsPrefix: './',
1011
},
12+
output: 'static',
1113
vite: {
14+
plugins: [svgLoader()],
1215
server: {
1316
watch: {
1417
usePolling: true,

package-lock.json

Lines changed: 454 additions & 36 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"astro": "^5.7.7"
1313
},
1414
"devDependencies": {
15-
"prettier": "^3.5.3"
15+
"prettier": "^3.5.3",
16+
"vite-svg-loader": "^5.1.0"
1617
}
1718
}

public/background.svg

Lines changed: 10 additions & 9 deletions
Loading

src/assets/icon/eye-off.svg

Lines changed: 6 additions & 0 deletions
Loading

src/assets/icon/eye.svg

Lines changed: 6 additions & 0 deletions
Loading

src/assets/icon/search.svg

Lines changed: 3 additions & 0 deletions
Loading

src/components/Footer.astro

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
---
22
import '../styles/global.css'
3-
import Icon from '../components/Icon.astro'
3+
import IconGitHub from '../assets/icon/brand-github.svg'
4+
import IconContact from '../assets/icon/mail-question.svg'
5+
import IconPrivacy from '../assets/icon/file-text-shield.svg'
46
57
import { SITE_NAME } from '../config.js'
68
@@ -24,14 +26,14 @@ const yearString =
2426
target="_blank"
2527
rel="noopener noreferrer"
2628
>
27-
<Icon name="brand-github" />
29+
<IconGitHub />
2830
</a>
2931
</li>
3032
<li title="Contact Us">
31-
<a href="contact.html"><Icon name="mail-question" /></a>
33+
<a href="contact.html"><IconContact /></a>
3234
</li>
3335
<li title="Privacy Policy">
34-
<a href="privacy.html"><Icon name="file-text-shield" /></a>
36+
<a href="privacy.html"><IconPrivacy /></a>
3537
</li>
3638
</ul>
3739
</footer>

src/components/Header.astro

Lines changed: 42 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,51 @@
11
---
22
import '../styles/global.css'
3-
import Icon from '../components/Icon.astro'
3+
import SearchBar from '../components/SearchBar.astro'
4+
import IconHome from '../assets/icon/home.svg'
5+
import IconUser from '../assets/icon/user-circle.svg'
46
57
import { SITE_NAME } from '../config.js'
8+
const { canSearch = false } = Astro.props || {}
69
---
710

8-
<header>
11+
<header class="show">
912
<a href="index.html" title="Home">
10-
<Icon name="home" />
13+
<IconHome />
1114
<h1>{SITE_NAME}</h1>
1215
</a>
16+
{canSearch && <SearchBar placeholder="Search for recipes..." />}
1317
<nav>
1418
<ul>
1519
<li title="Account">
16-
<a href="authentication.html"><Icon name="user-circle" /></a>
20+
<a href="authentication.html"><IconUser /></a>
1721
</li>
1822
</ul>
1923
</nav>
2024
</header>
2125

2226
<style>
27+
h1 {
28+
text-wrap: nowrap;
29+
}
30+
2331
header {
2432
background-color: var(--color-primary);
2533
display: flex;
2634
justify-content: space-between;
35+
position: fixed;
36+
gap: var(--spacing-medium);
37+
transition: transform 0.5s ease-in-out;
38+
white-space: nowrap;
2739
width: 100%;
40+
z-index: 1;
41+
}
42+
43+
header.hide {
44+
transform: translateY(-100%);
45+
}
46+
47+
header.show {
48+
transform: translateY(0);
2849
}
2950

3051
header > a {
@@ -44,7 +65,7 @@ import { SITE_NAME } from '../config.js'
4465
margin: 0 var(--spacing-medium);
4566
}
4667

47-
@media screen and (width<=850px) {
68+
@media screen and (width<=1000px) {
4869
header {
4970
align-items: center;
5071
flex-direction: column;
@@ -55,12 +76,9 @@ import { SITE_NAME } from '../config.js'
5576
header > *:last-child {
5677
margin: 0;
5778
}
58-
}
5979

60-
@media screen and (width<=850px) {
6180
h1 {
62-
font-size: calc(1.5 * var(--spacing-medium));
63-
line-height: calc(2.25 * var(--spacing-medium));
81+
font-size: 1.75rem;
6482
}
6583

6684
svg {
@@ -69,3 +87,18 @@ import { SITE_NAME } from '../config.js'
6987
}
7088
}
7189
</style>
90+
91+
<script type="module" is:inline>
92+
const header = document.querySelector('header')
93+
let lastScroll = 0
94+
95+
window.addEventListener('scroll', () => {
96+
const current = window.scrollY
97+
const scrollingDown = current > lastScroll
98+
99+
header.classList.toggle('hide', scrollingDown && current > 0)
100+
header.classList.toggle('show', !scrollingDown || current <= 0)
101+
102+
lastScroll = Math.max(current, 0)
103+
})
104+
</script>

src/components/Icon.astro

Lines changed: 0 additions & 10 deletions
This file was deleted.

0 commit comments

Comments
 (0)