Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions library/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
"build:standalone": "cross-env BUILD_MODE=standalone webpack",
"build:types": "tsc -p tsconfig.types.json",
"build:styles": "npm run build:styles:dev && npm run build:styles:prod",
"build:styles:dev": "cross-env NODE_ENV=production postcss src/styles/default.css -o styles/default.css --verbose",
"build:styles:dev": "cross-env NODE_ENV=development postcss src/styles/default.css -o styles/default.css --verbose & cross-env NODE_ENV=development postcss src/styles/default.css -o styles/default.min.css --verbose",
"build:styles:prod": "cross-env NODE_ENV=production MINIFY_STYLES=true postcss src/styles/default.css -o styles/default.min.css --verbose",
"test": "npm run test:unit && npm run test:e2e",
"test:unit": "jest --detectOpenHandles",
Expand Down Expand Up @@ -117,4 +117,4 @@
"publishConfig": {
"access": "public"
}
}
}
132 changes: 132 additions & 0 deletions library/src/assets/asyncapi-logo.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
import * as React from 'react';
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const AsyncapiLogo = (props: any) => (
<svg
id="Layer_1"
data-name="Layer 1"
xmlns="http://www.w3.org/2000/svg"
xmlnsXlink="http://www.w3.org/1999/xlink"
viewBox="0 0 155.51 155.51"
{...props}
>
<defs>
<style>
{
'.cls-1{fill:url(#linear-gradient);}.cls-2{fill:url(#linear-gradient-2);}.cls-3{fill:url(#linear-gradient-3);}.cls-4{fill:url(#linear-gradient-4);}.cls-5{fill:#fff;}'
}
</style>
<linearGradient
id="linear-gradient"
x1={133.74}
y1={21.76}
x2={24.84}
y2={130.67}
gradientUnits="userSpaceOnUse"
>
<stop offset={0} stopColor="#2dccfd" />
<stop offset={1} stopColor="#ad20e2" />
</linearGradient>
<linearGradient
id="linear-gradient-2"
x1={6471.36}
y1={6969.64}
x2={6362.46}
y2={7078.54}
gradientTransform="translate(7103.38 -6337.62) rotate(90)"
gradientUnits="userSpaceOnUse"
>
<stop offset={0} stopColor="#a829e2" />
<stop offset={0.05} stopColor="#a829e2" stopOpacity={0.84} />
<stop offset={0.11} stopColor="#a829e2" stopOpacity={0.67} />
<stop offset={0.18} stopColor="#a829e2" stopOpacity={0.51} />
<stop offset={0.25} stopColor="#a829e2" stopOpacity={0.38} />
<stop offset={0.33} stopColor="#a829e2" stopOpacity={0.28} />
<stop offset={0.43} stopColor="#a829e2" stopOpacity={0.2} />
<stop offset={0.54} stopColor="#a829e2" stopOpacity={0.14} />
<stop offset={0.68} stopColor="#a829e2" stopOpacity={0.11} />
<stop offset={1} stopColor="#a829e2" stopOpacity={0.1} />
</linearGradient>
<linearGradient
id="linear-gradient-3"
x1={13419.24}
y1={632.02}
x2={13310.33}
y2={740.92}
gradientTransform="translate(13441 765.76) rotate(180)"
gradientUnits="userSpaceOnUse"
>
<stop offset={0} stopColor="#e50e99" />
<stop offset={1} stopColor="#a829e2" stopOpacity={0.1} />
</linearGradient>
<linearGradient
id="linear-gradient-4"
x1={138.74}
y1={-7.39}
x2={29.84}
y2={101.52}
gradientTransform="translate(-5 29.16)"
gradientUnits="userSpaceOnUse"
>
<stop offset={0} stopColor="#21d4fd" />
<stop offset={0.03} stopColor="#27cdfc" stopOpacity={0.96} />
<stop offset={0.23} stopColor="#4e9cf4" stopOpacity={0.7} />
<stop offset={0.43} stopColor="#6e73ee" stopOpacity={0.49} />
<stop offset={0.61} stopColor="#8753e9" stopOpacity={0.32} />
<stop offset={0.77} stopColor="#993ce5" stopOpacity={0.2} />
<stop offset={0.9} stopColor="#a42ee3" stopOpacity={0.13} />
<stop offset={1} stopColor="#a829e2" stopOpacity={0.1} />
</linearGradient>
</defs>
<rect
className="cls-1"
x={8.88}
y={8.88}
width={137.75}
height={137.75}
rx={32.58}
/>
<rect
className="cls-2"
x={8.88}
y={8.88}
width={137.75}
height={137.75}
rx={32.58}
/>
<rect
className="cls-3"
x={8.88}
y={8.88}
width={137.75}
height={137.75}
rx={32.58}
/>
<rect
className="cls-4"
x={8.88}
y={8.88}
width={137.75}
height={137.75}
rx={32.58}
/>
<g id="New_lines" data-name="New lines">
<polygon
className="cls-5"
points="53.35 63.21 49.25 68.86 81.27 92.1 81.49 92.26 85.59 86.61 53.57 63.37 53.35 63.21"
/>
<polygon
className="cls-5"
points="74.27 63.37 74.05 63.21 69.95 68.86 101.97 92.1 102.19 92.26 106.29 86.61 74.27 63.37"
/>
<path
className="cls-5"
d="M77.78,34.29c-17.35,0-31.48,10.79-31.48,24.06v.27h7v-.27c0-9.42,11-17.08,24.5-17.08s24.51,7.66,24.51,17.08v.27h7v-.27C109.27,45.08,95.14,34.29,77.78,34.29Z"
/>
<path
className="cls-5"
d="M102.23,97.16c0,9.42-11,17.08-24.51,17.08s-24.5-7.66-24.5-17.08v-.27h-7v.27c0,13.26,14.13,24,31.48,24s31.49-10.79,31.49-24v-.27h-7Z"
/>
</g>
</svg>
);
export default AsyncapiLogo;
25 changes: 22 additions & 3 deletions library/src/containers/AsyncApi/AsyncApi.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
import React, { Component } from 'react';
import { AsyncAPIDocumentInterface } from '@asyncapi/parser';

