-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: enhance slider component with labels and improved input handling (
#5065) * 📝 (openai.py): Update temperature slider range from 0-1 to 0-2 with step 0.01 for more precise control 📝 (sliderComponent/index.tsx): Update step value for slider component from 0.1 to 0.01 for smoother and more accurate adjustments 📝 (sliderComponent/index.tsx): Update MAX_LABEL from "Wild" to "Creative" for better semantic representation 📝 (sliderComponent/index.tsx): Add cursor-grabbing style when slider thumb is being grabbed to improve user experience * 📝 (sliderComponent/index.tsx): improve styling and structure of the SliderComponent by refactoring the display value element to use a div container with appropriate classes and styles. * 📝 (App.css): Add styles to hide spin buttons in input[type=number] elements for better UX 🔧 (sliderComponent/index.tsx): Add input element to allow users to directly edit the slider value for improved user experience * ✨ (slider-labels.tsx): Add SliderLabels component to display min and max labels with icons in SliderComponent for better user experience 📝 (index.tsx): Remove sliderInput prop and refactor SliderComponent to improve code readability and maintainability 🔧 (applies.css): Add styling for input-slider-text class to improve consistency in SliderComponent styling * 📝 (applies.css): update hover:ring value to use variable hover:ring-slider-input-border for consistency and maintainability 📝 (index.css): add variable --slider-input-border to define the color value for slider input border 🔧 (tailwind.config.mjs): add slider-input-border custom property to map to the defined color value in the CSS variables * ✨ (build-color-by-name.ts): add function to dynamically build color based on input values to customize UI ✨ (get-min-max-value.ts): add function to get minimum or maximum value based on input constraints 🔧 (index.tsx): update import path for getMinOrMaxValue function 🔧 (index.tsx): add buildColorByName function to dynamically set thumb color based on percentage 🔧 (index.tsx): add logic to dynamically set background color gradient based on thumb color and percentage 🔧 (index.tsx): add logic to dynamically set thumb background color based on percentage and color calculation
- Loading branch information
1 parent
78081be
commit b2691ee
Showing
9 changed files
with
215 additions
and
54 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
46 changes: 46 additions & 0 deletions
46
...nts/core/parameterRenderComponent/components/sliderComponent/components/slider-labels.tsx
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,46 @@ | ||
import IconComponent from "@/components/common/genericIconComponent"; | ||
|
||
export const SliderLabels = ({ | ||
minLabel, | ||
maxLabel, | ||
minLabelIcon, | ||
maxLabelIcon, | ||
}: { | ||
minLabel: string; | ||
maxLabel: string; | ||
minLabelIcon: string; | ||
maxLabelIcon: string; | ||
}) => { | ||
return ( | ||
<> | ||
<div className="text mt-2 grid grid-cols-2 gap-x-2 text-sm"> | ||
<div className="flex items-center"> | ||
<IconComponent | ||
className="mr-1 h-4 w-4 text-placeholder-foreground" | ||
name={minLabelIcon} | ||
aria-hidden="true" | ||
/> | ||
<span | ||
data-testid="min_label" | ||
className="text-xs text-placeholder-foreground" | ||
> | ||
{minLabel} | ||
</span> | ||
</div> | ||
<div className="flex items-center justify-end"> | ||
<span | ||
data-testid="max_label" | ||
className="text-xs text-placeholder-foreground" | ||
> | ||
{maxLabel} | ||
</span> | ||
<IconComponent | ||
className="ml-1 h-4 w-4 text-placeholder-foreground" | ||
name={maxLabelIcon} | ||
aria-hidden="true" | ||
/> | ||
</div> | ||
</div> | ||
</> | ||
); | ||
}; |
30 changes: 30 additions & 0 deletions
30
...s/core/parameterRenderComponent/components/sliderComponent/helpers/build-color-by-name.ts
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,30 @@ | ||
export const buildColorByName = ( | ||
accentIndigoForeground: string, | ||
accentPinkForeground: string, | ||
percentage: number, | ||
) => { | ||
const startHue = parseInt(accentIndigoForeground.split(" ")[0]); | ||
const endHue = parseInt(accentPinkForeground.split(" ")[0]); | ||
|
||
const startSaturation = parseInt( | ||
accentIndigoForeground.split(" ")[1].replace("%", ""), | ||
); | ||
const endSaturation = parseInt( | ||
accentPinkForeground.split(" ")[1].replace("%", ""), | ||
); | ||
|
||
const startLightness = parseInt( | ||
accentIndigoForeground.split(" ")[2].replace("%", ""), | ||
); | ||
const endLightness = parseInt( | ||
accentPinkForeground.split(" ")[2].replace("%", ""), | ||
); | ||
|
||
const hue = startHue + (endHue - startHue) * (percentage / 100); | ||
const saturation = | ||
startSaturation + (endSaturation - startSaturation) * (percentage / 100); | ||
const lightness = | ||
startLightness + (endLightness - startLightness) * (percentage / 100); | ||
|
||
return `hsl(${hue}, ${saturation}%, ${lightness}%)`; | ||
}; |
File renamed without changes.
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