Skip to content

Commit e99b4f6

Browse files
authored
Add admin panel (#9)
* Refactor styles and layout for header, recipe card, and admin page; update global styles for consistency * Add tasks for building and deleting old Git branches in VSCode configuration * Enhance admin panel layout with navigation sections and improve global styles for better alignment and spacing * Adjust main margin-top for better responsiveness on smaller screens * Implement navigation selection for admin panel and enhance user interaction * Add dynamic content display for admin panel sections with show/hide functionality * Add admin panel icon to header and remove unused submit button styles * Update glassy background effect with percentage values for improved transparency
1 parent f0c5e9a commit e99b4f6

File tree

12 files changed

+253
-39
lines changed

12 files changed

+253
-39
lines changed

.vscode/tasks.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,18 @@
1515
"showReuseMessage": false
1616
}
1717
},
18+
{
19+
"label": "Astro Build",
20+
"type": "shell",
21+
"group": "build",
22+
"command": "npm run build",
23+
"presentation": {
24+
"reveal": "always",
25+
"focus": true,
26+
"panel": "dedicated",
27+
"clear": true
28+
}
29+
},
1830
{
1931
"label": "Prettify All Files",
2032
"type": "shell",
@@ -33,6 +45,14 @@
3345
"presentation": {
3446
"showReuseMessage": false
3547
}
48+
},
49+
{
50+
"label": "Delete old Git branches",
51+
"type": "shell",
52+
"command": "git fetch --prune && git fetch -p ; git branch -r | awk '{print $1}' | egrep -v -f /dev/fd/0 <(git branch -vv | grep origin) | awk '{print $1}' | xargs git branch -D",
53+
"presentation": {
54+
"showReuseMessage": false
55+
}
3656
}
3757
]
3858
}

package-lock.json

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

src/components/Header.astro

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import '../styles/global.css'
33
import SearchBar from '../components/SearchBar.astro'
44
import IconHome from '../assets/icon/home.svg'
55
import IconUser from '../assets/icon/user-circle.svg'
6+
import IconAdminPanel from '../assets/icon/device-desktop-analytics.svg'
67
78
import { SITE_NAME } from '../config.js'
89
const { canSearch = false } = Astro.props || {}
@@ -16,6 +17,9 @@ const { canSearch = false } = Astro.props || {}
1617
{canSearch && <SearchBar placeholder="Search for recipes..." />}
1718
<nav>
1819
<ul>
20+
<li title="Admin Panel">
21+
<a href="admin.html"><IconAdminPanel /></a>
22+
</li>
1923
<li title="Account">
2024
<a href="authentication.html"><IconUser /></a>
2125
</li>
@@ -24,11 +28,6 @@ const { canSearch = false } = Astro.props || {}
2428
</header>
2529

