Skip to content

Commit

Permalink
Add CSS listbox size parameters
Browse files Browse the repository at this point in the history
  • Loading branch information
CodeSandwich committed Nov 22, 2023
1 parent c322b3b commit d664375
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 30 deletions.
7 changes: 3 additions & 4 deletions demo/demo-theme.css
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,13 @@ header {
flex-flow: row wrap;
position: relative;
gap: 0.6665rem;
justify-content: space-between;
}

header > * {
align-self: center;
}

header h2 {
order: 1;
}

.demo-logo {
background-image: url(../assets/logo-text-dark.svg);
}
Expand All @@ -30,6 +27,8 @@ header .tsmb-form {
--tsmb-color-base30: var(--tsmb-color-primary90);
--tsmb-color-base50: #c090c0;
--tsmb-color-base90: #c090c0;
--tsmb-size-listbox-right: 0;
--tsmb-size-listbox-width: calc(min(50rem, 80vw));
}
header .tsmb-form:not(:focus-within)::before {
filter: invert();
Expand Down
2 changes: 1 addition & 1 deletion demo/demo.css
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ a:focus {
header,
main,
.demo-stylecontrol {
padding: 1rem calc((100% - 65rem) / 2) 0 1rem;
padding: 1rem;
}

.demo-logo {
Expand Down
45 changes: 20 additions & 25 deletions typesense-minibar.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
--tsmb-size-sm: 0.8rem;
--tsmb-size-half: calc(var(--tsmb-size-sm)/2);
--tsmb-size-input: calc(var(--tsmb-size-base) * 1.2);
/* Set to 0 to make the listbox expand to the left */
--tsmb-size-listbox-right: auto;
--tsmb-size-listbox-width: calc(min(30rem, 60vw));
--tsmb-size-listbox-max-height: 70vh;

--tsmb-color-base-background: #fff;
--tsmb-color-base30: #333;
Expand Down Expand Up @@ -51,9 +55,11 @@
.tsmb-form:focus-within {
color: var(--tsmb-color-focus30);
}

.tsmb-form:focus-within input[type=search] {
background: var(--tsmb-color-focus-background);
}

.tsmb-form:focus-within input[type=search]::placeholder {
color: var(--tsmb-color-focus50);
}
Expand Down Expand Up @@ -100,6 +106,10 @@
display: block !important;
}

.tsmb-form--slash::after {
display: none;
}

.tsmb-form--slash:not(.tsmb-form--open):not(:focus-within)::after {
content: '/';
display: inline-block;
Expand All @@ -122,13 +132,16 @@
.tsmb-form [role=listbox] {
position: absolute;
z-index: 10;

right: var(--tsmb-size-listbox-right);
background: var(--tsmb-color-focus-background);
color: var(--tsmb-color-focus30);
width: 100%;
max-height: 70vh;
margin-top: var(--tsmb-size-half);
min-width: 100%;
width: var(--tsmb-size-listbox-width);
max-height: var(--tsmb-size-listbox-max-height);
overflow: auto;
border: var(--tsmb-size-edge) solid var(--tsmb-color-focus90);
border-radius: var(--tsmb-size-radius);
box-shadow: 0 var(--tsmb-size-sm) 20px rgba(0,0,0,0.12);
}

Expand All @@ -143,9 +156,11 @@
text-decoration: none;
border-left: var(--tsmb-size-highlight) solid transparent;
}

.tsmb-form:not([data-group=true]) [role=option]:not(:first-child) a {
border-top: var(--tsmb-size-edge) solid var(--tsmb-color-focus90);
}

.tsmb-form[data-group=true] [role=option] a {
margin: 0 var(--tsmb-size-base);
padding: var(--tsmb-size-sm);
Expand Down Expand Up @@ -199,33 +214,13 @@
box-shadow: 0 0 10px rgba(0,0,0,0.12);
text-decoration: none;
}

.tsmb-foot::before {
content: 'Search by';
color: var(--tsmb-color-focus50);
}

.tsmb-foot::after {
content: ' Typesense';
color: #0300b0;
}

@media (max-width: 480px) {
.tsmb-form {
width: 100%;
}

.tsmb-form input[type=search] {
border-radius: 0;
}
}

@media (min-width: 768px) {
.tsmb-form [role=listbox] {
border-radius: var(--tsmb-size-radius);
min-width: 500px;
margin-top: var(--tsmb-size-half);
}

.tsmb-form--slash::after {
display: none;
}
}

0 comments on commit d664375

Please sign in to comment.