Skip to content

Commit f1f63e0

Browse files
cdxkerskeptrunedev
authored andcommitted
feature: properly shrink on page width decrease
1 parent 7bbd21b commit f1f63e0

File tree

7 files changed

+43
-9
lines changed

7 files changed

+43
-9
lines changed

clients/docusaurus-theme-search/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@trieve/docusaurus-search-theme",
3-
"version": "0.1.5",
3+
"version": "0.1.6",
44
"author": "cdxker <[email protected]>",
55
"license": "MIT",
66
"main": "dist/index.js",
@@ -24,7 +24,7 @@
2424
"cli-progress": "^3.12.0",
2525
"micromatch": "^4.0.7",
2626
"pagefind": "^1.1.0",
27-
"trieve-search-component": "^0.0.33"
27+
"trieve-search-component": "^0.0.34"
2828
},
2929
"peerDependencies": {
3030
"@docusaurus/core": "^2.0.0 || ^3.0.0",

clients/search-component/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ declare module "solid-js" {
9292
| brandName | string | null |
9393
| problemLink | string | null |
9494
| accentColor | string | #CB53EB |
95+
| responsive | boolean | false |
9596

9697
### Search Results
9798

clients/search-component/example/src/routes/index.lazy.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ export default function Home() {
113113
brandName="Trieve"
114114
brandColor="#b557c5"
115115
allowSwitchingModes={true}
116+
responsive={false}
116117
/>
117118

118119
<div className="mt-8 text-sm rounded overflow-hidden max-w-[100vw]">

clients/search-component/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"dist/*",
88
"dist/**/*"
99
],
10-
"version": "0.0.33",
10+
"version": "0.0.34",
1111
"license": "MIT",
1212
"scripts": {
1313
"dev": "run-p watch:css watch:js",

clients/search-component/src/TrieveModal/OpenModalButton.tsx

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ export const OpenModalButton = () => {
1414
<ButtonEl />
1515
</button>
1616
) : (
17-
<button id="open-trieve-modal" type="button" className={props.theme}>
18-
<div>
17+
<button id="open-trieve-modal" type="button" className={`${props.theme} ${props.responsive ?? false ? 'responsive' : ''}`}>
18+
<div className={`${props.responsive ?? false ? 'responsive' : ''}`}>
1919
<svg
2020
xmlns="http://www.w3.org/2000/svg"
2121
width="16"
@@ -30,9 +30,11 @@ export const OpenModalButton = () => {
3030
<circle cx="11" cy="11" r="8"></circle>
3131
<path d="m21 21-4.3-4.3"></path>
3232
</svg>
33-
<div>{props.placeholder}</div>
33+
<div className={`${props.responsive ?? false ? 'responsive' : ''}`}>
34+
{props.placeholder}
35+
</div>
3436
</div>
35-
<span key={"open-button"} className="open">
37+
<span key={"open-button"} className={`open ${props.responsive ?? false ? 'responsive' : ''}`}>
3638
{keyCombo.map((key) => (
3739
<Fragment key={key.key}>
3840
{key.ctrl ? (

clients/search-component/src/TrieveModal/index.css

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -863,7 +863,16 @@ body {
863863
}
864864
body {
865865
#open-trieve-modal {
866-
@apply w-full flex items-center text-sm leading-6 ring-1 shadow-sm justify-between rounded-md border-0 py-1.5 px-2 sm:text-sm truncate gap-2 min-w-[43px] max-w-[300px];
866+
@apply flex items-center text-sm leading-6 ring-1 shadow-sm justify-between rounded-md border-0 py-1.5 px-2 sm:text-sm truncate gap-2;
867+
868+
&:not(.responsive) {
869+
@apply w-full min-w-[43px] max-w-[300px];
870+
}
871+
872+
&.responsive {
873+
@apply sm:w-full sm:min-w-[43px] sm:max-w-[300px];
874+
}
875+
867876
color: var(--tv-zinc-400);
868877
background-color: var(--tv-zinc-50);
869878
outline: none;
@@ -883,7 +892,15 @@ body {
883892
}
884893

885894
> div {
886-
@apply flex items-center gap-3 min-w-[42px];
895+
@apply flex items-center gap-3;
896+
897+
&.responsive {
898+
@apply sm:min-w-[42px];
899+
}
900+
901+
&:not(.responsive) {
902+
@apply min-w-[42px];
903+
}
887904

888905
svg {
889906
@apply min-w-4 flex-none;
@@ -896,6 +913,11 @@ body {
896913

897914
> div {
898915
@apply truncate min-w-0;
916+
&.responsive {
917+
@media (max-width: 640px) {
918+
display: none;
919+
}
920+
}
899921
}
900922
}
901923

@@ -904,6 +926,12 @@ body {
904926
color: var(--tv-zinc-400);
905927
border-color: var(--tv-zinc-200);
906928

929+
&.responsive {
930+
@media (max-width: 640px) {
931+
display: none;
932+
}
933+
}
934+
907935
@media screen and (-webkit-font-smoothing: antialiased) {
908936
.mac {
909937
display: block;

clients/search-component/src/utils/hooks/modal-context.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ export type ModalProps = {
5151
allowSwitchingModes?: boolean;
5252
defaultCurrency?: string;
5353
currencyPosition?: currencyPosition;
54+
responsive?: boolean;
5455
};
5556

5657
const defaultProps = {
@@ -70,6 +71,7 @@ const defaultProps = {
7071
type: "docs" as ModalTypes,
7172
allowSwitchingModes: true,
7273
currencyPosition: "after" as currencyPosition,
74+
responsive: false
7375
};
7476

7577
const ModalContext = createContext<{

0 commit comments

Comments
 (0)