-
Notifications
You must be signed in to change notification settings - Fork 44
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
Slider and Range slider component #1831
Conversation
Overall, the code structure seems fine and the logic is clear. Code Review Comments:
All looks good. |
|
'stroke-default': strokeSemantics.secondary, | ||
'icon-default': { light: colorPrimitives['white-100'], dark: colorPrimitives['white-100'] }, | ||
'background-default': surfaceSemantics.secondary, | ||
'background-progress': surfaceSemantics['brand-medium'], |
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 need to mentioned both light and dark mode. This format is incorrect and will break.
src/blocks/slider/Slider.tsx
Outdated
@@ -0,0 +1,55 @@ | |||
import styled from 'styled-components'; | |||
|
|||
import { Slider as MuiSlider } from '@material-ui/core'; |
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.
Sir we will be removing Material UI from our codebase in future, so this isn't gonna work. I guess we discussed this earlier.
We can only use those 3rd part libraries which offers standalone components like react and radix and not the whole design system like material UI.
…service/push-dapp into DAPP-1792-blocks/slider
Apart from these issues, the code logic and structure seem fine. Final Code: import styled from 'styled-components';
import { Slider as MuiSlider } from '@material-ui/core';
import { SliderProps } from './Slider.types';
const StyledSlider = styled(MuiSlider)`
.MuiSlider-rail {
color: var(--components-slider-background-default);
height: var(--spacing-xxxs);
opacity: 1;
}
.MuiSlider-track {
color: var(--components-slider-background-progress);
height: var(--spacing-xxxs);
}
.MuiSlider-thumb {
width: var(--spacing-sm);
height: var(--spacing-sm);
margin-top: -6px;
background-color: var(--components-slider-icon-default);
border: var(--border-sm) solid var(--components-slider-stroke-default);
}
.MuiSlider-thumb:hover,
.MuiSlider-thumb:active,
.MuiSlider-thumb:focus {
box-shadow: none;
}
.MuiSlider-valueLabel {
display: none;
}
`;
const Slider = <T extends number | [number, number]>({
min,
max,
onChange,
value,
step,
defaultValue,
}: SliderProps<T>) => {
return (
<StyledSlider
{...{ min, max, value, step, defaultValue }}
onChange={(_event: MouseEvent, sliderValue: T) => onChange(sliderValue)}
/>
);
};
Slider.displayName = 'Slider';
export { Slider };
export type SliderBaseProps = {
min: number;
max: number;
step: number;
};
export type SliderProps<T> = SliderBaseProps & {
value?: T;
onChange: (value: T) => void;
defaultValue?: T;
};
// semanticKeys object and colorSemantics object are unchanged from the previous code snippet
import { colorPrimitives } from '../colors/colors.primitives';
import { strokeSemantics } from './semantics.stroke';
import { surfaceSemantics } from './semantics.surface';
export const sliderSemantics = {
'stroke-default': strokeSemantics.secondary,
'icon-default': { light: colorPrimitives['white-100'], dark: colorPrimitives['white-100'] },
'background-default': surfaceSemantics.secondary,
'background-progress': surfaceSemantics['brand-medium'],
};
All looks good. |
File: package.json
All looks good. File: src/blocks/slider/Slider.tsx
: css`
.horizontal-slider-track-0 {
// Add styling here
}
` All looks good. File: src/blocks/slider/Slider.types.ts All looks good. File: src/blocks/theme/colors/colors.semantics.ts All looks good. File: src/blocks/theme/semantics/semantics.slider.ts All looks good. File: yarn.lock All looks good. |
In the
In the
All looks good. |
In the
In the
Everything else in the provided files looks good. Corrected
Corrected const StyledSlider = styled(ReactSlider)<{ range?: boolean }>`
.horizontal-slider-track {
height: var(--spacing-xxxs);
background-color: var(--components-slider-background-default);
border-radius: var(--border-sm);
}
.horizontal-slider-thumb {
width: var(--spacing-sm);
height: var(--spacing-sm);
margin-top: -6px;
background-color: var(--components-slider-icon-default);
border: var(--border-sm) solid var(--components-slider-stroke-default);
border-radius: 50%;
cursor: pointer;
&:active,
&:focus {
outline: none;
}
${({ range }) =>
range
? css`
.horizontal-slider-track-1 {
background-color: var(--components-slider-background-progress);
}
`
: css`
.horizontal-slider-track-0 {
}
`}
`;
const Slider = <T extends number | [number, number]>({
min,
max,
onChange,
value,
step,
defaultValue,
}: SliderProps<T>) => {
return (
<StyledSlider
{...{ min, max, value, step, defaultValue }}
className="horizontal-slider"
thumbClassName="horizontal-slider-thumb"
trackClassName="horizontal-slider-track"
ariaLabel={isArray(value) ? ['Lower thumb', 'Upper thumb'] : 'Thumb'}
ariaValuetext={(state) => `Thumb value ${state.valueNow}`}
onChange={(value) => onChange(value as T)}
value={value}
range={isArray(value)}
/>
);
};
Slider.displayName = 'Slider';
export { Slider }; All looks good. |
Pull Request Template
Ticket Number
Description
Problem/Feature:
Type of Change
Checklist
Frontend Guidelines
Build & Testing
Review & Approvals
Notes