Skip to content

Commit bbc9451

Browse files
committed
perf!: Removed animation and other styled classes
1 parent 71f31d8 commit bbc9451

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

index.html

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ <h1 class="text-xl font-bold mb-4 text-gray-800">Float Labels Example</h1>
1313

1414
<form class="space-y-4">
1515
<div class="float-container">
16-
<label for="name" class="float-label text-gray-600"
16+
<label for="name" class="float-label px-2 text-gray-600"
1717
>Full Name (1: empty)</label
1818
>
1919
<input
@@ -25,7 +25,7 @@ <h1 class="text-xl font-bold mb-4 text-gray-800">Float Labels Example</h1>
2525
</div>
2626

2727
<div class="float-container float-always">
28-
<label for="sticky" class="float-label text-gray-600"
28+
<label for="sticky" class="float-label px-2 text-gray-600"
2929
>Sticky (sticky)</label
3030
>
3131
<input
@@ -37,7 +37,7 @@ <h1 class="text-xl font-bold mb-4 text-gray-800">Float Labels Example</h1>
3737
</div>
3838

3939
<div class="float-container">
40-
<label for="email" class="float-label text-gray-600"
40+
<label for="email" class="float-label px-2 text-gray-600"
4141
>Email Address (2: is focused)</label
4242
>
4343
<input
@@ -50,7 +50,7 @@ <h1 class="text-xl font-bold mb-4 text-gray-800">Float Labels Example</h1>
5050
</div>
5151

5252
<div class="float-container">
53-
<label class="float-label text-gray-600"
53+
<label class="float-label px-2 text-gray-600"
5454
>What type of event is it?</label
5555
>
5656
<select class="float-input w-full px-3 py-2 border border-gray-300">
@@ -63,7 +63,9 @@ <h1 class="text-xl font-bold mb-4 text-gray-800">Float Labels Example</h1>
6363
</div>
6464

6565
<div class="float-container">
66-
<label class="float-label text-gray-600">Additional details</label>
66+
<label class="float-label px-2 text-gray-600"
67+
>Additional details</label
68+
>
6769
<textarea
6870
class="float-input w-full border border-gray-300 p-2"
6971
rows="3"
@@ -86,13 +88,6 @@ <h1 class="text-xl font-bold mb-4 text-gray-800">Float Labels Example</h1>
8688
window.onload = () => {
8789
const focusedElement = document.querySelector('#name');
8890

89-
// email.addEventListener('blur', function (e) {
90-
// // Re-focus immediately after blur
91-
// setTimeout(() => {
92-
// email.focus();
93-
// }, 2000);
94-
// });
95-
9691
focusedElement.focus();
9792
};
9893
</script>

src/float-label.css

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
@layer utilities {
22
.float-container {
33
display: grid;
4-
grid-template-columns: 1fr;
5-
grid-template-rows: --spacing(1) 1fr;
64

75
/* Label always float (sticky) */
86
&.float-always,
@@ -11,13 +9,19 @@
119
/* Label when input has value and no placeholder */
1210
&:has(.float-input:not(:placeholder-shown)) {
1311
& .float-label {
14-
background-color: var(--float-label-background-color);
15-
@apply opacity-100 text-xs w-fit self-start -translate-y-2 translate-x-2;
12+
/*background-color: var(--float-label-background-color);*/
13+
@apply bg-[var(--float-label-background-color)]
14+
translate-x-2
15+
opacity-100
16+
text-xs
17+
w-fit
18+
self-start
19+
-translate-y-1/2;
1620
}
1721
}
1822

1923
.float-input {
20-
@apply col-[1] row-[2];
24+
@apply col-start-1 row-start-1;
2125
}
2226

2327
&:not(.float-always) .float-input::placeholder {
@@ -26,8 +30,9 @@
2630

2731
/** Placeholder replacement */
2832
.float-label {
29-
@apply col-[1] row-[2] self-center pointer-events-none transition-all duration-200 origin-[0_0] opacity-50;
30-
@apply px-2;
33+
@apply col-start-1 row-start-1
34+
opacity-50
35+
/*transition-all duration-200*/;
3136
}
3237

3338
&:has(textarea.float-input) .float-label {

0 commit comments

Comments
 (0)