Skip to content

Commit e5f383b

Browse files
committed
CSS: Fix icon overlapping long search input values
Reserve a bit of right padding equal so that typed text and input cursor don't get obscured behind the "slash" or "close" icons. When JS is disabled, or when the form is closed and the "slash" option is not enabled, don't reserve this padding to avoid an unexplained gap. It is possible for the "slash" icon and "close" icon to have different sizes (one is based on "sm" size, the other based on "input" size, although currently their padding evens out). Right now, this is setting the padding only based on the "close" icon since that is the only icon that can appear while the text field is focussed. I think it feels more smooth if the cut off does not change or shift when the input is focussed/de-focussed, so I choose not to have two different paddings. To avoid an ugly state where old text in the input field is rendered behind the transparent "slash" icon, I added a solid background color to the slash icon equal to the input background color, which makes sure that the slash icon maintains an "on top" appearance. == npm run size == A few unrelated spaces are changed to improve file compression. CSS: * Before: 1834 * After: 1869 (+35 B, +2%)
1 parent 9d3ae62 commit e5f383b

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

typesense-minibar.css

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
--tsmb-size-highlight: 2px;
66
--tsmb-size-base: 1rem;
77
--tsmb-size-sm: 0.8rem;
8-
--tsmb-size-half: calc( var(--tsmb-size-sm) * 0.5 );
9-
--tsmb-size-input: calc( var(--tsmb-size-base) * 1.2 );
8+
--tsmb-size-half: calc(var(--tsmb-size-sm)/2);
9+
--tsmb-size-input: calc(var(--tsmb-size-base) * 1.2);
1010

1111
--tsmb-color-base-background: #fff;
1212
--tsmb-color-base30: #333;
@@ -76,9 +76,16 @@
7676
opacity: 0.5;
7777
}
7878

79+
/* js only */
80+
.tsmb-form--open input[type=search],
81+
.tsmb-form--slash input[type=search] {
82+
padding-right: calc(var(--tsmb-size-sm) + var(--tsmb-size-base) + var(--tsmb-size-base));
83+
}
84+
7985
.tsmb-icon-close {
86+
box-sizing: border-box;
8087
position: absolute;
81-
top: calc(50% - var(--tsmb-size-base) / 2);
88+
top: calc(50% - var(--tsmb-size-base)/2);
8289
right: var(--tsmb-size-base);
8390
width: var(--tsmb-size-base);
8491
height: var(--tsmb-size-base);
@@ -97,7 +104,7 @@
97104
content: '/';
98105
display: inline-block;
99106
position: absolute;
100-
top: calc(50% - (var(--tsmb-size-input) + var(--tsmb-size-sm) / 2) / 2);
107+
top: calc(50% - (var(--tsmb-size-input) + var(--tsmb-size-sm)/2)/2);
101108
right: var(--tsmb-size-sm);
102109
width: calc(var(--tsmb-size-input) + var(--tsmb-size-sm)/2);
103110
height: calc(var(--tsmb-size-input) + var(--tsmb-size-sm)/2);
@@ -106,6 +113,7 @@
106113
line-height: calc(var(--tsmb-size-input) + var(--tsmb-size-sm)/2);
107114
text-align: center;
108115

116+
background: var(--tsmb-color-base-background);
109117
border: var(--tsmb-size-edge) solid var(--tsmb-color-base90);
110118
border-radius: var(--tsmb-size-radius);
111119
color: var(--tsmb-color-base90);

0 commit comments

Comments
 (0)