import { Meta, Story, Preview, Source } from '@storybook/addon-docs/blocks';
import { View, Text, theme } from '@tedconf/monterey';
import { select, text } from '@storybook/addon-knobs';

<Meta title="Primitives|Text" component={Text} />

# Text

The `<Text />` primitive should be treated as a dumb building block. by default
it renders as a `span`. It should be wrapped with whichever semantic attributes
necessary - they neednt be applied directly to it, but you can use whichever
tag you want via the `as` prop. `<Text />` should be your new default wrapping
element for any text content. You should _only ever_ use this component and its
variants to style text.

## Import the Text

<Source
  code={`
import { Text } from '@tedconf/monterey';
`}
/>

## Use the text

Pick the appropriate variant for your situation.

### Default

<Story name="kitchen sink">
  <Text
    variant={select(
      'variant',
      [
        '-1m',
        '-1r',
        '-1u',
        '1rserif',
        '1r',
        '1b',
        '2r',
        '2b',
        '3r',
        '3b',
        '3serif',
        '4b',
        '5',
        '5b',
        '6',
        '7',
      ],
      '1r',
    )}
    color={select(
      'color',
      Object.entries(theme.colors)
        .flatMap(([k, v]) => {
          if (typeof v === 'object') {
            return Object.entries(v).map(([l, val]) => ({
              name: `${k}.${l}`,
              value: val,
            }));
          }
          return {
            name: k,
            value: v,
          };
        })
        .reduce((acc, curr) => {
          acc[curr.name] = curr.value;
          return acc;
        }, {}),
      'black',
    )}
  >
    {text('children', 'Hello')}
  </Text>
</Story>

## Variants

Each text style is defined as a `variant`. you can gain access to them by specifying a `variant` prop on the text component, or from the `textVariants` named export.

<Preview>
  <Story name="Negative One Medium">
    <Text variant="-1m">Text: -1m.</Text>
  </Story>
</Preview>

<Preview>
  <Story name="Negative One Regular">
    <Text variant="-1r">Text: -1r.</Text>
  </Story>
</Preview>

<Preview>
  <Story name="Negative One Uppercase">
    <Text variant="-1u">Text: -1u.</Text>
  </Story>
</Preview>

<Preview>
  <Story name="One Regular Serif">
    <Text variant="1rserif">Text: 1rserif.</Text>
  </Story>
</Preview>

<Preview>
  <Story name="One Regular">
    <Text variant="1r">Text: 1r.</Text>
  </Story>
</Preview>

<Preview>
  <Story name="One bold">
    <Text variant="1b">Text: 1b.</Text>
  </Story>
</Preview>

<Preview>
  <Story name="Two regular">
    <Text variant="2r">Text: 2r.</Text>
  </Story>
</Preview>

<Preview>
  <Story name="Two bold">
    <Text variant="2b">Text: 2b.</Text>
  </Story>
</Preview>

<Preview>
  <Story name="Three Regular">
    <Text variant="3r">Text: 3r.</Text>
  </Story>
</Preview>

<Preview>
  <Story name="Three Bold">
    <Text variant="3b">Text: 3b.</Text>
  </Story>
</Preview>

<Preview>
  <Story name="Three Serif">
    <Text variant="3serif">Text: 3serif.</Text>
  </Story>
</Preview>

<Preview>
  <Story name="Four Bold">
    <Text variant="4b">Text: 4b.</Text>
  </Story>
</Preview>

<Preview>
  <Story name="Five">
    <Text variant="5">Text: 5.</Text>
  </Story>
</Preview>

<Preview>
  <Story name="Five Bold">
    <Text variant="5b">Text: 5b.</Text>
  </Story>
</Preview>

<Preview>
  <Story name="Six">
    <Text variant="6">Text: 6.</Text>
  </Story>
</Preview>

<Preview>
  <Story name="Seven">
    <Text variant="7">Text: 7.</Text>
  </Story>
</Preview>
