A Pen by Itay haephrati on CodePen.
Created
January 5, 2023 02:40
-
-
Save guberm/2f00b2a1bd76fd7ab8f4124573543da6 to your computer and use it in GitHub Desktop.
שירי - text to speech SpeechSynthesisUtterance
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="input-group"> | |
<input required="" type="text" name="text" autocomplete="off" class="input" id="inputVal"> | |
<label class="user-label">מה תרצה שאומר? (heb)</label> | |
</div> | |
<button onclick="speakFunc();" data-text="Awesome" class="button"> | |
<span class="actual-text"> TALK </span> | |
<span class="hover-text" aria-hidden="true"> TALK </span> | |
</button> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function speakFunc() { | |
let inputVal = document.getElementById("inputVal").value; | |
msg = new SpeechSynthesisUtterance(); | |
msg.text = inputVal; | |
msg.lang = "he"; | |
window.speechSynthesis.speak(msg); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@import url("https://fonts.googleapis.com/css2?family=Secular+One&display=swap"); | |
body { | |
--bgcolor: #121111; | |
--primarycolor: #ff0; | |
direction: rtl; | |
display: grid; | |
place-items: center; | |
align-content: center; | |
gap: 20px; | |
height: 100vh; | |
margin: 0; | |
background: var(--bgcolor); | |
font-family: "Secular One", sans-serif; | |
/* === removing default button style ===*/ | |
.button { | |
margin: 0; | |
height: auto; | |
background: transparent; | |
padding: 0; | |
border: none; | |
cursor: pointer; | |
} | |
/* button styling */ | |
.button { | |
--border-left: 6px; | |
--text-stroke-color: rgba(255, 255, 255, 0.6); | |
--animation-color: var(--primarycolor); | |
--fs-size: 2em; | |
letter-spacing: 3px; | |
text-decoration: none; | |
font-size: var(--fs-size); | |
position: relative; | |
text-transform: uppercase; | |
color: transparent; | |
-webkit-text-stroke: 1px var(--text-stroke-color); | |
} | |
/* this is the text, when you hover on button */ | |
.hover-text { | |
position: absolute; | |
box-sizing: border-box; | |
content: attr(data-text); | |
color: var(--animation-color); | |
width: 0%; | |
inset: 0; | |
border-left: var(--border-left) solid var(--animation-color); | |
overflow: hidden; | |
transition: 0.5s; | |
-webkit-text-stroke: 1px var(--animation-color); | |
} | |
/* hover */ | |
.button:hover .hover-text { | |
width: 100%; | |
filter: drop-shadow(0 0 23px var(--animation-color)); | |
} | |
.input-group { | |
position: relative; | |
} | |
.input { | |
border: solid 1.5px #9e9e9e; | |
border-radius: 1rem; | |
background: none; | |
padding: 1rem; | |
font-size: 1rem; | |
color: #f5f5f5; | |
transition: border 150ms cubic-bezier(0.4, 0, 0.2, 1); | |
} | |
.user-label { | |
position: absolute; | |
right: 15px; | |
color: #e8e8e8; | |
pointer-events: none; | |
transform: translateY(1rem); | |
transition: 150ms cubic-bezier(0.4, 0, 0.2, 1); | |
} | |
.input:focus, | |
input:valid { | |
outline: none; | |
border: 1.5px solid var(--primarycolor); | |
} | |
.input:focus ~ label, | |
input:valid ~ label { | |
transform: translateY(-50%) scale(0.8); | |
background-color: var(--bgcolor); | |
padding: 0 0.2em; | |
color: var(--primarycolor); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment