mirror of
https://github.com/Redocly/redoc.git
synced 2024-11-28 19:43:43 +03:00
fix: improve customization fab (#1891)
This commit is contained in:
parent
eb4040afd8
commit
635f379eb0
|
@ -217,6 +217,7 @@ You can use all of the following options with the standalone version of the <red
|
||||||
* `hideDownloadButton` - do not show "Download" spec button. **THIS DOESN'T MAKE YOUR SPEC PRIVATE**, it just hides the button.
|
* `hideDownloadButton` - do not show "Download" spec button. **THIS DOESN'T MAKE YOUR SPEC PRIVATE**, it just hides the button.
|
||||||
* `hideHostname` - if set, the protocol and hostname is not shown in the operation definition.
|
* `hideHostname` - if set, the protocol and hostname is not shown in the operation definition.
|
||||||
* `hideLoading` - do not show loading animation. Useful for small docs.
|
* `hideLoading` - do not show loading animation. Useful for small docs.
|
||||||
|
* `hideFab` - do not show FAB in mobile view. Useful for implementing a custom floating action button.
|
||||||
* `hideSchemaPattern` - if set, the pattern is not shown in the schema.
|
* `hideSchemaPattern` - if set, the pattern is not shown in the schema.
|
||||||
* `hideSingleRequestSampleTab` - do not show the request sample tab for requests with only one sample.
|
* `hideSingleRequestSampleTab` - do not show the request sample tab for requests with only one sample.
|
||||||
* `showObjectSchemaExamples` - show object schema example in the properties, default `false`.
|
* `showObjectSchemaExamples` - show object schema example in the properties, default `false`.
|
||||||
|
@ -305,6 +306,9 @@ You can use all of the following options with the standalone version of the <red
|
||||||
* `backgroundColor`: '#263238'
|
* `backgroundColor`: '#263238'
|
||||||
* `width`: '40%'
|
* `width`: '40%'
|
||||||
* `textColor`: '#ffffff'
|
* `textColor`: '#ffffff'
|
||||||
|
* `fab`
|
||||||
|
* `backgroundColor`: '#263238'
|
||||||
|
* `color`: '#ffffff'
|
||||||
|
|
||||||
-----------
|
-----------
|
||||||
## Development
|
## Development
|
||||||
|
|
|
@ -56,7 +56,7 @@ const StyledStickySidebar = styled.div<{ open?: boolean }>`
|
||||||
const FloatingButton = styled.div`
|
const FloatingButton = styled.div`
|
||||||
outline: none;
|
outline: none;
|
||||||
user-select: none;
|
user-select: none;
|
||||||
background-color: #f2f2f2;
|
background-color: ${({ theme }) => theme.fab.backgroundColor};
|
||||||
color: ${props => props.theme.colors.primary.main};
|
color: ${props => props.theme.colors.primary.main};
|
||||||
display: none;
|
display: none;
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
@ -74,6 +74,9 @@ const FloatingButton = styled.div`
|
||||||
width: 60px;
|
width: 60px;
|
||||||
height: 60px;
|
height: 60px;
|
||||||
padding: 0 20px;
|
padding: 0 20px;
|
||||||
|
svg {
|
||||||
|
color: ${({ theme }) => theme.fab.color};
|
||||||
|
}
|
||||||
|
|
||||||
@media print {
|
@media print {
|
||||||
display: none;
|
display: none;
|
||||||
|
@ -140,9 +143,11 @@ export class StickyResponsiveSidebar extends React.Component<
|
||||||
>
|
>
|
||||||
{this.props.children}
|
{this.props.children}
|
||||||
</StyledStickySidebar>
|
</StyledStickySidebar>
|
||||||
<FloatingButton onClick={this.toggleNavMenu}>
|
{!this.context.hideFab && (
|
||||||
<AnimatedChevronButton open={open} />
|
<FloatingButton onClick={this.toggleNavMenu}>
|
||||||
</FloatingButton>
|
<AnimatedChevronButton open={open} />
|
||||||
|
</FloatingButton>
|
||||||
|
)}
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -80,6 +80,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
||||||
"expandSingleSchemaField": false,
|
"expandSingleSchemaField": false,
|
||||||
"generatedPayloadSamplesMaxDepth": 10,
|
"generatedPayloadSamplesMaxDepth": 10,
|
||||||
"hideDownloadButton": false,
|
"hideDownloadButton": false,
|
||||||
|
"hideFab": false,
|
||||||
"hideHostname": false,
|
"hideHostname": false,
|
||||||
"hideSchemaPattern": false,
|
"hideSchemaPattern": false,
|
||||||
"hideSchemaTitles": false,
|
"hideSchemaTitles": false,
|
||||||
|
@ -186,6 +187,10 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"extensionsHook": undefined,
|
"extensionsHook": undefined,
|
||||||
|
"fab": Object {
|
||||||
|
"backgroundColor": "#f2f2f2",
|
||||||
|
"color": "#0065FB",
|
||||||
|
},
|
||||||
"logo": Object {
|
"logo": Object {
|
||||||
"gutter": "2px",
|
"gutter": "2px",
|
||||||
"maxHeight": "260px",
|
"maxHeight": "260px",
|
||||||
|
@ -320,6 +325,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
||||||
"expandSingleSchemaField": false,
|
"expandSingleSchemaField": false,
|
||||||
"generatedPayloadSamplesMaxDepth": 10,
|
"generatedPayloadSamplesMaxDepth": 10,
|
||||||
"hideDownloadButton": false,
|
"hideDownloadButton": false,
|
||||||
|
"hideFab": false,
|
||||||
"hideHostname": false,
|
"hideHostname": false,
|
||||||
"hideSchemaPattern": false,
|
"hideSchemaPattern": false,
|
||||||
"hideSchemaTitles": false,
|
"hideSchemaTitles": false,
|
||||||
|
@ -426,6 +432,10 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"extensionsHook": undefined,
|
"extensionsHook": undefined,
|
||||||
|
"fab": Object {
|
||||||
|
"backgroundColor": "#f2f2f2",
|
||||||
|
"color": "#0065FB",
|
||||||
|
},
|
||||||
"logo": Object {
|
"logo": Object {
|
||||||
"gutter": "2px",
|
"gutter": "2px",
|
||||||
"maxHeight": "260px",
|
"maxHeight": "260px",
|
||||||
|
@ -536,6 +546,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
||||||
"expandSingleSchemaField": false,
|
"expandSingleSchemaField": false,
|
||||||
"generatedPayloadSamplesMaxDepth": 10,
|
"generatedPayloadSamplesMaxDepth": 10,
|
||||||
"hideDownloadButton": false,
|
"hideDownloadButton": false,
|
||||||
|
"hideFab": false,
|
||||||
"hideHostname": false,
|
"hideHostname": false,
|
||||||
"hideSchemaPattern": false,
|
"hideSchemaPattern": false,
|
||||||
"hideSchemaTitles": false,
|
"hideSchemaTitles": false,
|
||||||
|
@ -642,6 +653,10 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"extensionsHook": undefined,
|
"extensionsHook": undefined,
|
||||||
|
"fab": Object {
|
||||||
|
"backgroundColor": "#f2f2f2",
|
||||||
|
"color": "#0065FB",
|
||||||
|
},
|
||||||
"logo": Object {
|
"logo": Object {
|
||||||
"gutter": "2px",
|
"gutter": "2px",
|
||||||
"maxHeight": "260px",
|
"maxHeight": "260px",
|
||||||
|
@ -817,6 +832,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
||||||
"expandSingleSchemaField": false,
|
"expandSingleSchemaField": false,
|
||||||
"generatedPayloadSamplesMaxDepth": 10,
|
"generatedPayloadSamplesMaxDepth": 10,
|
||||||
"hideDownloadButton": false,
|
"hideDownloadButton": false,
|
||||||
|
"hideFab": false,
|
||||||
"hideHostname": false,
|
"hideHostname": false,
|
||||||
"hideSchemaPattern": false,
|
"hideSchemaPattern": false,
|
||||||
"hideSchemaTitles": false,
|
"hideSchemaTitles": false,
|
||||||
|
@ -923,6 +939,10 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"extensionsHook": undefined,
|
"extensionsHook": undefined,
|
||||||
|
"fab": Object {
|
||||||
|
"backgroundColor": "#f2f2f2",
|
||||||
|
"color": "#0065FB",
|
||||||
|
},
|
||||||
"logo": Object {
|
"logo": Object {
|
||||||
"gutter": "2px",
|
"gutter": "2px",
|
||||||
"maxHeight": "260px",
|
"maxHeight": "260px",
|
||||||
|
@ -1057,6 +1077,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
||||||
"expandSingleSchemaField": false,
|
"expandSingleSchemaField": false,
|
||||||
"generatedPayloadSamplesMaxDepth": 10,
|
"generatedPayloadSamplesMaxDepth": 10,
|
||||||
"hideDownloadButton": false,
|
"hideDownloadButton": false,
|
||||||
|
"hideFab": false,
|
||||||
"hideHostname": false,
|
"hideHostname": false,
|
||||||
"hideSchemaPattern": false,
|
"hideSchemaPattern": false,
|
||||||
"hideSchemaTitles": false,
|
"hideSchemaTitles": false,
|
||||||
|
@ -1163,6 +1184,10 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"extensionsHook": undefined,
|
"extensionsHook": undefined,
|
||||||
|
"fab": Object {
|
||||||
|
"backgroundColor": "#f2f2f2",
|
||||||
|
"color": "#0065FB",
|
||||||
|
},
|
||||||
"logo": Object {
|
"logo": Object {
|
||||||
"gutter": "2px",
|
"gutter": "2px",
|
||||||
"maxHeight": "260px",
|
"maxHeight": "260px",
|
||||||
|
@ -1273,6 +1298,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
||||||
"expandSingleSchemaField": false,
|
"expandSingleSchemaField": false,
|
||||||
"generatedPayloadSamplesMaxDepth": 10,
|
"generatedPayloadSamplesMaxDepth": 10,
|
||||||
"hideDownloadButton": false,
|
"hideDownloadButton": false,
|
||||||
|
"hideFab": false,
|
||||||
"hideHostname": false,
|
"hideHostname": false,
|
||||||
"hideSchemaPattern": false,
|
"hideSchemaPattern": false,
|
||||||
"hideSchemaTitles": false,
|
"hideSchemaTitles": false,
|
||||||
|
@ -1379,6 +1405,10 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"extensionsHook": undefined,
|
"extensionsHook": undefined,
|
||||||
|
"fab": Object {
|
||||||
|
"backgroundColor": "#f2f2f2",
|
||||||
|
"color": "#0065FB",
|
||||||
|
},
|
||||||
"logo": Object {
|
"logo": Object {
|
||||||
"gutter": "2px",
|
"gutter": "2px",
|
||||||
"maxHeight": "260px",
|
"maxHeight": "260px",
|
||||||
|
@ -1512,6 +1542,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
||||||
"expandSingleSchemaField": false,
|
"expandSingleSchemaField": false,
|
||||||
"generatedPayloadSamplesMaxDepth": 10,
|
"generatedPayloadSamplesMaxDepth": 10,
|
||||||
"hideDownloadButton": false,
|
"hideDownloadButton": false,
|
||||||
|
"hideFab": false,
|
||||||
"hideHostname": false,
|
"hideHostname": false,
|
||||||
"hideSchemaPattern": false,
|
"hideSchemaPattern": false,
|
||||||
"hideSchemaTitles": false,
|
"hideSchemaTitles": false,
|
||||||
|
@ -1618,6 +1649,10 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"extensionsHook": undefined,
|
"extensionsHook": undefined,
|
||||||
|
"fab": Object {
|
||||||
|
"backgroundColor": "#f2f2f2",
|
||||||
|
"color": "#0065FB",
|
||||||
|
},
|
||||||
"logo": Object {
|
"logo": Object {
|
||||||
"gutter": "2px",
|
"gutter": "2px",
|
||||||
"maxHeight": "260px",
|
"maxHeight": "260px",
|
||||||
|
@ -1790,6 +1825,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
||||||
"expandSingleSchemaField": false,
|
"expandSingleSchemaField": false,
|
||||||
"generatedPayloadSamplesMaxDepth": 10,
|
"generatedPayloadSamplesMaxDepth": 10,
|
||||||
"hideDownloadButton": false,
|
"hideDownloadButton": false,
|
||||||
|
"hideFab": false,
|
||||||
"hideHostname": false,
|
"hideHostname": false,
|
||||||
"hideSchemaPattern": false,
|
"hideSchemaPattern": false,
|
||||||
"hideSchemaTitles": false,
|
"hideSchemaTitles": false,
|
||||||
|
@ -1896,6 +1932,10 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"extensionsHook": undefined,
|
"extensionsHook": undefined,
|
||||||
|
"fab": Object {
|
||||||
|
"backgroundColor": "#f2f2f2",
|
||||||
|
"color": "#0065FB",
|
||||||
|
},
|
||||||
"logo": Object {
|
"logo": Object {
|
||||||
"gutter": "2px",
|
"gutter": "2px",
|
||||||
"maxHeight": "260px",
|
"maxHeight": "260px",
|
||||||
|
@ -2030,6 +2070,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
||||||
"expandSingleSchemaField": false,
|
"expandSingleSchemaField": false,
|
||||||
"generatedPayloadSamplesMaxDepth": 10,
|
"generatedPayloadSamplesMaxDepth": 10,
|
||||||
"hideDownloadButton": false,
|
"hideDownloadButton": false,
|
||||||
|
"hideFab": false,
|
||||||
"hideHostname": false,
|
"hideHostname": false,
|
||||||
"hideSchemaPattern": false,
|
"hideSchemaPattern": false,
|
||||||
"hideSchemaTitles": false,
|
"hideSchemaTitles": false,
|
||||||
|
@ -2136,6 +2177,10 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"extensionsHook": undefined,
|
"extensionsHook": undefined,
|
||||||
|
"fab": Object {
|
||||||
|
"backgroundColor": "#f2f2f2",
|
||||||
|
"color": "#0065FB",
|
||||||
|
},
|
||||||
"logo": Object {
|
"logo": Object {
|
||||||
"gutter": "2px",
|
"gutter": "2px",
|
||||||
"maxHeight": "260px",
|
"maxHeight": "260px",
|
||||||
|
@ -2246,6 +2291,7 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
||||||
"expandSingleSchemaField": false,
|
"expandSingleSchemaField": false,
|
||||||
"generatedPayloadSamplesMaxDepth": 10,
|
"generatedPayloadSamplesMaxDepth": 10,
|
||||||
"hideDownloadButton": false,
|
"hideDownloadButton": false,
|
||||||
|
"hideFab": false,
|
||||||
"hideHostname": false,
|
"hideHostname": false,
|
||||||
"hideSchemaPattern": false,
|
"hideSchemaPattern": false,
|
||||||
"hideSchemaTitles": false,
|
"hideSchemaTitles": false,
|
||||||
|
@ -2352,6 +2398,10 @@ exports[`Components SchemaView discriminator should correctly render SchemaView
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
"extensionsHook": undefined,
|
"extensionsHook": undefined,
|
||||||
|
"fab": Object {
|
||||||
|
"backgroundColor": "#f2f2f2",
|
||||||
|
"color": "#0065FB",
|
||||||
|
},
|
||||||
"logo": Object {
|
"logo": Object {
|
||||||
"gutter": "2px",
|
"gutter": "2px",
|
||||||
"maxHeight": "260px",
|
"maxHeight": "260px",
|
||||||
|
|
|
@ -53,6 +53,7 @@ export interface RedocRawOptions {
|
||||||
ignoreNamedSchemas?: string[] | string;
|
ignoreNamedSchemas?: string[] | string;
|
||||||
hideSchemaPattern?: boolean;
|
hideSchemaPattern?: boolean;
|
||||||
generatedPayloadSamplesMaxDepth?: number;
|
generatedPayloadSamplesMaxDepth?: number;
|
||||||
|
hideFab?: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
export function argValueToBoolean(val?: string | boolean, defaultValue?: boolean): boolean {
|
export function argValueToBoolean(val?: string | boolean, defaultValue?: boolean): boolean {
|
||||||
|
@ -245,6 +246,7 @@ export class RedocNormalizedOptions {
|
||||||
ignoreNamedSchemas: Set<string>;
|
ignoreNamedSchemas: Set<string>;
|
||||||
hideSchemaPattern: boolean;
|
hideSchemaPattern: boolean;
|
||||||
generatedPayloadSamplesMaxDepth: number;
|
generatedPayloadSamplesMaxDepth: number;
|
||||||
|
hideFab: boolean;
|
||||||
|
|
||||||
constructor(raw: RedocRawOptions, defaults: RedocRawOptions = {}) {
|
constructor(raw: RedocRawOptions, defaults: RedocRawOptions = {}) {
|
||||||
raw = { ...defaults, ...raw };
|
raw = { ...defaults, ...raw };
|
||||||
|
@ -315,5 +317,6 @@ export class RedocNormalizedOptions {
|
||||||
RedocNormalizedOptions.normalizeGeneratedPayloadSamplesMaxDepth(
|
RedocNormalizedOptions.normalizeGeneratedPayloadSamplesMaxDepth(
|
||||||
raw.generatedPayloadSamplesMaxDepth,
|
raw.generatedPayloadSamplesMaxDepth,
|
||||||
);
|
);
|
||||||
|
this.hideFab = argValueToBoolean(raw.hideFab);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -162,6 +162,10 @@ const defaultTheme: ThemeInterface = {
|
||||||
codeBlock: {
|
codeBlock: {
|
||||||
backgroundColor: ({ rightPanel }) => darken(0.1, rightPanel.backgroundColor),
|
backgroundColor: ({ rightPanel }) => darken(0.1, rightPanel.backgroundColor),
|
||||||
},
|
},
|
||||||
|
fab: {
|
||||||
|
backgroundColor: '#f2f2f2',
|
||||||
|
color: '#0065FB',
|
||||||
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
export default defaultTheme;
|
export default defaultTheme;
|
||||||
|
@ -338,6 +342,10 @@ export interface ResolvedThemeInterface {
|
||||||
codeBlock: {
|
codeBlock: {
|
||||||
backgroundColor: string;
|
backgroundColor: string;
|
||||||
};
|
};
|
||||||
|
fab: {
|
||||||
|
backgroundColor: string;
|
||||||
|
color: string;
|
||||||
|
};
|
||||||
|
|
||||||
extensionsHook?: (name: string, props: any) => string;
|
extensionsHook?: (name: string, props: any) => string;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user