Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 23 additions & 12 deletions src/components/inputs/accent-range.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import React from 'react';
import React, {useState} from 'react';
import styled from 'styled-components';
import {NumberInput} from 'src/components/panes/configure-panes/submenus/macros/keycode-sequence-components';

const Container = styled.span`
display: inline-block;
display: flex;
gap: 10px;
align-items: space-between;
line-height: initial;
width: 200px;
`;
Expand All @@ -16,13 +19,21 @@ export const AccentRange: React.FC<
Omit<React.InputHTMLAttributes<HTMLInputElement>, 'onChange'> & {
onChange: (x: number) => void;
}
> = (props) => (
<Container>
<SliderInput
{...props}
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
props.onChange && props.onChange(+e.target.value);
}}
/>
</Container>
);
> = (props) => {
const [value, setValue] = useState<number>(
(props.defaultValue as number) || 0,
);

const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
const newValue = +e.target.value;
setValue(newValue);
props.onChange && props.onChange(newValue);
};

return (
<Container>
<SliderInput {...props} value={value} onChange={handleChange} />
<NumberInput {...props} value={value} onChange={handleChange} />
</Container>
);
};