Skip to content

Commit d546231

Browse files
authored
Add password requirements and privacy policy (#6)
* Refactor search bar input event handling for improved readability and performance * Refactor components and enhance authentication page - Simplified year string logic in Footer component. - Consolidated destructuring in RecipeCard component for cleaner code. - Streamlined product filtering logic in SearchBar component. - Improved authentication page with password requirements and icons for validation. - Added check and x SVG icons for password requirement indicators. - Updated global CSS for consistent styling and improved variable usage. * Refactor authentication form components and styles for improved structure and readability * Enhance form field styles for user validation feedback * Refactor password requirements styling for improved layout consistency * Adjust body height calculation for improved layout consistency * Rename task label from "Start Dev Server" to "Astro Dev Server" for clarity * Add conditional class to main element and adjust media query breakpoint * Fix focus going to running task after "Prettify Current File" task closed * Add presentation options to "Prettify Current File" task for improved user experience * Enhance form field validation styles by adding user-valid state and correcting gradient opacity * Refactor font sizes across components to use CSS variables for consistency and improved readability * Add styles for markdown component layout and adjust h1 margin * Remove unused styles from privacy page to clean up code * Add comment to clarify small screen font size adjustments for readability
1 parent 32349d5 commit d546231

17 files changed

Lines changed: 432 additions & 239 deletions

.vscode/tasks.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"version": "2.0.0",
33
"tasks": [
44
{
5-
"label": "Start Dev Server",
5+
"label": "Astro Dev Server",
66
"type": "shell",
77
"command": "npm run dev",
88
"runOptions": {
@@ -11,7 +11,6 @@
1111
"presentation": {
1212
"clear": true,
1313
"close": true,
14-
"focus": true,
1514
"panel": "dedicated",
1615
"showReuseMessage": false
1716
}
@@ -32,7 +31,7 @@
3231
"type": "shell",
3332
"command": "npx prettier --write ${file}",
3433
"presentation": {
35-
"close": true
34+
"showReuseMessage": false
3635
}
3736
}
3837
]

package-lock.json

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

src/components/Footer.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ const yearString = currentYear === baseYear ? baseYear.toString() : `${baseYear}
5656
@media screen and (width<=850px) {
5757
footer > div {
5858
flex-direction: column;
59-
font-size: 1rem;
59+
font-size: var(--font-size-small);
6060
gap: 0;
6161
}
6262
}

src/components/FormField.astro

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
import '../styles/form_field.css'
3+
4+
const { id, type, name, label } = Astro.props
5+
---
6+
7+
<Fragment>
8+
<div class="form-field">
9+
<input type={type} id={id} name={name} required />
10+
<label for={id}>{label}</label>
11+
</div>
12+
</Fragment>

src/components/Header.astro

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ const { canSearch = false } = Astro.props || {}
2525

2626
<style>
2727
h1 {
28+
font-size: var(--font-size-title);
2829
text-wrap: nowrap;
2930
}
3031

@@ -77,10 +78,6 @@ const { canSearch = false } = Astro.props || {}
7778
margin: 0;
7879
}
7980

80-
h1 {
81-
font-size: 1.75rem;
82-
}
83-
8481
svg {
8582
width: calc(1.5 * var(--spacing-medium));
8683
height: calc(1.5 * var(--spacing-medium));

src/components/PasswordField.astro

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
---
2+
const { id, name, label } = Astro.props
3+
import IconShowPassword from '../assets/icon/eye.svg'
4+
import IconHidePassword from '../assets/icon/eye-off.svg'
5+
---
6+
7+
<Fragment>
8+
<div class="form-field">
9+
<div class="input-with-icon">
10+
<input type="password" id={id} name={name} required />
11+
<label for={id}>{label}</label>
12+
<div class="icons" title="Toggle password visibility">
13+
<IconShowPassword class="show-password" />
14+
<IconHidePassword class="hide-password" />
15+
</div>
16+
</div>
17+
</div>
18+
</Fragment>
19+
20+
<style>
21+
.hide-password {
22+
display: none;
23+
}
24+
25+
.icons {
26+
cursor: pointer;
27+
}
28+
29+
.input-with-icon {
30+
display: flex;
31+
}
32+
33+
.show-password {
34+
color: #888;
35+
}
36+
</style>
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
---
2+
import PasswordRequirementsCheck from './PasswordRequirementsCheck.astro'
3+
---
4+
5+
<div id="password-requirements">
6+
<h3>Password requirements</h3>
7+
<ul>
8+
<PasswordRequirementsCheck description="At least 12 characters long." />
9+
<PasswordRequirementsCheck description="Contains at least one uppercase letter (A-Z)." />
10+
<PasswordRequirementsCheck description="Contains at least one lowercase letter (a-z)." />
11+
<PasswordRequirementsCheck description="Contains at least one digit (0-9)." />
12+
<PasswordRequirementsCheck
13+
description="Contains at least one special character (non-alphanumeric)."
14+
/>
15+
</ul>
16+
</div>
17+
18+
<style>
19+
ul {
20+
list-style: none;
21+
}
22+
</style>
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
---
2+
import IconCheck from '../assets/icon/check.svg'
3+
import IconX from '../assets/icon/x.svg'
4+
5+
const { description } = Astro.props
6+
---
7+
8+
<Fragment>
9+
<li>
10+
<IconCheck class="password-requirement-check" />
11+
<IconX class="password-requirement-x" />
12+
<span>{description}</span>
13+
</li>
14+
</Fragment>
15+
16+
<style>
17+
li {
18+
display: flex;
19+
gap: var(--spacing-small);
20+
align-items: center;
21+
}
22+
23+
.password-requirement-check,
24+
.password-requirement-x {
25+
width: 1.75rem;
26+
min-width: 1.75rem;
27+
}
28+
29+
.password-requirement-check {
30+
color: var(--color-success);
31+
}
32+
33+
.password-requirement-x {
34+
color: var(--color-error);
35+
}
36+
37+
.password-requirement-check {
38+
display: none;
39+
}
40+
</style>

src/components/RecipeCard.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ function randint(min: number, max: number) {
3030

3131
<style>
3232
h1 {
33-
font-size: calc(1.5 * var(--spacing-medium));
33+
font-size: var(--font-size-title);
3434
}
3535

3636
.recipe-polaroid {

src/components/SearchBar.astro

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ const { placeholder } = Astro.props
1818
border: none;
1919
border-bottom: 2px solid var(--color-primary);
2020
flex: 1;
21-
font-size: 1.5rem;
21+
font-size: var(--font-size-body);
2222
outline: none;
2323
}
2424

0 commit comments

Comments
 (0)