-
Notifications
You must be signed in to change notification settings - Fork 73
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: better UI for model selection (credit @cfahlgren1)
- Loading branch information
1 parent
1884408
commit 48be91a
Showing
24 changed files
with
950 additions
and
193 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
.row { | ||
display: flex; | ||
flex-direction: column; | ||
border: var(--border-in-light); | ||
border-radius: 10px; | ||
overflow: hidden; | ||
font-size: .8rem; | ||
|
||
.summary-continer { | ||
padding: 0.75rem; | ||
transition: background-color 0.2s ease-in-out; | ||
cursor: pointer; | ||
height: 100%; | ||
|
||
&:hover { | ||
background-color: var(--second); | ||
} | ||
|
||
.summary { | ||
display: flex; | ||
justify-content: space-between; | ||
align-items: center; | ||
|
||
.summary-model-info { | ||
display: flex; | ||
align-items: center; | ||
gap: 10px; | ||
} | ||
} | ||
} | ||
|
||
.expanded { | ||
padding: .75rem; | ||
|
||
.variant-option { | ||
display: flex; | ||
align-items: center; | ||
justify-content: space-between; | ||
padding: 0.5rem; | ||
border-radius: 0.375rem; | ||
cursor: pointer; | ||
transition: background-color 0.2s ease-in-out; | ||
|
||
&:hover { | ||
background-color: var(--gray); | ||
} | ||
|
||
.variant-label { | ||
font-size: 0.75rem; | ||
color: var(--black); | ||
white-space: nowrap; | ||
overflow: hidden; | ||
text-overflow: ellipsis; | ||
flex-grow: 1; | ||
margin-right: 0.5rem; | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import React from "react"; | ||
import { ChevronDown, ChevronUp } from "lucide-react"; | ||
|
||
import style from "./model-row.module.scss"; | ||
|
||
interface ModelRowProps { | ||
baseModel: string; | ||
variants: string[]; | ||
isExpanded: boolean; | ||
hasSingleVariant: boolean; | ||
determineModelIcon: (model: string) => JSX.Element; | ||
extractModelDetails: (model: string) => { | ||
displayName: string; | ||
quantBadge: string | null; | ||
}; | ||
onSelectModel: (model: string) => void; | ||
onClose: () => void; | ||
handleToggleExpand: (modelName: string) => void; | ||
} | ||
|
||
const ModelRow: React.FC<ModelRowProps> = ({ | ||
baseModel, | ||
variants, | ||
isExpanded, | ||
hasSingleVariant, | ||
determineModelIcon, | ||
extractModelDetails, | ||
onSelectModel, | ||
onClose, | ||
handleToggleExpand, | ||
}) => { | ||
const { quantBadge } = hasSingleVariant | ||
? extractModelDetails(variants[0]) | ||
: { quantBadge: null }; | ||
|
||
return ( | ||
<div className={style["row"]} key={baseModel}> | ||
<div | ||
className={style["summary-continer"]} | ||
onClick={() => { | ||
if (hasSingleVariant) { | ||
onSelectModel(variants[0]); | ||
onClose(); | ||
} else { | ||
handleToggleExpand(baseModel); | ||
} | ||
}} | ||
> | ||
<div className={style["summary"]}> | ||
<div className={style["summary-model-info"]}> | ||
{determineModelIcon(variants[0])} | ||
<span>{baseModel}</span> | ||
{hasSingleVariant && quantBadge && <span>{quantBadge}</span>} | ||
</div> | ||
{!hasSingleVariant && (isExpanded ? <ChevronUp /> : <ChevronDown />)} | ||
</div> | ||
</div> | ||
{isExpanded && !hasSingleVariant && ( | ||
<div className={style["expanded"]}> | ||
{variants.map((variant) => { | ||
const { quantBadge } = extractModelDetails(variant); | ||
return ( | ||
<div | ||
key={variant} | ||
onClick={() => { | ||
onSelectModel(variant); | ||
onClose(); | ||
}} | ||
className={style["variant-option"]} | ||
> | ||
<span className={style["variant-label"]}> | ||
{quantBadge || variant} | ||
</span> | ||
</div> | ||
); | ||
})} | ||
</div> | ||
)} | ||
</div> | ||
); | ||
}; | ||
|
||
export default ModelRow; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
.header { | ||
display: flex; | ||
flex-direction: column; | ||
width: 100%; | ||
position: relative; | ||
gap: 20px; | ||
padding-bottom: 20px; | ||
} | ||
|
||
.input-container { | ||
position: relative; | ||
width: 100%; | ||
} | ||
|
||
input.input[type=text] { | ||
width: 100%; | ||
max-width: 100%; | ||
padding: 0.5rem 0.5rem 0.5rem 2rem; | ||
} | ||
|
||
.input-icon { | ||
position: absolute; | ||
left: 0.5rem; | ||
top: 50%; | ||
transform: translateY(-50%); | ||
color: #9ca3af; | ||
width: 1rem; | ||
height: 1rem; | ||
} | ||
|
||
.model-list { | ||
display: grid; | ||
gap: 1rem; | ||
grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); | ||
grid-auto-rows: auto; | ||
align-items: start; | ||
} | ||
|
||
.model-family-filter { | ||
display: flex; | ||
flex-wrap: wrap; | ||
gap: .4rem; | ||
|
||
.model-family-button { | ||
.icon { | ||
position: relative; | ||
height: 1rem; | ||
width: 1rem; | ||
|
||
svg, | ||
img { | ||
max-width: 100%; | ||
max-height: 100%; | ||
filter: none !important; | ||
} | ||
} | ||
} | ||
} | ||
|
||
.model-icon { | ||
height: 1rem; | ||
width: 1rem; | ||
position: relative; | ||
|
||
svg, | ||
img { | ||
max-width: 100%; | ||
max-height: 100%; | ||
filter: none !important; | ||
} | ||
} |
Oops, something went wrong.