2630
<style>
27-
h1 {
28-
font-size: var(--font-size-title);
29-
text-wrap: nowrap;
30-
}
31-
3231
header {
3332
background-color: var(--color-primary);
3433
display: flex;

src/components/RecipeCard.astro

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,6 @@ function randint(min: number, max: number) {
2929
</Fragment>
3030

3131
<style>
32-
h1 {
33-
font-size: var(--font-size-title);
34-
}
35-
3632
.recipe-polaroid {
3733
align-items: center;
3834
background-color: var(--polaroid-color);
@@ -57,7 +53,6 @@ function randint(min: number, max: number) {
5753
overflow: hidden;
5854
text-align: center;
5955
text-overflow: ellipsis;
60-
white-space: nowrap;
6156
width: calc(var(--polaroid-width) - var(--spacing-small));
6257
}
6358

src/layouts/Main.astro

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,6 @@ const { canSearch = false } = Astro.props || {}
3737
}
3838

3939
body {
40-
align-items: center;
41-
display: flex;
42-
flex-direction: column;
43-
gap: var(--spacing-large);
4440
background-color: light-dark(rgb(255 255 255 / 0.5), rgb(0 0 0 / 0.5));
4541
background-image:
4642
radial-gradient(rgb(128 128 128 / 0.05) 1px, transparent 1px),
@@ -76,11 +72,13 @@ const { canSearch = false } = Astro.props || {}
7672

7773
@media screen and (width <=1000px) {
7874
main {
79-
margin-top: calc(2 * var(--spacing-large) + 2rem);
75+
margin-top: calc(var(--spacing-large) + var(--font-size-title) + var(--spacing-medium));
8076
}
8177

8278
main.with-search {
83-
margin-top: calc(2 * var(--spacing-large) + 4rem);
79+
margin-top: calc(
80+
var(--spacing-large) + 3 * var(--font-size-title) + var(--spacing-medium)
81+
);
8482
}
8583
}
8684
</style>

src/pages/admin.astro

Lines changed: 175 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,175 @@
1+
---
2+
import '../styles/global.css'
3+
import Main from '../layouts/Main.astro'
4+
---
5+
6+
<Main title="Admin Panel">
7+
<div id="admin-panel">
8+
<section id="content">
9+
<h1>Content</h1>
10+
<nav>
11+
<ul>
12+
<li class="admin-panel-selected">Recipes</li>
13+
<li>Comments</li>
14+
<li>Media</li>
15+
</ul>
16+
</nav>
17+
<div class="admin-panel-data">
18+
<div class="show">Showing recipes</div>
19+
<div class="hide">Showing comments</div>
20+
<div class="hide">Showing media</div>
21+
</div>
22+
</section>
23+
24+
<section id="users">
25+
<h1>Users</h1>
26+
<nav>
27+
<ul>
28+
<li class="admin-panel-selected">User list</li>
29+
<li>Reports</li>
30+
<li>Flags</li>
31+
</ul>
32+
</nav>
33+
<div class="admin-panel-data">
34+
<div class="show">Showing user list</div>
35+
<div class="hide">Showing reports</div>
36+
<div class="hide">Showing flags</div>
37+
</div>
38+
</section>
39+
40+
<section id="activity">
41+
<h1>Activity</h1>
42+
<nav>
43+
<ul>
44+
<li class="admin-panel-selected">Site stats</li>
45+
<li>Trending</li>
46+
<li>Audit logs</li>
47+
</ul>
48+
</nav>
49+
<div class="admin-panel-data">
50+
<div class="show">Showing site stats</div>
51+
<div class="hide">Showing trending</div>
52+
<div class="hide">Showing audit logs</div>
53+
</div>
54+
</section>
55+
</div>
56+
</Main>
57+
58+
<style>
59+
div#admin-panel {
60+
display: grid;
61+
width: 100%;
62+
grid-template:
63+
'content users'
64+
'content activity' / 1fr 1fr;
65+
gap: var(--spacing-medium);
66+
height: 100%;
67+
justify-content: center;
68+
width: 90%;
69+
}
70+
71+
div.hide {
72+
opacity: 0;
73+
transform: translateY(-100%);
74+
}
75+
76+
div.show {
77+
opacity: 1;
78+
transform: translateY(0);
79+
}
80+
81+
div.admin-panel-data {
82+
overflow: hidden;
83+
min-height: calc(100% - var(--spacing-large) - var(--spacing-medium));
84+
}
85+
86+
div.admin-panel-data {
87+
overflow: hidden;
88+
position: relative;
89+
}
90+
91+
div.admin-panel-data > div {
92+
position: absolute;
93+
top: 0;
94+
left: 0;
95+
width: 100%;
96+
}
97+
98+
h1 {
99+
text-align: center;
100+
}
101+
102+
li.admin-panel-selected {
103+
background-color: var(--background-glassy);
104+
}
105+
106+
nav {
107+
border-bottom: 1px solid #888;
108+
}
109+
110+
nav > ul {
111+
list-style: none;
112+
display: flex;
113+
width: 100%;
114+
justify-content: space-around;
115+
}
116+
117+
nav > ul > li {
118+
border-top-left-radius: var(--border-radius-small);
119+
border-top-right-radius: var(--border-radius-small);
120+
cursor: pointer;
121+
padding: var(--spacing-small);
122+
}
123+
124+
section {
125+
border-radius: var(--border-radius-large);
126+
padding: var(--spacing-medium);
127+
}
128+
129+
section#activity {
130+
grid-area: activity;
131+
}
132+
133+
section#content {
134+
grid-area: content;
135+
}
136+
137+
section#users {
138+
grid-area: users;
139+
}
140+
141+
section#settings {
142+
grid-area: settings;
143+
}
144+
145+
@media screen and (width<=1000px) {
146+
div#admin-panel {
147+
grid-template:
148+
'content'
149+
'users'
150+
'activity' / 1fr;
151+
width: 95%;
152+
}
153+
}
154+
</style>
155+
156+
<script type="module" is:inline>
157+
document.querySelectorAll('nav > ul').forEach((menu) => {
158+
menu.addEventListener('click', (event) => {
159+
if (event.target.tagName === 'LI') {
160+
const current = menu.querySelector('.admin-panel-selected')
161+
const index = Array.from(menu.children).indexOf(event.target)
162+
const data = menu.closest('section').querySelector('.admin-panel-data')
163+
const items = data.children
164+
165+
if (current) current.classList.remove('admin-panel-selected')
166+
event.target.classList.add('admin-panel-selected')
167+
168+
Array.from(items).forEach((item, i) => {
169+
item.classList.toggle('show', i === index)
170+
item.classList.toggle('hide', i !== index)
171+
})
172+
}
173+
})
174+
})
175+
</script>

src/pages/authentication.astro

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@ import PasswordRequirements from '../components/PasswordRequirements.astro'
6666
}
6767

6868
section {
69-
background-color: light-dark(rgb(0 0 0 / 0.2), rgb(255 255 255 / 0.1));
7069
border-radius: var(--border-radius-large);
7170
display: flex;
7271
flex-direction: column;

src/pages/index.astro

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ import recipes from '../assets/recipes.json'
3535

3636
<style>
3737
#recipes-list {
38+
background-color: transparent;
3839
display: flex;
3940
flex-wrap: wrap;
4041
gap: var(--spacing-medium);

src/styles/form_field.css

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,3 @@
1-
button[type='submit'] {
2-
color: white;
3-
cursor: pointer;
4-
background-color: var(--color-secondary);
5-
border: none;
6-
border-radius: var(--border-radius-large);
7-
font-size: 1rem;
8-
padding: 1rem 2rem;
9-
}
10-
111
.form-field {
122
position: relative;
133
width: 100%;

0 commit comments

Comments
 (0)