import { Meta, Preview, Story } from "@storybook/addon-docs/blocks";
import { Flex } from "../Flex";
import { Text } from "../Text";
import { Loading } from "./Loading";

<Meta title="Components/Feedback/Loading" component={Loading} />

export const ExampleContainer = ({ ...props }) => (
  <div className="h-64" {...props} />
);

# Loading

Loading provides a loading animation.

```jsx
import { Loading } from "@aptible/arrow-ds";
```

<Preview>
  <Story name="Loading">
    <Loading />
  </Story>
</Preview>

## Custom Props

There are no custom props for this component. The props extend
[`BoxProps`](/?path=/docs/components-box--box#all-props).

## Demos

### Centering the loader

This example shows how you can center the loader in both directions within a
larger container using flexbox.

<Preview>
  <Story name="Loading centering demo with flexbox">
    <ExampleContainer>
      <Flex className="w-full h-full items-center justify-center">
        <Loading />
      </Flex>
    </ExampleContainer>
  </Story>
</Preview>

If you don’t need to center the loading component vertically, you can use margin
to center it horizontally.

<Preview>
  <Story name="Loading centering demo">
    <ExampleContainer>
      <Loading className="mx-auto" />
    </ExampleContainer>
  </Story>
</Preview>

### Loading with text

This example shows how you can add text above the loader while centering both.

<Preview>
  <Story name="Loading with text">
    <ExampleContainer>
      <Flex className="w-full h-full items-center justify-center flex-col">
        <Text className="text-h3 font-medium mb-4">
          Creating 8 SaaS Systems…
        </Text>
        <Loading />
      </Flex>
    </ExampleContainer>
  </Story>
</Preview>

### On a dark background

This example shows how you can change the color of the loader when using on a
dark background.

<Preview>
  <Story name="Loading on a dark background">
    <ExampleContainer>
      <Flex className="w-full h-full items-center justify-center flex-col bg-gray-900">
        <Loading className="text-brandGreen-400" />
      </Flex>
    </ExampleContainer>
  </Story>
</Preview>
