Skip to content

Commit fb941f2

Browse files
committed
Style the input box
1 parent eb4e2b4 commit fb941f2

3 files changed

Lines changed: 52 additions & 12 deletions

File tree

index.html

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,11 @@
1010

1111

1212
<form>
13-
<textarea name="message" placeholder="What is populated with it"></textarea>
14-
<input type="submit" />
13+
<textarea name="message" placeholder="What's happening here" rows="1"></textarea>
14+
15+
<button>
16+
<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 -960 960 960" width="24px" fill="currentColor"><path d="M440-400h80v-120h120v-80H520v-120h-80v120H320v80h120v120Zm40 214q122-112 181-203.5T720-552q0-109-69.5-178.5T480-800q-101 0-170.5 69.5T240-552q0 71 59 162.5T480-186Zm0 106Q319-217 239.5-334.5T160-552q0-150 96.5-239T480-880q127 0 223.5 89T800-552q0 100-79.5 217.5T480-80Zm0-480Z"/></svg>
17+
</button>
1518
</form>
1619

1720
<ol>

src/main.ts

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,4 +78,17 @@ form?.addEventListener('submit', async e => {
7878

7979
form.reset()
8080

81-
})
81+
})
82+
83+
84+
// resize any text areas to fit content
85+
for(const textarea of document.querySelectorAll('textarea')) {
86+
87+
textarea.addEventListener('input', () => {
88+
const padding = 12;
89+
90+
textarea.style.height = 'auto';
91+
textarea.style.height = `${textarea.scrollHeight - (padding * 2)}px`;
92+
})
93+
}
94+

src/style.css

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,12 +23,9 @@ a:hover {
2323
}
2424

2525
body {
26-
margin: 3em;
27-
/* display: flex; */
28-
/* flex-direction: column; */
29-
/* place-items: center; */
30-
min-width: 320px;
31-
min-height: 100vh;
26+
max-width: 500px;
27+
margin: auto ;
28+
padding: 1em;
3229
}
3330

3431
@media (prefers-color-scheme: light) {
@@ -39,7 +36,34 @@ body {
3936
a:hover {
4037
color: #747bff;
4138
}
42-
button {
43-
background-color: #f9f9f9;
44-
}
39+
}
40+
41+
42+
form {
43+
display: flex;
44+
align-items: flex-end;
45+
gap: 12px;
46+
}
47+
48+
button {
49+
border-radius: 100%;
50+
border: none;
51+
height: 42px;
52+
width: 42px;
53+
display: flex;
54+
padding: 0;
55+
justify-content: center;
56+
align-items: center;
57+
background-color: #7773;
58+
}
59+
60+
textarea {
61+
border-radius: 22px;
62+
padding: 12px;
63+
font-family: inherit;
64+
resize: none;
65+
border: none;
66+
flex: 1;
67+
font-weight: 600;
68+
background-color: #7773;
4569
}

0 commit comments

Comments
 (0)