## Feature Examples

### Structure
- description: Notification is a compound component that consists of 3 child elements: - `<Notification.TextLabel/>` (required) - `<Notification.ActionButton/>` - `<Notification.CloseButton/>`
- example:
```jsx
<Notification show>
  <Notification.TextLabel>Label</Notification.TextLabel>
  <Notification.ActionButton>Action</Notification.ActionButton>
  <Notification.CloseButton />
</Notification>;
```

### Skin
- description: Control the appearance of the notification with the `skin` prop. It supports 5 skins: - `standard` (default) - provides users with relevant information and actions. - `error` - use it to inform the user about application error that needs immediate action. - `success` - use it when a task has been performed successfully. - `warning` - use it to warn the user about application status that might affect the usage, but doesn't block the user. - `premium` - use it for premium upgrades only — packages that let accept payments, connect domain and have business email. [Read more about Premium patterns](https://docs.google.com/document/d/1mALfPW9BOZgAjaFpvor5la3WGhGkXIxpbkF2GFrapU0/edit).
- example:
```jsx
<StorybookComponents.Stack flexDirection="column">
  <Notification skin="standard" show>
    <Notification.TextLabel>Standard</Notification.TextLabel>
  </Notification>
  <Notification skin="error" show>
    <Notification.TextLabel>Error</Notification.TextLabel>
  </Notification>
  <Notification skin="success" show>
    <Notification.TextLabel>Success</Notification.TextLabel>
  </Notification>
  <Notification skin="warning" show>
    <Notification.TextLabel>Warning</Notification.TextLabel>
  </Notification>
  <Notification skin="premium" show>
    <Notification.TextLabel>Premium</Notification.TextLabel>
  </Notification>
</StorybookComponents.Stack>;
```

### Action
- description: Add a call to action to a notification by passing `<Notification.ActionButton/>` as a child component. Change its appearance with `type` prop. It supports 2 values: - `button` - use it to prompt users to take an action in order to continue - `textLink` - use it to display optional actions, such as 'Learn more'
- example:
```jsx
<StorybookComponents.Stack flexDirection="column">
  <Notification show>
    <Notification.TextLabel>Label</Notification.TextLabel>
    <Notification.ActionButton>Button</Notification.ActionButton>
  </Notification>
  <Notification show>
    <Notification.TextLabel>Label</Notification.TextLabel>
    <Notification.ActionButton type="textLink">
      Text link
    </Notification.ActionButton>
  </Notification>
</StorybookComponents.Stack>;
```

### Text overflow
- description: By default notification label is limited to a single line of text. Full text is revealed in a tooltip on hover over. Allow text to wrap to multiple lines by setting `ellipsis` prop value to `false`.
- example:
```jsx
<StorybookComponents.Stack flexDirection="column">
  <Notification show>
    <Notification.TextLabel>
      This notification appears with extremely long text and it doesn't fit in a
      single line. It requires to enable ellipsis feature or wrap the text in
      multiple lines.
    </Notification.TextLabel>
  </Notification>
  <Notification show>
    <Notification.TextLabel ellipsis={false}>
      This notification appears with extremely long text and it doesn't fit in a
      single line. It requires to enable ellipsis feature or wrap the text in
      multiple lines.
    </Notification.TextLabel>
  </Notification>
</StorybookComponents.Stack>;
```

### Placement
- description: Specify how notification should be displayed using the `type` prop. It supports 3 types: - `global` (default) - takes up space and pushes the content down. On page scroll, it scrolls together with content. - `local` will not take up space and will be displayed on top of the content. On page scroll, it scrolls together with content. - `sticky` - will not take up space and will be displayed on top of the whole page. On page scroll, it keeps its position fixed at the top of a screen.
- example:
```jsx
() => {
  const [show, setShow] = React.useState(false);
  const [type, setType] = React.useState(undefined);
  return (
    <StorybookComponents.Stack flexDirection="column">
      <Notification type={type} show={show} autoHideTimeout={3000}>
        <Notification.TextLabel>Label</Notification.TextLabel>
      </Notification>
      <StorybookComponents.Stack>
        <Button
          onClick={() => {
            setShow(true);
            setType('global');
          }}
        >
          Display as global
        </Button>
        <Button
          onClick={() => {
            setShow(true);
            setType('local');
          }}
        >
          Display as local
        </Button>
        <Button
          onClick={() => {
            setShow(true);
            setType('sticky');
          }}
        >
          Display as sticky
        </Button>
      </StorybookComponents.Stack>
    </StorybookComponents.Stack>
  );
};
```

