-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Slider component #164
base: main
Are you sure you want to change the base?
Conversation
<div | ||
className={sliderBar} | ||
style={{ | ||
position: 'absolute', | ||
left: state.getThumbValue(1) | ||
? `${state.getThumbValue(0)}%` | ||
: 0, | ||
width: state.getThumbValue(1) | ||
? `${(state.getThumbValue(1) || 0) - (state.getThumbValue(0) || 0)}%` | ||
: `${state.getThumbValue(0)}%`, | ||
}} | ||
/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i tried a handful of ways to implement the bar, and I doubt this is the correct way. Any advice is greatly appreciated! I used this example for this implementation.
Because of how this is implemented, it does mean there are two slider bars when using the Range Slider. 😬😞
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea, let's go over this when we have time
@@ -0,0 +1,312 @@ | |||
import { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i have a feeling i didn't organize this file properly, please lmk if there is a better way to do this!
@@ -0,0 +1,145 @@ | |||
import { style } from '@vanilla-extract/css'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I eyeballed all the styles from the pic, so I doubt they're fully accurate. If anything should be tweaked, I am happy to do so!
{({ state }: SliderRenderProps) => ( | ||
<> | ||
<div | ||
className={sliderBar} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think i applied this incorrectly, but was unable to get it working with the same method the Picker
stories were using. User error, i'm sure 😆
}, | ||
thumb: { | ||
container: style({ | ||
' input': { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks like this is the line that is causing the build to fail. I wasn't sure how to properly address this issue, because the RAC component has an grandchild element of input
, which holds a 90px width. The tooltip in the story is hovering over the input
rather than the main level component, thus the width change. Below are a few pictures to better explain.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll look at this together. But the rule that you appear to be breaking is that (aside from pseudo selectors), styles can only target the current element:
https://vanilla-extract.style/documentation/styling/#complex-selectors
}; | ||
track: { | ||
container: string; | ||
track: string; // TODO: adjust the styles to use this class |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i have the TODO here, but i'm not quite sure i actually need to make that change 🤔💭
sliderTrackStateVars, | ||
type ThemeContext, | ||
} from '../../src'; | ||
import type { SliderThumbState } from '../../src/components/slider/types'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a reason you're not importing from root? I see it commented out above
sliderStateVars, | ||
sliderThumbStateVars, | ||
sliderTrackStateVars, | ||
type LabelAlignment, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be prefixed with Slider to not cause a naming conflict
} from '@vanilla-extract/css'; | ||
import type { SliderClassNames } from './types'; | ||
import { layers, typographyVars } from '../../styles'; | ||
import { containerQueries } from '@/utils'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's hold off on using import aliases for the moment
|
||
export type LabelAlignment = 'top' | 'left'; | ||
|
||
export type SliderRenderProps = RACSliderRenderProps; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You'll likely want to wrap these with AsType
BaseSliderProps; | ||
|
||
type BaseSliderThumbProps = { | ||
children?: RenderPropsChildren<SliderRenderProps>; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think you need to redefine children
here unless you're actually changing the type (which I don't think you are). And then you could simplify why getting rid of the BaseSlideThumbProps and just add the classNames prop directly to the join
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This applies below too
@@ -122,6 +129,18 @@ export type DefaultsContext = DefaultsOf<{ | |||
// biome-ignore lint/style/useNamingConvention: component name should be PascalCase | |||
Select: SelectProps<object>; | |||
// biome-ignore lint/style/useNamingConvention: component name should be PascalCase | |||
Slider: SliderProps; | |||
// biome-ignore lint/style/useNamingConvention: component name should be PascalCase |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dear lord, who did this Biome commenting? Can you create an issue to convert to range suppression biomejs/biome#4569 please?
@@ -86,6 +87,8 @@ export type ThemeContext = { | |||
// biome-ignore lint/style/useNamingConvention: component name should be PascalCase | |||
Select?: SelectClassNames; | |||
// biome-ignore lint/style/useNamingConvention: component name should be PascalCase | |||
Slider?: SliderClassNames; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here too
<div | ||
className={sliderBar} | ||
style={{ | ||
position: 'absolute', | ||
left: state.getThumbValue(1) | ||
? `${state.getThumbValue(0)}%` | ||
: 0, | ||
width: state.getThumbValue(1) | ||
? `${(state.getThumbValue(1) || 0) - (state.getThumbValue(0) || 0)}%` | ||
: `${state.getThumbValue(0)}%`, | ||
}} | ||
/> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea, let's go over this when we have time
Closes
✅ Pull Request Checklist:
📝 Test Instructions:
open the ladle page and view the Slider component. There are a handful of stories for review, including:
includeTextField
andincludeOutputField
❓ Does this PR introduce a breaking change?
💬 Other information
I'm happy to hear any and all feedback, especially on variable names and naming conventions. I'm sure there are some internal practices I was not aware of!
I didn't have a ticket for this, because I don't have Jira access yet, but here is the screenshot I was given and attempted to match.