Skip to content

Commit 7206b15

Browse files
committed
[REVERT ME] issue repro
1 parent 9400504 commit 7206b15

1 file changed

Lines changed: 40 additions & 56 deletions

File tree

src-docs/src/views/range/range.tsx

Lines changed: 40 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,48 @@
1-
import React, { useState } from 'react';
1+
import React, { useState, useMemo } from 'react';
22

3-
import { EuiRange, EuiRangeProps, EuiSpacer } from '../../../../src/components';
3+
import { EuiRange, EuiAccordion } from '../../../../src/components';
44

5-
import { useGeneratedHtmlId } from '../../../../src/services';
5+
// import { useGeneratedHtmlId } from '../../../../src/services';
66

77
export default () => {
8-
const [value, setValue] = useState('120');
9-
10-
const basicRangeId = useGeneratedHtmlId({ prefix: 'basicRange' });
11-
const rangeWithShowValueId = useGeneratedHtmlId({
12-
prefix: 'rangeWithShowValue',
13-
});
14-
const rangeWithValuePrependId = useGeneratedHtmlId({
15-
prefix: 'rangeWithValuePrepend',
16-
});
17-
18-
const onChange: EuiRangeProps['onChange'] = (e) => {
19-
setValue(e.currentTarget.value);
20-
};
8+
const [value, setValue] = useState(21);
9+
const [active, setActive] = useState(false);
10+
11+
const range = useMemo(
12+
() => (
13+
<>
14+
<div
15+
style={{
16+
display: active ? undefined : 'none',
17+
}}
18+
>
19+
<EuiRange
20+
value={value}
21+
onChange={(e) => {
22+
const range = e.currentTarget.value;
23+
setValue(Number(range.trim()));
24+
}}
25+
max={100}
26+
min={0}
27+
showRange
28+
showInput
29+
fullWidth={false}
30+
showTicks
31+
tickInterval={25}
32+
/>
33+
</div>
34+
</>
35+
),
36+
[active, value]
37+
);
2138

2239
return (
23-
<>
24-
<EuiRange
25-
id={basicRangeId}
26-
min={100}
27-
max={200}
28-
step={0.05}
29-
value={value}
30-
onChange={onChange}
31-
showLabels
32-
aria-label="An example of EuiRange with showLabels prop"
33-
/>
34-
35-
<EuiSpacer size="xl" />
36-
37-
<EuiRange
38-
id={rangeWithShowValueId}
39-
min={100}
40-
max={200}
41-
value={value}
42-
onChange={onChange}
43-
showLabels
44-
showValue
45-
aria-label="An example of EuiRange with showValue prop"
46-
/>
47-
48-
<EuiSpacer size="xl" />
49-
50-
<EuiRange
51-
id={rangeWithValuePrependId}
52-
min={100}
53-
max={200}
54-
value={value}
55-
onChange={onChange}
56-
showLabels
57-
showRange
58-
showValue
59-
valuePrepend="100 - "
60-
aria-label="An example of EuiRange with valuePrepend prop"
61-
/>
62-
</>
40+
<EuiAccordion
41+
id="rangeTest"
42+
buttonContent="Toggle accordion"
43+
onToggle={() => setActive(!active)}
44+
>
45+
{range}
46+
</EuiAccordion>
6347
);
6448
};

0 commit comments

Comments
 (0)