mirror of
https://github.com/Redocly/redoc.git
synced 2024-11-22 08:36:33 +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');
|
||||
|
||||
let store;
|
||||
const options: RedocRawOptions = { nativeScrollbars: false, maxDisplayedEnumValues: 2 };
|
||||
const options: RedocRawOptions = { nativeScrollbars: false, maxDisplayedEnumValues: 3 };
|
||||
|
||||
async function init() {
|
||||
const spec = await loadAndBundleSpec(specUrl);
|
||||
|
|
|
@ -42,6 +42,16 @@ export class EnumValues extends React.PureComponent<EnumValuesProps, EnumValuesS
|
|||
? values.slice(0, maxDisplayedEnumValues)
|
||||
: values;
|
||||
|
||||
const showToggleButton = maxDisplayedEnumValues
|
||||
? values.length > maxDisplayedEnumValues
|
||||
: false;
|
||||
|
||||
const toggleButtonText = maxDisplayedEnumValues
|
||||
? collapsed
|
||||
? `… ${values.length - maxDisplayedEnumValues} more`
|
||||
: 'Hide'
|
||||
: '';
|
||||
|
||||
return (
|
||||
<div>
|
||||
<FieldLabel>
|
||||
|
@ -56,13 +66,13 @@ export class EnumValues extends React.PureComponent<EnumValuesProps, EnumValuesS
|
|||
</React.Fragment>
|
||||
);
|
||||
})}
|
||||
{maxDisplayedEnumValues ? (
|
||||
{showToggleButton ? (
|
||||
<ToggleButton
|
||||
onClick={() => {
|
||||
this.toggle();
|
||||
}}
|
||||
>
|
||||
{collapsed ? `… ${values.length - maxDisplayedEnumValues} more` : 'Hide'}
|
||||
{toggleButtonText}
|
||||
</ToggleButton>
|
||||
) : null}
|
||||
</div>
|
||||
|
|
Loading…
Reference in New Issue
Block a user