Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update docs related to styles #62

Merged
merged 9 commits into from
Sep 11, 2019
Merged
Show file tree
Hide file tree
Changes from 5 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
Binary file added .github/assets/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 30 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
# AsyncAPI React Component
<h5 align="center">
<br>
<a href="https://www.asyncapi.org"><img src="./.github/assets/logo.png" alt="AsyncAPI logo" width="200"></a>
<br>
React Component
</h5>
<h4 align="center">A React component for AsyncAPI specification</h4>

---

> :warning: This package doesn't support AsyncAPI 1.x anymore. We recommend to upgrade to the latest AsyncAPI version using the [AsyncAPI converter](https://github.com/asyncapi/converter). If you need to convert documents on the fly, you may use the [Node.js](https://github.com/asyncapi/converter) or [Go](https://github.com/asyncapi/converter-go) converters.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe add that npm package up to some version supports v1? and after that only v2

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can make something like a v1 branch with old code before migration

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aerfio We can create tag for appropriate revision, so this will be easy.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

imho this is not a big deal therefore separate warning exposed like that doesn't make much sense to me.
after overview we should just have a section called like supported versions and explain that this component supports 2.0, that people should convert and that is it,
mentioning old version of the component doesn't make much sense as we will not maintain it anyway

>
> However, if you have to use 1.x version use command `npm install --save @kyma-project/asyncapi-react@0.2.0`

---

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

