mirror of
https://github.com/Redocly/redoc.git
synced 2024-11-25 18:13:44 +03:00
fix: update EnumValues component (#1324)
This commit is contained in:
parent
676faa943a
commit
de27ac0308
|
@ -26,7 +26,7 @@ const specUrl =
|
||||||
(userUrl && userUrl[1]) || (swagger ? 'swagger.yaml' : big ? 'big-openapi.json' : 'openapi.yaml');
|
(userUrl && userUrl[1]) || (swagger ? 'swagger.yaml' : big ? 'big-openapi.json' : 'openapi.yaml');
|
||||||
|
|
||||||
let store;
|
let store;
|
||||||
const options: RedocRawOptions = { nativeScrollbars: false, maxDisplayedEnumValues: 2 };
|
const options: RedocRawOptions = { nativeScrollbars: false, maxDisplayedEnumValues: 3 };
|
||||||
|
|
||||||
async function init() {
|
async function init() {
|
||||||
const spec = await loadAndBundleSpec(specUrl);
|
const spec = await loadAndBundleSpec(specUrl);
|
||||||
|
|
|
@ -42,6 +42,16 @@ export class EnumValues extends React.PureComponent<EnumValuesProps, EnumValuesS
|
||||||
? values.slice(0, maxDisplayedEnumValues)
|
? values.slice(0, maxDisplayedEnumValues)
|
||||||
: values;
|
: values;
|
||||||
|
|
||||||
|
const showToggleButton = maxDisplayedEnumValues
|
||||||
|
? values.length > maxDisplayedEnumValues
|
||||||
|
: false;
|
||||||
|
|
||||||
|
const toggleButtonText = maxDisplayedEnumValues
|
||||||
|
? collapsed
|
||||||
|
? `… ${values.length - maxDisplayedEnumValues} more`
|
||||||
|
: 'Hide'
|
||||||
|
: '';
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<FieldLabel>
|
<FieldLabel>
|
||||||
|
@ -56,13 +66,13 @@ export class EnumValues extends React.PureComponent<EnumValuesProps, EnumValuesS
|
||||||
</React.Fragment>
|
</React.Fragment>
|
||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
{maxDisplayedEnumValues ? (
|
{showToggleButton ? (
|
||||||
<ToggleButton
|
<ToggleButton
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
this.toggle();
|
this.toggle();
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{collapsed ? `… ${values.length - maxDisplayedEnumValues} more` : 'Hide'}
|
{toggleButtonText}
|
||||||
</ToggleButton>
|
</ToggleButton>
|
||||||
) : null}
|
) : null}
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user