PPolaris ComponentsConnect an agent

Overview

A usage overview card with impression quota and contact count tiles, built with Polaris Card, Grid, Box, Text, Tooltip and Icon.

Preview

Code

Example.jsx
import { BlockStack, Box, Card, Grid, Icon, InlineStack, Text, Tooltip } from '@shopify/polaris';
import { InfoIcon } from '@shopify/polaris-icons';

const FREE_IMPRESSIONS = 59;
const IMPRESSION_LIMIT = 100;
const CONTACTS = 0;

const IMPRESSION_TOOLTIP =
  'Number of times the app has successfully blocked invalid actions.';
const IMPRESSION_LIMIT_TOOLTIP =
  'All rules will be inactive once you reach the free impression limit.';
const CONTACT_TOOLTIP = 'Total number of contacts collected by the app.';

const LABEL_TRIGGER_STYLE = {
  appearance: 'none',
  border: 'none',
  background: 'none',
  padding: 0,
  margin: 0,
  display: 'inline',
  cursor: 'help',
  font: 'inherit',
  fontSize: 'var(--p-font-size-325, 0.8125rem)',
  lineHeight: 'var(--p-font-line-height-500, 1.25rem)',
  fontWeight: 'var(--p-font-weight-semibold, 650)',
  color: 'var(--p-color-text, #303030)',
  borderBottom: '0.0625rem dashed #8a8a8a',
};

const ICON_TRIGGER_STYLE = {
  display: 'inline-flex',
  cursor: 'help',
};

export const Example = () => (
  <Card>
    <BlockStack gap="200">
      <Text as="h3" variant="headingSm">
        Overview
      </Text>
      <Grid>
        <Grid.Cell columnSpan={{ xs: 6, sm: 3, md: 3, lg: 6, xl: 6 }}>
          <Box background="bg-fill-secondary" padding="300" borderRadius="200">
            <BlockStack gap="200">
              <InlineStack gap="100" blockAlign="center">
                <Tooltip content={IMPRESSION_TOOLTIP}>
                  <button type="button" style={LABEL_TRIGGER_STYLE}>
                    Impressions
                  </button>
                </Tooltip>
                <Tooltip content={IMPRESSION_LIMIT_TOOLTIP}>
                  <span style={ICON_TRIGGER_STYLE}>
                    <Icon source={InfoIcon} />
                  </span>
                </Tooltip>
              </InlineStack>
              <InlineStack blockAlign="end" gap="100">
                <Text as="span" variant="headingXl" fontWeight="medium">
                  {FREE_IMPRESSIONS}
                </Text>
                <Text as="span" variant="headingXl" fontWeight="medium">
                  /
                </Text>
                <Text as="span" variant="bodyMd">
                  {IMPRESSION_LIMIT} free impressions
                </Text>
              </InlineStack>
            </BlockStack>
          </Box>
        </Grid.Cell>
        <Grid.Cell columnSpan={{ xs: 6, sm: 3, md: 3, lg: 6, xl: 6 }}>
          <Box background="bg-fill-secondary" padding="300" borderRadius="200">
            <BlockStack gap="200">
              <Tooltip content={CONTACT_TOOLTIP}>
                <button type="button" style={LABEL_TRIGGER_STYLE}>
                  Contacts
                </button>
              </Tooltip>
              <Text as="span" variant="headingXl" fontWeight="medium">
                {CONTACTS}
              </Text>
            </BlockStack>
          </Box>
        </Grid.Cell>
      </Grid>
    </BlockStack>
  </Card>
);