Skip to content

Conversation

@AndrewMusgrave
Copy link
Member

@AndrewMusgrave AndrewMusgrave commented Aug 3, 2021

WHY are these changes introduced?

Fixes linked issue (see mentions below)

WHAT is this pull request doing?

Creating consistent spacing between the list, items, sections & titles.

Screenies

Image 2021-08-03 at 3 22 07 PM
Image 2021-08-03 at 3 30 05 PM

How to 🎩

Code below displaying a bunch of different combinations between sections/items/section titles

Copy-paste this code in playground/Playground.tsx:
import React, {useState, useCallback} from 'react';
import {ImportMinor, ExportMinor} from '@shopify/polaris-icons';

import {Page, Popover, Button, ActionList} from '../src';

const actionListProps = [
  {
    sections: [
      {
        title: 'File options',
        items: [
          {content: 'Import file', icon: ImportMinor},
          {content: 'Export file', icon: ExportMinor},
        ],
      },
      {
        title: 'File options',
        items: [
          {content: 'Import file', icon: ImportMinor},
          {content: 'Export file', icon: ExportMinor},
        ],
      },
      {
        items: [
          {content: 'Import file', icon: ImportMinor},
          {content: 'Export file', icon: ExportMinor},
        ],
      },
      {
        title: 'File options',
        items: [
          {content: 'Import file', icon: ImportMinor},
          {content: 'Export file', icon: ExportMinor},
        ],
      },
      {
        items: [
          {content: 'Import file', icon: ImportMinor},
          {content: 'Export file', icon: ExportMinor},
        ],
      },
    ],
  },
  {
    sections: [
      {
        items: [
          {content: 'Import file', icon: ImportMinor},
          {content: 'Export file', icon: ExportMinor},
        ],
      },
      {
        title: 'File options',
        items: [
          {content: 'Import file', icon: ImportMinor},
          {content: 'Export file', icon: ExportMinor},
        ],
      },
      {
        items: [
          {content: 'Import file', icon: ImportMinor},
          {content: 'Export file', icon: ExportMinor},
        ],
      },
      {
        title: '',
        items: [
          {content: 'Import file', icon: ImportMinor},
          {content: 'Export file', icon: ExportMinor},
        ],
      },
      {
        title: 'Test',
        items: [
          {content: 'Import file', icon: ImportMinor},
          {content: 'Export file', icon: ExportMinor},
        ],
      },
    ],
  },
  {
    items: [{content: 'Import file', icon: ImportMinor}],
    sections: [
      {
        title: 'File options',
        items: [
          {content: 'Import file', icon: ImportMinor},
          {content: 'Export file', icon: ExportMinor},
        ],
      },
      {
        title: 'File options',
        items: [
          {content: 'Import file', icon: ImportMinor},
          {content: 'Export file', icon: ExportMinor},
        ],
      },
      {
        items: [
          {content: 'Import file', icon: ImportMinor},
          {content: 'Export file', icon: ExportMinor},
        ],
      },
      {
        title: 'File options',
        items: [
          {content: 'Import file', icon: ImportMinor},
          {content: 'Export file', icon: ExportMinor},
        ],
      },
      {
        items: [
          {content: 'Import file', icon: ImportMinor},
          {content: 'Export file', icon: ExportMinor},
        ],
      },
    ],
  },
  {
    items: [
      {content: 'Import file', icon: ImportMinor},
      {content: 'Export file', icon: ExportMinor},
    ],
    sections: [
      {
        title: 'File options',
        items: [
          {content: 'Import file', icon: ImportMinor},
          {content: 'Export file', icon: ExportMinor},
        ],
      },
      {
        title: 'File options',
        items: [
          {content: 'Import file', icon: ImportMinor},
          {content: 'Export file', icon: ExportMinor},
        ],
      },
      {
        items: [
          {content: 'Import file', icon: ImportMinor},
          {content: 'Export file', icon: ExportMinor},
        ],
      },
      {
        title: '',
        items: [
          {content: 'Import file', icon: ImportMinor},
          {content: 'Export file', icon: ExportMinor},
        ],
      },
      {
        title: 'Test',
        items: [
          {content: 'Import file', icon: ImportMinor},
          {content: 'Export file', icon: ExportMinor},
        ],
      },
    ],
  },
  {
    items: [
      {content: 'Import file', icon: ImportMinor},
      {content: 'Export file', icon: ExportMinor},
    ],
  },
];

export function Playground() {
  return (
    <Page title="Playground">
      {Array.from({length: actionListProps.length}).map((_, index) => (
        <SectionedActionListExample index={index} key={index} />
      ))}
    </Page>
  );
}

function SectionedActionListExample({index}: any) {
  const [active, setActive] = useState(false);

  const toggleActive = useCallback(() => setActive((active) => !active), []);

  const activator = (
    <Button onClick={toggleActive} disclosure>
      More actions
    </Button>
  );

  return (
    <Popover active={active} activator={activator} onClose={toggleActive}>
      <ActionList {...actionListProps[index]} />
    </Popover>
  );
}

🎩 checklist

@github-actions
Copy link
Contributor

github-actions bot commented Aug 3, 2021

size-limit report

Path Size
cjs 142.4 KB (+0.03% 🔺)
esm 96.16 KB (+0.06% 🔺)
esnext 139.35 KB (+0.06% 🔺)
css 33.73 KB (+0.04% 🔺)

@AndrewMusgrave AndrewMusgrave marked this pull request as ready for review August 4, 2021 14:55
Copy link
Contributor

@danielle-dsouza danielle-dsouza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks amazing!

@AndrewMusgrave
Copy link
Member Author

@sarahill This may require some UI kit changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants