Skip to content

Commit

Permalink
docs: remove flow types references
Browse files Browse the repository at this point in the history
  • Loading branch information
DSil committed Jan 4, 2024
1 parent 7f7dfc2 commit 10938b2
Show file tree
Hide file tree
Showing 14 changed files with 42 additions and 52 deletions.
1 change: 0 additions & 1 deletion .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ This is a monorepo containing a few Orbit packages:

#### Root

- `/flow-typed` – Flow library definitions
- `/scripts` – Scripts for development and publishing

### How to develop
Expand Down
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@

- [ ] Tests have been added/adjusted for my new feature
- [ ] New Components are registered in index.js of my project
- [ ] New Components have both `.flow` and `d.ts` files and are exported in `index.js.flow` and `index.d.ts`
- [ ] New Components have `d.ts` files and are exported in `index.d.ts`
35 changes: 15 additions & 20 deletions .github/contribution/component-design.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ Structure of the directory where the necessary files for a Component are located

<pre>
<strong>├─ _tests_</strong>
<strong> └── index.test.js</strong> ........... Component's tests
<strong>├─ index.js</strong> .................... Component's logic
<strong>├─ index.js.flow</strong> ............... Component's types
<strong>├─ Component.stories.js</strong> ........ Component's Storybook
<strong>├─ consts.js</strong> ................... Component's constants
<strong> └── index.test.tsx</strong> ........... Component's tests
<strong>├─ index.tsx</strong> ................... Component's logic and rendering
<strong>├─ index.d.ts</strong> .................. Component's types
<strong>├─ Component.stories.tsx</strong> ....... Component's Storybook
<strong>├─ consts.ts</strong> ................... Component's constants
<strong>└─ README.md</strong> ................... Component's documentation
</pre>

Expand Down Expand Up @@ -40,7 +40,7 @@ StyledComponent.defaultProps = {

### Render

Set up `defaultProps` by assigning default values to the props. Destructurize them and finally return the Component.
Set up `defaultProps` by assigning default values to the props. Destructure them and finally return the Component.

```jsx
const Component = (props: Props) => {
Expand All @@ -49,31 +49,26 @@ const Component = (props: Props) => {
};
```

## Component Flow typing
## Component types

For static typing we use [Flow](https://flow.org/en/docs/react/). Always create `index.js.flow` file, where the declaration of types is stored. We use `strict` and `read-only` types to be more strict in setting up values of the props, `optional` types are used only when the purpose of the prop is really optional.
For component typing we use [Typescript](https://www.typescriptlang.org/). Always create `index.d.ts` file, where the declaration of types is stored. We use `readonly` types to be more strict in setting up values of the props. When the purpose of the prop is really optional, its type should me marked as optional (`?`).

Every component should have `dataTest` prop. For this cases, we are using `globals` flow type.
Every component should accept `dataTest` and `id` props. For this, we extend the `Globals` type.

```jsx
// @flow
import type { Globals } from "../common/common.js.flow";

export type Props = {|
+size?: "small" | "medium" | "large",
+children: React$Node,
...Globals,
|};
```ts
import type * as Common from "../common/types";

declare export default React$ComponentType<Props>;
export interface Props extends Common.Globals {
readonly size?: "small" | "medium" | "large";
readonly children: React.ReactNode;
}
```

## Component constants

We use constants for props that have options. In this way, we can easily maintain consistency. Just export your options as objects with `uppercase`.

```jsx
// @flow
export const SIZE_OPTIONS = {
SMALL: "small",
MEDIUM: "medium",
Expand Down
6 changes: 3 additions & 3 deletions .github/contribution/icons.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@ Orbit icons are one of the most essential parts of the Orbit Design system.

## Usage

The implementation API for icons is described [here](https://github.com/kiwicom/orbit-components/blob/master/src/Icon/README.md).
View the list of icons [here](https://kiwicom.github.io/orbit-components/?selectedKind=Icon&selectedStory=List%20of%20all%20icons).
The implementation API for icons is described [here](https://github.com/kiwicom/orbit/blob/master/packages/orbit-components/src/Icon/README.md).
View the list of icons [here](https://kiwicom.github.io/orbit/?path=/story/icon--list-of-all-icons).

## Adding a new icon

If you want to add or update an icon, insert your `SVG` file into `src/icons/svg` directory and run `yarn build` and then `yarn test -u` to be sure that all your snapshots are updated. Then commit and push changes into a new branch.

## Build process

In the `svg` folder, there are source SVG files as delivered by our designers. The build script `config/build.js` is executed when you run `yarn build`. It processes, optimizes and transforms all of them into React JS components. This script also generates flow typing for all icons. These JS files are then compiled with Babel and copied to the `lib` folder.
In the `svg` folder, there are source SVG files as delivered by our designers. The build script `config/build.js` is executed when you run `yarn build`. It processes, optimizes and transforms all of them into React JS components. This script also generates types for all icons. These JS files are then compiled with Babel and copied to the `lib` folder.
2 changes: 0 additions & 2 deletions docs/plugins/gatsby-remark-figma-images/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// @noflow

const visit = require("unist-util-visit");
const path = require("path");
const fs = require("fs");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,9 @@ For a live preview, check out our [Storybook](https://kiwicom.github.io/orbit/)

You can also try `orbit-components` live on [CodeSandbox](https://codesandbox.io/s/github/designkiwicom/orbit-sandbox).

## Types
## Typescript

Orbit comes with both Flow and Typescript definition files, so you can choose what fits your project.
Orbit comes with Typescript definition files.
If you're working with Typescript, you need to add a type for `styled-components`.

```shell
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Using component types
description: Guidelines on how to use and make the most out of exported component types in Typescript and Flow.
description: Guidelines on how to use and make the most out of exported component types in Typescript.
redirect_from:
- /guides/using-component-types/
---
Expand Down Expand Up @@ -49,22 +49,3 @@ const WrappedText = ({ children, type }) => <Text type={type}>{children}</Text>;

export default WrappedText;
```

## Flow

In `Flow`,
you can access the fields using [`$PropertyType`](https://flow.org/en/docs/types/utilities/#toc-propertytype),
so the example would be fixed as follows:

```jsx
import Text from "@kiwicom/orbit-components/lib/Text";
import type { Props as TextProps } from "@kiwicom/orbit-components/lib/Text";

type Props = {|
type: $PropertyType<TextProps, "type">,
|};

const WrappedText = ({ children, type }) => <Text type={type}>{children}</Text>;

export default WrappedText;
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
title: v12
description: How to migrate to Orbit 12.0.0
redirect_from:
- /migration-guides/v12/
---

# Orbit Migration Guide v12

This migration guide focuses on the process of migrating from Orbit v11 to v12.0, as some breaking changes were introduced.
With this guide, we aim to walk through all the breaking changes and how they can be addressed, allowing the migration to be smoother and effortlessly.

## Breaking changes

### Flow types removed

Flow types were deprecated in Orbit 9.0.0 and are now removed. Typescript is now the only supported type system in Orbit.
1 change: 0 additions & 1 deletion docs/src/hooks/useCopyToClipboard.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// @flow
import { useEffect, useState, useCallback } from "react";
import copy from "copy-to-clipboard";

Expand Down
5 changes: 3 additions & 2 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,10 @@ For live preview check out [Storybook](https://kiwicom.github.io/orbit/) or [orb

You can also try `orbit-components` live on [CodeSandbox](https://codesandbox.io/s/github/designkiwicom/orbit-sandbox).

## Types
## Typescript

Orbit comes with both Flow and Typescript definitions files, so you can choose what fits your project. However, if you work with Typescript, you need to add type for `styled-components`.
Orbit comes with Typescript definitions files.
If you work with Typescript, you need to add type for `styled-components`.

```
// with npm
Expand Down

0 comments on commit 10938b2

Please sign in to comment.