mirror of
https://github.com/Redocly/redoc.git
synced 2025-08-07 21:54:53 +03:00
fix: update StyledCallbackTitle
to fix chevron animation
This commit is contained in:
parent
0511c678db
commit
03586cfcec
|
@ -12,13 +12,16 @@ export class CallbackOperation extends React.Component<{ callbackOperation: Oper
|
|||
};
|
||||
|
||||
render() {
|
||||
const { expanded } = this.props.callbackOperation;
|
||||
const { name, expanded, httpVerb, deprecated } = this.props.callbackOperation;
|
||||
|
||||
return (
|
||||
<>
|
||||
<StyledCallbackTitle
|
||||
onClick={this.toggle}
|
||||
callbackOperation={this.props.callbackOperation}
|
||||
name={name}
|
||||
opened={expanded}
|
||||
httpVerb={httpVerb}
|
||||
deprecated={deprecated}
|
||||
/>
|
||||
{expanded && <CallbackDetails operation={this.props.callbackOperation} />}
|
||||
</>
|
||||
|
|
|
@ -6,23 +6,24 @@ import { shortenHTTPVerb } from '../../utils/openapi';
|
|||
import styled from '../../styled-components';
|
||||
import { Badge } from '../../common-elements/';
|
||||
import { l } from '../../services/Labels';
|
||||
import { OperationModel } from '../../services/models';
|
||||
|
||||
export interface CallbackTitleProps {
|
||||
name: string;
|
||||
opened?: boolean;
|
||||
httpVerb: string;
|
||||
deprecated?: boolean;
|
||||
className?: string;
|
||||
onClick?: () => void;
|
||||
callbackOperation: OperationModel;
|
||||
}
|
||||
|
||||
export class CallbackTitle extends React.PureComponent<CallbackTitleProps> {
|
||||
render() {
|
||||
const { className, onClick, callbackOperation } = this.props;
|
||||
const { name, httpVerb, deprecated, expanded } = callbackOperation;
|
||||
const { name, opened, className, onClick, httpVerb, deprecated } = this.props;
|
||||
|
||||
return (
|
||||
<CallbackTitleWrapper className={className} onClick={onClick || undefined}>
|
||||
<OperationBadgeStyled type={httpVerb}>{shortenHTTPVerb(httpVerb)}</OperationBadgeStyled>
|
||||
<ShelfIcon size={'1.5em'} direction={expanded ? 'down' : 'right'} float={'left'} />
|
||||
<ShelfIcon size={'1.5em'} direction={opened ? 'down' : 'right'} float={'left'} />
|
||||
<CallbackName deprecated={deprecated}>{name}</CallbackName>
|
||||
{deprecated ? <Badge type="warning"> {l('deprecated')} </Badge> : null}
|
||||
</CallbackTitleWrapper>
|
||||
|
@ -34,6 +35,12 @@ const CallbackTitleWrapper = styled.div`
|
|||
& > * {
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
${ShelfIcon} {
|
||||
polygon {
|
||||
fill: ${({ theme }) => theme.colors.gray.A200};
|
||||
}
|
||||
}
|
||||
`;
|
||||
|
||||
const CallbackName = styled.span<{ deprecated?: boolean }>`
|
||||
|
|
|
@ -8,7 +8,6 @@ import { CallbackModel } from '../../services/models/Callback';
|
|||
import { RedocNormalizedOptions } from '../../services/RedocNormalizedOptions';
|
||||
import { CallbacksList, CallbackTitle, CallbackOperation } from '../Callbacks';
|
||||
import * as simpleCallbackFixture from './fixtures/simple-callback.json';
|
||||
import { OperationModel } from '../../services/models';
|
||||
|
||||
const options = new RedocNormalizedOptions({});
|
||||
describe('Components', () => {
|
||||
|
@ -32,16 +31,8 @@ describe('Components', () => {
|
|||
});
|
||||
|
||||
it('should correctly render CallbackTitle', () => {
|
||||
const callbackOperation = {
|
||||
name: 'Test',
|
||||
httpVerb: 'get',
|
||||
} as OperationModel;
|
||||
const callbackTitleViewElement = shallow(
|
||||
<CallbackTitle
|
||||
className={'.test'}
|
||||
onClick={undefined}
|
||||
callbackOperation={callbackOperation}
|
||||
/>,
|
||||
<CallbackTitle name={'Test'} className={'.test'} onClick={undefined} httpVerb={'get'} />,
|
||||
).getElement();
|
||||
expect(callbackTitleViewElement.props).toBeDefined();
|
||||
expect(callbackTitleViewElement.props.className).toEqual('.test');
|
||||
|
|
Loading…
Reference in New Issue
Block a user