Skip to content

Commit 96dfcef

Browse files
Update docs related to styles (#62)
1 parent d30099f commit 96dfcef

File tree

18 files changed

+165
-240
lines changed

18 files changed

+165
-240
lines changed

.github/assets/logo.png

5.46 KB
Loading

README.md

Lines changed: 40 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,33 @@
1-
# AsyncAPI React Component
1+
<h5 align="center">
2+
<img src="./.github/assets/logo.png" alt="AsyncAPI logo" width="200">
3+
<br>
4+
React Component
5+
</h5>
6+
<h4 align="center">A official React component for AsyncAPI 2.0 specification</h4>
7+
8+
---
29

310
[![All Contributors](https://img.shields.io/badge/all_contributors-5-orange.svg?style=flat-square)](#contributors)
411

512
## Overview
613

7-
A [React](https://reactjs.org/) component for AsyncAPI specification. It allows you to render the documentation of your asynchronous API provided in the AsyncAPI specification format and validate this specification. You can fully restyle the component using your own styles.
14+
A official [React](https://reactjs.org/) component for AsyncAPI 2.0 specification. It allows you to render the documentation of your asynchronous API provided in the AsyncAPI specification format and validate this specification. You can fully restyle the component using your own styles.
15+
16+
> **CAUTION**: This package only supports AsyncAPI 2.0 specification. If you use 1.x, we recommend that you upgrade to the latest AsyncAPI version using the [Node.js](https://github.com/asyncapi/converter) or [Go](https://github.com/asyncapi/converter-go) converters.
817
918
## Playground
1019

1120
This repository comes in with a [Playground application](https://www.asyncapi.com/asyncapi-react/). Test it to see the component in action and play with it before you use it in your application.
1221

1322
You can also run the Playground application locally by following [this](./docs/development/guide.md#install-dependencies) instruction from the development guide.
1423

15-
## Usage
24+
## Prerequisites
1625

17-
> **NOTE:** Use React version 16.0.0 or higher and styled-components version 4.0.0 or higher.
26+
- [`react`](https://github.com/facebook/react/) (version 16.8.0 or higher)
27+
28+
## Usage
1829

19-
Run this command to install the component:
30+
Run this command to install the component in your project:
2031

2132
```sh
2233
npm install --save @kyma-project/asyncapi-react
@@ -28,25 +39,29 @@ Check out this simple sandbox application that uses the asyncapi-react component
2839

2940
### Props
3041

31-
The list of props for the AsyncApi React component includes:
42+
The list of props for the AsyncAPI React component includes:
3243

3344
- **schema: string | AsyncApiInterface | FetchingSchemaInterface**
3445

3546
The `schema` property is required and contains AsyncAPI specification. Use the `string` type, the [`AsyncApiInterface`](./library/src/types.ts#L13) type, or the [`FetchingSchemaInterface`](./library/src/helpers/fetchSchema.ts#L1) object to fetch the schema from an external resource. For more information on what it contains and what it should look like, read [AsyncAPI Specification](https://github.com/asyncapi/asyncapi#asyncapi-specification).
3647

37-
- **theme?: Partial<ThemeInterface\>**
38-
39-
The `theme` property is optional and contains styles for specific parts of the AsyncApi component. For information on how to change styles, read the [Theme Modification](./docs/configuration/theme-modification.md) document.
40-
41-
> **NOTE:** If you do not pass the [**disableDefaultTheme**](./docs/configuration/config-modification.md) config as `true`, this property is concatenated with the [default theme](./library/src/theme/default.ts)
42-
4348
- **config?: Partial<ConfigInterface\>**
4449

45-
The `config` property is optional and contains configuration for the AsyncApi component. For more information on the available configuration options, read the [Configuration Modification](./docs/configuration/config-modification.md) document.
50+
The `config` property is optional and contains configuration for the AsyncAPI component. For more information on the available configuration options, read the [Configuration Modification](./docs/configuration/config-modification.md) document.
4651
This property is concatenated with the [default configuration](./library/src/config/default.ts).
4752

4853
> **NOTE:** The `Partial<T>` type means that every field in the `T` type is optional.
4954
55+
### Styles
56+
57+
To use default styles based on [SAP Fundamentals](https://sap.github.io/fundamental/), import them as follows:
58+
59+
``` js
60+
import "@kyma-project/asyncapi-react/lib/styles/fiori.css";
61+
```
62+
63+
For information on how to change styles, read the [Style Modification](./docs/configuration/style-modification.md) document.
64+
5065
## Development
5166

5267
For information on how to set up a development environment, write and run tests, follow the naming and architecture convention defined for the project in the [Development Guide](./docs/development/guide.md).
@@ -62,6 +77,18 @@ If you create a feature request, use the dedicated **Feature request** issue tem
6277

6378
If you have a bug to report, reproduce it in an online code editor. For example, use [CodeSandbox](https://codesandbox.io/). Attach the link to the reproduced bug to your issue. Log the bug using the **Bug report** template.
6479

80+
## Missing features
81+
82+
See the list of features that are still missing in the component:
83+
84+
- [ ] render [`bindings`](https://github.com/asyncapi/asyncapi/blob/master/versions/next/asyncapi.md#fixed-fields-19)
85+
- [ ] render [`tags`](https://github.com/asyncapi/asyncapi/blob/master/versions/next/asyncapi.md#tagsObject)
86+
- [ ] render [`externalDocs`](https://github.com/asyncapi/asyncapi/blob/master/versions/next/asyncapi.md#externalDocumentationObject)
87+
- [ ] render [`schema properties`](https://github.com/asyncapi/asyncapi/blob/master/versions/next/asyncapi.md#properties)
88+
- [ ] render [`correlationID`](https://github.com/asyncapi/asyncapi/blob/master/versions/next/asyncapi.md#correlationIdObject)
89+
90+
If you want to help us develop them, feel free to contribute.
91+
6592
## Credits
6693

6794
<p align="center">

docs/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
This directory contains the following documents that relate to the project:
66

77
- configuration:
8-
- [Theme Modification](./configuration/theme-modification.md) describes how to edit a theme of the whole AsyncAPI component or of its specific part.
8+
- [Style Modification](./configuration/style-modification.md) describes how to edit the styles of the AsyncAPI component.
99
- [Configuration Modification](./configuration/config-modification.md) describes the available component configuration options.
1010
- development:
1111
- [Development Guide](./development/guide.md) describes how to set up a development environment, write, and run tests. It also contains the naming and architecture convention.

docs/configuration/config-modification.md

Lines changed: 44 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -6,83 +6,100 @@ Learn how to use various configuration options available in `ConfigInterface`.
66

77
## Definition
88

9-
See the definition of the object that you must pass to probs to modify the component configuration:
9+
See the definition of the object that you must pass to props to modify the component configuration:
1010

1111
```ts
1212
interface ConfigInterface {
1313
show?: {
1414
info?: boolean;
15-
security?: boolean;
16-
servers?: boolean;
1715
channels?: boolean;
16+
servers?: boolean;
1817
messages?: boolean;
1918
schemas?: boolean;
2019
};
21-
disableDefaultTheme?: boolean;
20+
expand?: {
21+
channels?: {
22+
root?: boolean;
23+
elements?: boolean;
24+
};
25+
servers?: {
26+
root?: boolean;
27+
elements?: boolean;
28+
};
29+
messages?: {
30+
root?: boolean;
31+
elements?: boolean;
32+
};
33+
schemas?: {
34+
root?: boolean;
35+
elements?: boolean;
36+
};
37+
},
2238
showErrors?: boolean;
39+
parserOptions?: ParserOptions;
2340
}
2441
```
2542

2643
- **show?: Partial<ShowConfig>**
2744

28-
This field contains configuration responsible for rendering specific parts of the AsyncApi component.
45+
This field contains configuration responsible for rendering specific parts of the AsyncAPI component.
2946
All fields are set to `true` by default.
3047

31-
- **disableDefaultTheme?: boolean**
48+
- **expand?: Partial<ExpandConfig>**
3249

33-
This field informs whether the forwarded [`ThemeInterface`](../../library/src/theme/theme.ts#L5) should be concatenated with the [default theme](../../library/src/theme/default.ts) or if the AsyncApi component should consider only the forwarded one.
34-
This field is set to `false` by default.
35-
36-
> **NOTE:** When you set this flag to `true`, you must provide definitions of all styles.
50+
This field contains configuration responsible for expanding specific parts of the AsyncAPI component automatically.
51+
`root` refers to a root component for specific parts of the AsyncAPI component, and `elements` refers to elements inside the `root` component.
52+
By default, `expand.channels.root` is set to `true`.
3753

3854
- **showErrors?: boolean**
3955

4056
This field turns on or off the option displaying validation or parsing errors that show at the top of the component.
41-
This field is set to `false` by default.
57+
This field is set to `true` by default.
58+
59+
- **parserOptions?: ParserOptions**
60+
61+
This field contains configuration for [`asyncapi-parser`](https://github.com/asyncapi/parser). See available options [here](https://github.com/asyncapi/parser-js/blob/master/API.md#parser).
62+
This field is set to `null` by default.
4263

4364
## Examples
4465

45-
See exemplary component configuration in JavaScript and TypeScript.
66+
See exemplary component configuration in TypeScript and JavaScript.
4667

47-
### JavaScript
68+
### TypeScript
4869

49-
```jsx
70+
```tsx
5071
import * as React from "react";
5172
import { render } from "react-dom";
52-
import AsyncApiComponent from "asyncapi-react";
73+
import AsyncApiComponent, { ConfigInterface } from "asyncapi-react";
5374

5475
import { schema } from "./mock";
5576

56-
const config = {
77+
const config: Partial<ConfigInterface> = {
5778
show: {
58-
security: false,
5979
schemas: false
6080
},
61-
disableDefaultTheme: true,
62-
showErrors: true
81+
showErrors: false
6382
};
6483

6584
const App = () => <AsyncApiComponent schema={schema} config={config} />;
6685

6786
render(<App />, document.getElementById("root"));
6887
```
6988

70-
### TypeScript
89+
### JavaScript
7190

72-
```tsx
91+
```jsx
7392
import * as React from "react";
7493
import { render } from "react-dom";
75-
import AsyncApiComponent, { ConfigInterface } from "asyncapi-react";
94+
import AsyncApiComponent from "asyncapi-react";
7695

7796
import { schema } from "./mock";
7897

79-
const config: Partial<ConfigInterface> = {
98+
const config = {
8099
show: {
81-
security: false,
82100
schemas: false
83101
},
84-
disableDefaultTheme: true,
85-
showErrors: true
102+
showErrors: false
86103
};
87104

88105
const App = () => <AsyncApiComponent schema={schema} config={config} />;
@@ -96,13 +113,11 @@ In the above examples, after concatenation with the default configuration, the r
96113
{
97114
show: {
98115
info: true,
99-
security: false,
100116
servers: true,
101117
channels: true,
102118
messages: true,
103119
schemas: false
104120
},
105-
disableDefaultTheme: true,
106-
showErrors: true
121+
showErrors: false
107122
}
108123
```
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Style Modification
2+
3+
## Overview
4+
5+
This document describes how you can apply the styles for the AsyncAPI component.
6+
7+
## Changing styles
8+
9+
In the AsyncApi component, we use pure CSS styling and [`BEM`](http://getbem.com/) methodology. Each HTML tag inside the root component has a unique CSS class in the `asyncapi__{ELEMENT}--{MODIFIER}` format, where:
10+
11+
- `{ELEMENT}` is the name of a specific element. Each element name is the concatenation of the names of the elements in which it is located. For example, `asyncapi__channel-header-title` is located in the `header` HTML element of the `channel` element.
12+
- `{MODIFIER}` is a modifier for `{ELEMENT}`. Very few elements have a modifier. This is usually a badge, button, or similar, generic components.
13+
14+
To change styles, create an appropriate class or modify it if you use the [default](../../library/src/styles/fiori.css) style.
15+
16+
> **NOTE**: We recommend that you first [copy](../../library/src/styles/fiori.css) the default styles to a separate file and then modify them as you prefer.

docs/configuration/theme-modification.md

Lines changed: 0 additions & 116 deletions
This file was deleted.

0 commit comments

Comments
 (0)