Expand All @@ -12,11 +26,13 @@ This repository comes in with a [Playground application](https://www.asyncapi.co

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

## Usage
## Prerequisites

> **NOTE:** Use React version 16.0.0 or higher and styled-components version 4.0.0 or higher.
- [`react`](https://github.com/facebook/react/): >= 16.8.0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- [`react`](https://github.com/facebook/react/): >= 16.8.0
- [`react`](https://github.com/facebook/react/) (version 16.8.0 or higher)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this is how we write it in other docs


Run this command to install the component:
## Usage

Run this command to install the component in your project:

```sh
npm install --save @kyma-project/asyncapi-react
Expand All @@ -34,19 +50,23 @@ The list of props for the AsyncApi React component includes:

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).

- **theme?: Partial<ThemeInterface\>**

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.

> **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)

- **config?: Partial<ConfigInterface\>**

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.
This property is concatenated with the [default configuration](./library/src/config/default.ts).

> **NOTE:** The `Partial<T>` type means that every field in the `T` type is optional.

### Styles

To use default styles based on [SAP Fundamentals](https://sap.github.io/fundamental/), import them as follows:

``` js
import "@kyma-project/asyncapi-react/lib/styles/fiori.css";
```

For information on how to change styles, read the [Style Modification](./docs/configuration/style-modification.md) document.

## Development

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).
Expand Down
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
This directory contains the following documents that relate to the project:

- configuration:
- [Theme Modification](./configuration/theme-modification.md) describes how to edit a theme of the whole AsyncAPI component or of its specific part.
- [Style Modification](./configuration/style-modification.md) describes how to edit the styles of the AsyncApi component.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- [Style Modification](./configuration/style-modification.md) describes how to edit the styles of the AsyncApi component.
- [Style Modification](./configuration/style-modification.md) describes how to edit the styles of the AsyncAPI component.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here and everywhere I guess, I noticed now that it is written in lowercase in some places

- [Configuration Modification](./configuration/config-modification.md) describes the available component configuration options.
- development:
- [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.
Expand Down
71 changes: 43 additions & 28 deletions docs/configuration/config-modification.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,37 @@ Learn how to use various configuration options available in `ConfigInterface`.

## Definition

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

```ts
interface ConfigInterface {
show?: {
info?: boolean;
security?: boolean;
servers?: boolean;
channels?: boolean;
servers?: boolean;
messages?: boolean;
schemas?: boolean;
};
disableDefaultTheme?: boolean;
expand?: {
channels?: {
root?: boolean;
elements?: boolean;
};
servers?: {
root?: boolean;
elements?: boolean;
};
messages?: {
root?: boolean;
elements?: boolean;
};
schemas?: {
root?: boolean;
elements?: boolean;
};
},
showErrors?: boolean;
parserOptions?: ParserOptions;
}
```

Expand All @@ -28,61 +45,61 @@ interface ConfigInterface {
This field contains configuration responsible for rendering specific parts of the AsyncApi component.
All fields are set to `true` by default.

- **disableDefaultTheme?: boolean**
- **expand?: Partial<ExpandConfig>**

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.
This field is set to `false` by default.

> **NOTE:** When you set this flag to `true`, you must provide definitions of all styles.
This field contains configuration responsible for initial expanding specific parts of the AsyncApi component.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
This field contains configuration responsible for initial expanding specific parts of the AsyncApi component.
This field contains configuration responsible for expanding specific parts of the AsyncApi component automatically.

`root` means root component for specific parts of the AsyncApi component. `Elements` means elements inside `root` component.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
`root` means root component for specific parts of the AsyncApi component. `Elements` means elements inside `root` component.
`root` refers to a root component for specific parts of the AsyncAPI component, and `Elements` refers to elements inside the `root` component.

By default `expand.channels.root` is set to `true`.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
By default `expand.channels.root` is set to `true`.
By default, `expand.channels.root` is set to `true`.


- **showErrors?: boolean**

This field turns on or off the option displaying validation or parsing errors that show at the top of the component.
This field is set to `false` by default.
This field is set to `true` by default.

- **parserOptions?: ParserOptions**

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).
This field is set to `null` by default.

## Examples

See exemplary component configuration in JavaScript and TypeScript.
See exemplary component configuration in TypeScript and JavaScript.

### JavaScript
### TypeScript

```jsx
```tsx
import * as React from "react";
import { render } from "react-dom";
import AsyncApiComponent from "asyncapi-react";
import AsyncApiComponent, { ConfigInterface } from "asyncapi-react";

import { schema } from "./mock";

const config = {
const config: Partial<ConfigInterface> = {
show: {
security: false,
schemas: false
},
disableDefaultTheme: true,
showErrors: true
showErrors: false
};

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

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

### TypeScript
### JavaScript
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know we love TS, but pure JS example should be first, as it was before 😢

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope :P


```tsx
```jsx
import * as React from "react";
import { render } from "react-dom";
import AsyncApiComponent, { ConfigInterface } from "asyncapi-react";
import AsyncApiComponent from "asyncapi-react";

import { schema } from "./mock";

const config: Partial<ConfigInterface> = {
const config = {
show: {
security: false,
schemas: false
},
disableDefaultTheme: true,
showErrors: true
showErrors: false
};

const App = () => <AsyncApiComponent schema={schema} config={config} />;
Expand All @@ -96,13 +113,11 @@ In the above examples, after concatenation with the default configuration, the r
{
show: {
info: true,
security: false,
servers: true,
channels: true,
messages: true,
schemas: false
},
disableDefaultTheme: true,
showErrors: true
showErrors: false
}
```
16 changes: 16 additions & 0 deletions docs/configuration/style-modification.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Style Modification

## Overview

This document describes how you can apply the styles for the AsyncApi component.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
This document describes how you can apply the styles for the AsyncApi component.
This document describes how you can apply the styles for the AsyncAPI component.


## Changing styles

In the AsyncApi component we use pure css styling. Each component inside root component has a unique css class. Each class has form: `asyncapi__{ELEMENT}--{MODIFIER}`, where:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe each html tag has unique css class? from css perspective there are html tags/elements, not components

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
In the AsyncApi component we use pure css styling. Each component inside root component has a unique css class. Each class has form: `asyncapi__{ELEMENT}--{MODIFIER}`, where:
In the AsyncApi component, we use pure CSS styling. Each HTML tag inside the root component has a unique CSS class in the `asyncapi__{ELEMENT}--{MODIFIER}` format, where:


- `{ELEMENT}` - is a name of 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 `header` HTML element of `channel` element.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is located in `header` HTML element - is this always true? This may lead to situation in which someone does something like header.asyncapi__channel-header-title {}, but in reality there could be div element. Maybe instead of outlining things like that just say we follow BEM and link to it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But here I described that title is in header, not *-title is HTML header.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- `{ELEMENT}` - is a name of 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 `header` HTML element of `channel` element.
- `{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.

- `{MODIFIER}` - is a modifier for `{ELEMENT}`. Very few elements have a modifier. This is usually badge, button and similar, generic components.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
- `{MODIFIER}` - is a modifier for `{ELEMENT}`. Very few elements have a modifier. This is usually badge, button and similar, generic components.
- `{MODIFIER}` is a modifier for `{ELEMENT}`. Very few elements have a modifier. This is usually a badge, button, or similar, generic components.


For changing styles, you must create (or if you use [default](../../library/src/styles/fiori.css) style, modify) appropriate class.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
For changing styles, you must create (or if you use [default](../../library/src/styles/fiori.css) style, modify) appropriate class.
To change styles, create an appropriate class or modify it if you use the [default](../../library/src/styles/fiori.css) style.


> **NOTE**: We recommend copy default styles from [here](../../library/src/styles/fiori.css) and changing them at its sole discretion.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

copying

and did you really mean discretion?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
> **NOTE**: We recommend copy default styles from [here](../../library/src/styles/fiori.css) and changing them at its sole discretion.
> **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.

116 changes: 0 additions & 116 deletions docs/configuration/theme-modification.md

This file was deleted.

19 changes: 5 additions & 14 deletions docs/development/guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,18 +11,18 @@ Read the document to find out how to install dependencies, launch the developmen
This repository has the following structure:

<!-- markdownlint-disable MD040 -->
<!-- remember to update docs after removing styled components, like `theme` folder here -->

```
├── .github # Pull request and issue templates
├── docs # Directory with project-related documents
├── library # Source code of the AsyncApi React component
│ ├── src # Source code of the AsyncApi React component
│ │ ├── components # Source code of generic components used in the "containers" directory
│ │ ├── components # Source code of shared components used in the "containers" directory
│ │ ├── config # Configuration of the AsyncApi React component
│ │ ├── containers # Subcomponents for specific parts of the AsyncApi React component
│ │ ├── helpers # Various helper functions
│ │ └── theme # Theme-related files for the AsyncApi React component
│ │ ├── store # Global store of the AsyncApi React component
│ │ └── styles # Style-related files for the AsyncApi React component
│ └── test # Tests for the AsyncApi React component
└── playground # Source code of the Playground application for the AsyncApi React component
├── public # Fonts, images, and icons used in the Playground application
Expand All @@ -39,9 +39,8 @@ If you make any changes in the project structure, remember to update it.

Use the following tools to develop the AsyncApi React component:
Copy link
Contributor

@aerfio aerfio Sep 11, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've never liked this section, because it's not like we somehow use react or TS cli to develop directly, they are dependencies and are downloaded automatically, I'm not bringing them myself, it's misleading

to be discussed with @kazydek and @magicmatatjahu

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not insisting on keeping it if you think it is more of a hassle than help 🤷‍♀


- React (version 16.8.0 or higher)
- [Styled-components](https://github.com/styled-components/styled-components) (version 4.0.0 or higher)
- TypeScript (version 3.5.0 or higher)
- [`react`](https://github.com/facebook/react/) (version 16.8.0 or higher)
- [`typescript`](https://github.com/microsoft/TypeScript) (version 3.5.0 or higher)

## Install dependencies

Expand Down Expand Up @@ -76,14 +75,6 @@ To launch tests for the [`library`](../../library) package, run this command:
npm test
```

If you only want to run tests for a specific part of the repository, use:

```sh
npm run test:{PART}
```

In this command `{PART}` must be either `playground` or `library`.

## Naming and architecture convention

See the rules for naming functions and components, and the architecture convention to use in the `playground` and `library` projects:
Expand Down
Loading