### Timeout
- description: Hide the notification after a specified amount of time with `autoHideTimeout` prop. Time is specified in milliseconds. When set it's recommended to keep it visible for at least for 7 seconds.
- example:
```jsx
() => {
  const [show, setShow] = React.useState(false);
  return (
    <StorybookComponents.Stack flexDirection="column">
      <Notification autoHideTimeout={3000} show={show}>
        <Notification.TextLabel>Label</Notification.TextLabel>
      </Notification>
      <StorybookComponents.Stack>
        <Button onClick={() => setShow(true)}>Display with timeout</Button>
      </StorybookComponents.Stack>
    </StorybookComponents.Stack>
  );
};
```

## Developer Examples

### Controlled display
- description: Control whether notification is visible or not with `show` prop.
- example:
```jsx
() => {
  const [show, setShow] = React.useState(false);

  return (
    <Layout>
      <Cell>
        <Button onClick={() => setShow(!show)}>Show / Hide Notification</Button>
      </Cell>
      <Cell>
        <Notification onClose={() => setShow(false)} skin="error" show={show}>
          <Notification.TextLabel ellipsis={false}>
            This notification appears with extremely long text and it doesn't
            fit in a single line. It requires to enable ellipsis feature or wrap
            the text in multiple lines.
          </Notification.TextLabel>
          <Notification.ActionButton onClick={() => console.log('Clicked!')}>
            button
          </Notification.ActionButton>
          <Notification.CloseButton />
        </Notification>
      </Cell>
      <Cell>
        <Text>
          The Life and Strange Surprizing Adventures of Robinson Crusoe, Of
          York, Mariner: Who lived Eight and Twenty Years, all alone in an
          un-inhabited Island on the Coast of America, near the Mouth of the
          Great River of Oroonoque; Having been cast on Shore by Shipwreck,
          wherein all the Men perished but himself. With An Account how he was
          at last as strangely deliver'd by Pyrates
        </Text>
      </Cell>
    </Layout>
  );
};
```

## Common Use Case Examples

### Application status
- description: Use notification to update users about the application status change after user's performed action. For example, "save" button clicked when a required field was left empty.
- example:
```jsx
<>
  <Notification show skin="error">
    <Notification.TextLabel>Name your plan to continue.</Notification.TextLabel>
  </Notification>
  <Page>
    <Page.Header
      actionsBar={
        <Box gap="SP2">
          <Button skin="inverted">Cancel</Button>
          <Button>Save</Button>
        </Box>
      }
      breadcrumbs={
        <Breadcrumbs
          activeId="2"
          items={[
            { id: '1', value: 'Pricing Plans' },
            { id: '2', value: 'Basic Plan' },
          ]}
          onClick={() => {}}
        />
      }
      showBackButton
      onBackClicked={() => {}}
      title="Basic Plan"
    />
    <Page.Content>
      <Layout>
        <Cell span={8}>
          <Layout>
            <Cell>
              <Card>
                <Card.Header title="Plan info" />
                <Card.Divider />
                <Card.Content>
                  <Layout>
                    <Cell span={8}>
                      <FormField
                        label="Plan name"
                        required
                        statusMessage="Give your plan a name"
                        status="error"
                      >
                        <Input placeholder="e.g., Silver membership" />
                      </FormField>
                    </Cell>
                    <Cell span={4} rows={2}>
                      <FormField label="Cover image">
                        <ImageViewer width="100%" />
                      </FormField>
                    </Cell>
                    <Cell span={8}>
                      <FormField label="Description">
                        <Input placeholder="e.g., Unlimited yoga classes" />
                      </FormField>
                    </Cell>
                  </Layout>
                </Card.Content>
              </Card>
            </Cell>
          </Layout>
        </Cell>
        <Cell span={4}>
          <Card hideOverflow>
            <Card.Header title="Plan Preview" />
            <StorybookComponents.Placeholder height="222px">
              Preview area
            </StorybookComponents.Placeholder>
          </Card>
        </Cell>
      </Layout>
    </Page.Content>
  </Page>
</>;
```