import AsyncApiStandalone from './Standalone';

import {
isFetchingSchemaInterface,
ErrorObject,
PropsSchema,
} from '../../types';
import { ConfigInterface } from '../../config';
import { SpecificationHelpers, Parser } from '../../helpers';
import AsyncapiLogo from '../../assets/asyncapi-logo';

export interface AsyncApiProps {
schema: PropsSchema;
Expand All @@ -19,18 +18,21 @@ export interface AsyncApiProps {
interface AsyncAPIState {
asyncapi?: AsyncAPIDocumentInterface;
error?: ErrorObject;
loading: boolean;
}

class AsyncApiComponent extends Component<AsyncApiProps, AsyncAPIState> {
state: AsyncAPIState = {
asyncapi: undefined,
error: undefined,
loading: true,
};

async componentDidMount() {
if (this.props.schema) {
const { schema, config } = this.props;
await this.parseSchema(schema, config?.parserOptions);
this.setState({ loading: false });
}
}

Expand All @@ -39,14 +41,31 @@ class AsyncApiComponent extends Component<AsyncApiProps, AsyncAPIState> {
const newSchema = this.props.schema;

if (oldSchema !== newSchema) {
this.setState({ loading: true });
const { config } = this.props;
await this.parseSchema(newSchema, config?.parserOptions);
this.setState({ loading: false });
}
}

render() {
const { schema, config } = this.props;
const { asyncapi, error } = this.state;
const { asyncapi, error, loading } = this.state;

if (loading) {
return (
<div style={{ height: '100%' }} className="aui-root">
<div className="flex items-center justify-center h-full w-full">
<div className="w-full max-w-sm">
<AsyncapiLogo />
<div className="loading-bar">
<div className="loading-moving-bar"></div>
</div>
</div>
</div>
</div>
);
}

return (
<AsyncApiStandalone
Expand Down
38 changes: 37 additions & 1 deletion library/src/styles/default.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
@apply lg:relative lg:block lg:w-64 lg:h-auto;
}

.container\:xl .sidebar--wrapper{
.container\:xl .sidebar--wrapper {
@apply xl:w-full;
@apply sm:w-full;
}
Expand Down Expand Up @@ -74,3 +74,39 @@
overflow-wrap: anywhere;
}
}


.loading-bar {
width: 130px;
height: 5px;
margin: 0 auto;
border-radius: 2px;
background-color: #fff;
position: relative;
overflow: hidden;
z-index: 1;
transform: rotateY(0);
transition: transform .3s ease-in
}
.loading-moving-bar {
height: 100%;
width: 68px;
position: absolute;
transform: translate(-34px);
background-color: #4299e1; /* corresponds to bg-blue-500 */
border-radius: 2px;
animation: initial-loading 1.5s ease infinite
}
@keyframes initial-loading {
0% {
transform: translate(-34px)
}

50% {
transform: translate(96px)
}

to {
transform: translate(-34px)
}
}