Skip to content

Commit

Permalink
added dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
xkeshav committed Sep 25, 2024
1 parent 27da0a9 commit 3f24ea4
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/assets/styles/about.css
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
@import url('./common.css');
.container__about {
padding: 1rem;

>.moto {
color: #3a8657;
font-size: 3rem;

}
}
11 changes: 4 additions & 7 deletions src/assets/styles/common.css
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
.text-gradient {
background-image: var(--accent-gradient);
background-clip: text;
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-size: 400%;
background-position: 0%;
.hint {
padding: 1rem;
outline: 1px solid grey;
cursor: pointer;
}
51 changes: 51 additions & 0 deletions src/assets/styles/dialog.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
dialog[open] {
opacity: 1;
transform: scaleY(1);
}

/* Closed state of the dialog */
dialog {
opacity: 0;
transform: scaleY(0);
transition:
opacity 0.7s ease-out,
transform 0.7s ease-out,
overlay 0.7s ease-out allow-discrete,
display 0.7s ease-out allow-discrete;
/* Equivalent to
transition: all 0.7s allow-discrete; */
}

/* Before-open state */
/* Needs to be after the previous dialog[open] rule to take effect,
as the specificity is the same */
@starting-style {
dialog[open] {
opacity: 0;
transform: scaleY(0);
}
}

/* Transition the :backdrop when the dialog modal is promoted to the top layer */
dialog::backdrop {
background-color: rgb(0 0 0 / 0%);
transition:
display 0.7s allow-discrete,
overlay 0.7s allow-discrete,
background-color 0.7s;
/* Equivalent to
transition: all 0.7s allow-discrete; */
}

dialog[open]::backdrop {
background-color: rgb(0 0 0 / 25%);
}

/* This starting-style rule cannot be nested inside the above selector
because the nesting selector cannot represent pseudo-elements. */

@starting-style {
dialog[open]::backdrop {
background-color: rgb(0 0 0 / 0%);
}
}
4 changes: 1 addition & 3 deletions src/assets/styles/global.css
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
}

* {
margin: 0;
padding: 0;
box-sizing: border-box;
}

Expand Down Expand Up @@ -128,4 +126,4 @@ footer {
height: var(--footer-h);
display: flex;
align-items: center;
}
}
30 changes: 22 additions & 8 deletions src/pages/about.astro
Original file line number Diff line number Diff line change
@@ -1,27 +1,41 @@
---
import "@/assets/styles/about.css";
import "@/assets/styles/dialog.css";
import Header from "@/components/Header";
import Layout from "@/layouts/Layout";
---

<Layout title="About Us">
<Header title="About us">
<div >❓</div>
<div id="hint" class="hint">❓</div>
</Header>
<dialog id="hint">
<button autofocus>Close</button>
<p>Hide & Seek.</p>
<p>Press any alphabet key from keyboard and that letter will appears and when you press again then it will
disappears. see some hover and active effect while hover over each card</p>
</dialog>
<main>
<div class="container__about">
<h1>Hello There</h1>
<section class="moto">
<p>This is my initial version to make interactive games for kids</p>
<p>Inspiration behind these games are to take kids away from smartphone and close to keyboard which will help in their future building also. </p>
</section>
</div>
<dialog id="info">
<button autofocus>Close</button>
<p>Hide & Seek.</p>
<p>Press any alphabet key from keyboard and that letter will appears and when you press again then it will
disappears. see some hover and active effect while hover over each card</p>
</dialog>
</div>
</main>
</Layout>


<script>
const hint = document.querySelector('#hint');
const infoDialog = document.querySelector('dialog');
const btn = document.querySelector('dialog > button');
hint?.addEventListener('click', ()=>{
infoDialog?.showModal();
})
btn?.addEventListener('click', () =>{
infoDialog?.close();
})
</script>

0 comments on commit 3f24ea4

Please sign in to comment.