Skip to content

Commit a1bf086

Browse files
committed
updated help ui and removed border from header
1 parent 0d1ce1e commit a1bf086

File tree

4 files changed

+73
-46
lines changed

4 files changed

+73
-46
lines changed

src/assets/styles/dialog.css

Lines changed: 54 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -48,53 +48,74 @@
4848
}
4949

5050
dialog[open] {
51-
opacity: 1;
52-
transform: scaleY(1);
51+
animation: slideIn 0.3s ease-out forwards;
5352
}
5453

55-
/* Closed state of the dialog */
5654
dialog {
5755
opacity: 0;
58-
transform: scaleY(0);
59-
transition:
60-
opacity 0.7s ease-out,
61-
transform 0.7s ease-out,
62-
overlay 0.7s ease-out allow-discrete,
63-
display 0.7s ease-out allow-discrete;
64-
/* Equivalent to
65-
transition: all 0.7s allow-discrete; */
66-
}
67-
68-
/* Before-open state */
69-
/* Needs to be after the previous dialog[open] rule to take effect,
70-
as the specificity is the same */
71-
@starting-style {
72-
dialog[open] {
56+
transform: translateY(-20px);
57+
transition: opacity 0.2s ease-out;
58+
}
59+
60+
@keyframes slideIn {
61+
from {
62+
opacity: 0;
63+
transform: translateY(-20px);
64+
}
65+
66+
to {
67+
opacity: 1;
68+
transform: translateY(0);
69+
}
70+
}
71+
72+
@keyframes slideOut {
73+
from {
74+
opacity: 1;
75+
transform: translateY(0);
76+
}
77+
78+
to {
7379
opacity: 0;
74-
transform: scaleY(0);
80+
transform: translateY(20px);
7581
}
7682
}
7783

78-
/* Transition the :backdrop when the dialog modal is promoted to the top layer */
84+
dialog[closing] {
85+
animation: slideOut 0.3s ease-in forwards;
86+
pointer-events: none;
87+
}
88+
7989
dialog::backdrop {
80-
background-color: var(--dialog__bg--1);
81-
transition:
82-
display 0.7s allow-discrete,
83-
overlay 0.7s allow-discrete,
84-
background-color 0.7s;
85-
/* Equivalent to
86-
transition: all 0.7s allow-discrete; */
90+
background: rgba(0, 0, 0, 0);
91+
transition: background 0.3s ease-in-out;
8792
}
8893

8994
dialog[open]::backdrop {
90-
background-color: var(--dialog__bg--2);
95+
background: rgba(0, 0, 0, 0.5);
96+
animation: fadeIn 0.3s ease-out forwards;
9197
}
9298

93-
/* This starting-style rule cannot be nested inside the above selector
94-
because the nesting selector cannot represent pseudo-elements. */
99+
dialog[closing]::backdrop {
100+
animation: fadeOut 0.3s ease-in forwards;
101+
}
102+
103+
@keyframes fadeIn {
104+
from {
105+
background: rgba(0, 0, 0, 0);
106+
}
95107

96-
@starting-style {
97-
dialog[open]::backdrop {
98-
background-color: var(--dialog__bg--1);
108+
to {
109+
background: rgba(0, 0, 0, 0.5);
99110
}
100111
}
112+
113+
@keyframes fadeOut {
114+
from {
115+
background: rgba(0, 0, 0, 0.5);
116+
}
117+
118+
to {
119+
background: rgba(0, 0, 0, 0);
120+
}
121+
}

src/assets/styles/globals.css

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -93,16 +93,6 @@
9393
min-height: 100vh;
9494
}
9595

96-
header {
97-
grid-area: header;
98-
height: var(--header-h);
99-
border: 1px solid pink;
100-
display: flex;
101-
justify-content: space-between;
102-
align-items: center;
103-
padding-inline: 1rem;
104-
}
105-
10696
a {
10797
color: light-dark(#151414, white);
10898
}

src/components/Dialog.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
document.querySelector('dialog').addEventListener('close', (e) => {
2+
const dialog = e.target;
3+
dialog.setAttribute('closing', '');
4+
dialog.addEventListener('animationend', () => {
5+
dialog.removeAttribute('closing');
6+
}, { once: true });
7+
});

src/components/Help.astro

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ interface Props {
99
const { title, description } = Astro.props;
1010
---
1111

12-
<div id="help" class="help"></div>
12+
<div id="help" class="help">?</div>
1313
<dialog id="info" class="help-dialog">
1414
<div class="dialog-header">
1515
<h2>{title}</h2>
@@ -34,8 +34,17 @@ const { title, description } = Astro.props;
3434

3535
<style>
3636
.help {
37-
padding: 1rem;
38-
outline: 1px solid grey;
37+
display: flex;
38+
justify-content: center;
39+
align-items: center;
40+
font-size: 1.5rem;
41+
font-weight: 600;
42+
padding: 1.5rem;
43+
width: 2rem;
44+
height: 2rem;
45+
color: var(--primary);
46+
border-radius: 50%;
47+
border: 1.5px solid var(--primary);
3948
cursor: pointer;
4049
}
4150
</style>

0 commit comments

Comments
 (0)