Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reformat exports #2058

Merged
merged 6 commits into from
Aug 30, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
],
"babel/no-unused-expressions": "off",
"import/named": "off",
"import/no-named-as-default": "off",
"import/no-default-export": ["error"],
"react/button-has-type": "off",
"react/no-array-index-key": "off",
"react/jsx-fragments": ["error", "element"],
Expand Down
2 changes: 1 addition & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ Fixes #0000 <!-- link to issue if one exists -->
import React from 'react';
import {Page} from '../src';

export default function Playground() {
export function Playground() {
return (
<Page title="Playground">
{/* Add the code you want to test in here */}
Expand Down
2 changes: 1 addition & 1 deletion .storybook/stories-from-readme.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import {AppProvider, Heading} from '../src';
import {withA11y} from '@storybook/addon-a11y';
import {storiesOf} from '@storybook/react';
import Playground from '../playground/Playground';
import {Playground} from '../playground/Playground';
import en from '../locales/en.json';

/**
Expand Down
2 changes: 2 additions & 0 deletions UNRELEASED.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ Use [the changelog guidelines](https://git.io/polaris-changelog-guidelines) to f

### Development workflow

- Update subcomponents to use named exports for components and better names props exports ([#2058](https://github.com/Shopify/polaris-react/pull/2058))

### Dependency upgrades

### Code quality
Expand Down
2 changes: 1 addition & 1 deletion playground/Playground.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import {Page} from '../src';

export default function Playground() {
export function Playground() {
return (
<Page title="Playground">
{/* Add the code you want to test in here */}
Expand Down
1 change: 1 addition & 0 deletions sewing-kit.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ interface InitialOptions extends jest.InitialOptions {
setupFilesAfterEnv: string[];
}

// eslint-disable-next-line import/no-default-export
export default function sewingKitConfig(
plugins: Plugins,
env: Env,
Expand Down
16 changes: 8 additions & 8 deletions src/components/AccountConnection/AccountConnection.tsx
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import React from 'react';

import {Action} from '../../types';
import Avatar from '../Avatar';
import {Avatar} from '../Avatar';
import {buttonFrom} from '../Button';
import Card from '../Card';
import Stack from '../Stack';
import TextStyle from '../TextStyle';
import SettingAction from '../SettingAction';
import {Card} from '../Card';
import {Stack} from '../Stack';
import {TextStyle} from '../TextStyle';
import {SettingAction} from '../SettingAction';

import styles from './AccountConnection.scss';

export interface Props {
export interface AccountConnectionProps {
/** Content to display as title */
title?: React.ReactNode;
/** Content to display as additional details */
Expand All @@ -27,15 +27,15 @@ export interface Props {
action?: Action;
}

export default function AccountConnection({
export function AccountConnection({
connected = false,
action,
avatarUrl,
accountName = '',
title,
details,
termsOfService,
}: Props) {
}: AccountConnectionProps) {
const initials = accountName
? accountName
.split(/\s+/)
Expand Down
5 changes: 1 addition & 4 deletions src/components/AccountConnection/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
import AccountConnection from './AccountConnection';

export {Props} from './AccountConnection';
export default AccountConnection;
export {AccountConnection, AccountConnectionProps} from './AccountConnection';
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import {mountWithAppProvider} from 'test-utilities/legacy';
import {Avatar, buttonFrom} from 'components';
import AccountConnection from '../AccountConnection';
import {AccountConnection} from '../AccountConnection';

describe('<AccountConnection />', () => {
describe('title', () => {
Expand Down
6 changes: 3 additions & 3 deletions src/components/ActionList/ActionList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {Section} from './components';

import styles from './ActionList.scss';

export interface Props {
export interface ActionListProps {
/** Collection of actions for list */
items?: ActionListItemDescriptor[];
/** Collection of sectioned action items */
Expand All @@ -15,12 +15,12 @@ export interface Props {
onActionAnyItem?: ActionListItemDescriptor['onAction'];
}

export default function ActionList({
export function ActionList({
items,
sections = [],
actionRole,
onActionAnyItem,
}: Props) {
}: ActionListProps) {
let finalSections: ActionListSection[] = [];

if (items) {
Expand Down
16 changes: 8 additions & 8 deletions src/components/ActionList/components/Item/Item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ import React from 'react';

import {classNames} from '../../../../utilities/css';
import {ActionListItemDescriptor} from '../../../../types';
import Scrollable from '../../../Scrollable';
import Icon from '../../../Icon';
import UnstyledLink from '../../../UnstyledLink';
import Badge from '../../../Badge';
import TextStyle from '../../../TextStyle';
import {Scrollable} from '../../../Scrollable';
import {Icon} from '../../../Icon';
import {UnstyledLink} from '../../../UnstyledLink';
import {Badge} from '../../../Badge';
import {TextStyle} from '../../../TextStyle';

import styles from '../../ActionList.scss';

export type Props = ActionListItemDescriptor;
export type ItemProps = ActionListItemDescriptor;

export default function Item({
export function Item({
id,
badge,
content,
Expand All @@ -28,7 +28,7 @@ export default function Item({
ellipsis,
active,
role,
}: Props) {
}: ItemProps) {
const className = classNames(
styles.Item,
disabled && styles.disabled,
Expand Down
5 changes: 1 addition & 4 deletions src/components/ActionList/components/Item/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
import Item from './Item';

export {Props} from './Item';
export default Item;
export {Item, ItemProps} from './Item';
4 changes: 2 additions & 2 deletions src/components/ActionList/components/Item/tests/Item.test.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from 'react';
import {mountWithAppProvider} from 'test-utilities/legacy';
import {UnstyledLink} from 'components';
import Item from '../Item';
import TextStyle from '../../../../TextStyle';
import {Item} from '../Item';
import {TextStyle} from '../../../../TextStyle';

describe('<Item />', () => {
it('adds a style property when the image prop is present', () => {
Expand Down
8 changes: 4 additions & 4 deletions src/components/ActionList/components/Section/Section.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React from 'react';
import Item from '../Item';
import {Item} from '../Item';
import {ActionListItemDescriptor, ActionListSection} from '../../../../types';

import styles from '../../ActionList.scss';

export interface Props {
export interface SectionProps {
/** Section of action items */
section: ActionListSection;
/** Should there be multiple sections */
Expand All @@ -15,12 +15,12 @@ export interface Props {
onActionAnyItem?: ActionListItemDescriptor['onAction'];
}

export default function Section({
export function Section({
section,
hasMultipleSections,
actionRole,
onActionAnyItem,
}: Props) {
}: SectionProps) {
const handleAction = (itemOnAction: ActionListItemDescriptor['onAction']) => {
return () => {
if (itemOnAction) {
Expand Down
5 changes: 1 addition & 4 deletions src/components/ActionList/components/Section/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
import Section from './Section';

export {Props} from './Section';
export default Section;
export {Section, SectionProps} from './Section';
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import {mountWithAppProvider} from 'test-utilities/legacy';
import Item from '../../Item';
import Section from '../Section';
import {Item} from '../../Item';
import {Section} from '../Section';

describe('<Section />', () => {
it('renders its items', () => {
Expand Down
4 changes: 2 additions & 2 deletions src/components/ActionList/components/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export {default as Item, Props as ItemProps} from './Item';
export {Item, ItemProps} from './Item';

export {default as Section, Props as SectionProps} from './Section';
export {Section, SectionProps} from './Section';
5 changes: 1 addition & 4 deletions src/components/ActionList/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
import ActionList from './ActionList';

export {Props} from './ActionList';
export default ActionList;
export {ActionList, ActionListProps} from './ActionList';
4 changes: 2 additions & 2 deletions src/components/ActionList/tests/ActionList.test.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React from 'react';
import {ImportMinor, ExportMinor} from '@shopify/polaris-icons';
import {mountWithAppProvider} from 'test-utilities/legacy';
import ActionList from '../ActionList';
import Badge from '../../Badge';
import {ActionList} from '../ActionList';
import {Badge} from '../../Badge';
import {Item, Section} from '../components';

describe('<ActionList />', () => {
Expand Down
6 changes: 3 additions & 3 deletions src/components/ActionMenu/ActionMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {MenuAction, MenuGroup, RollupActions} from './components';

import styles from './ActionMenu.scss';

export interface Props {
export interface ActionMenuProps {
/** Collection of page-level secondary actions */
actions?: ComplexAction[];
/** Collection of page-level action groups */
Expand All @@ -24,7 +24,7 @@ interface State {
activeMenuGroup?: string;
}

export default class ActionMenu extends React.PureComponent<Props, State> {
export class ActionMenu extends React.PureComponent<ActionMenuProps, State> {
state: State = {
activeMenuGroup: undefined,
};
Expand Down Expand Up @@ -100,7 +100,7 @@ export default class ActionMenu extends React.PureComponent<Props, State> {
};
}

export function hasGroupsWithActions(groups: Props['groups'] = []) {
export function hasGroupsWithActions(groups: ActionMenuProps['groups'] = []) {
return groups.length === 0
? false
: groups.some((group) => group.actions.length > 0);
Expand Down
10 changes: 5 additions & 5 deletions src/components/ActionMenu/components/MenuAction/MenuAction.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,17 @@ import {classNames} from '../../../../utilities/css';
import {handleMouseUpByBlurring} from '../../../../utilities/focus';
import {ComplexAction} from '../../../../types';

import Icon from '../../../Icon';
import UnstyledLink from '../../../UnstyledLink';
import {Icon} from '../../../Icon';
import {UnstyledLink} from '../../../UnstyledLink';

import styles from './MenuAction.scss';

export interface Props extends ComplexAction {
export interface MenuActionProps extends ComplexAction {
/** Whether or not the action discloses a menu group */
disclosure?: boolean;
}

export default function MenuAction({
export function MenuAction({
content,
accessibilityLabel,
url,
Expand All @@ -24,7 +24,7 @@ export default function MenuAction({
disclosure,
disabled,
onAction,
}: Props) {
}: MenuActionProps) {
const iconMarkup = icon && (
<span className={styles.IconWrapper}>
<Icon source={icon} />
Expand Down
2 changes: 1 addition & 1 deletion src/components/ActionMenu/components/MenuAction/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export {default, Props} from './MenuAction';
export {MenuAction, MenuActionProps} from './MenuAction';
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import React from 'react';
import {CaretDownMinor, SaveMinor} from '@shopify/polaris-icons';
import {mountWithAppProvider, trigger} from 'test-utilities/legacy';

import Icon from '../../../../Icon';
import UnstyledLink from '../../../../UnstyledLink';
import {Icon} from '../../../../Icon';
import {UnstyledLink} from '../../../../UnstyledLink';

import MenuAction, {Props} from '../MenuAction';
import {MenuAction} from '../MenuAction';

describe('<MenuAction />', () => {
const mockProps: Props = {
const mockProps = {
content: 'content',
};

Expand Down
10 changes: 5 additions & 5 deletions src/components/ActionMenu/components/MenuGroup/MenuGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import React from 'react';

import {MenuGroupDescriptor} from '../../../../types';

import ActionList from '../../../ActionList';
import Popover from '../../../Popover';
import MenuAction from '../MenuAction';
import {ActionList} from '../../../ActionList';
import {Popover} from '../../../Popover';
import {MenuAction} from '../MenuAction';

import styles from './MenuGroup.scss';

export interface Props extends MenuGroupDescriptor {
export interface MenuGroupProps extends MenuGroupDescriptor {
/** Visually hidden menu description for screen readers */
accessibilityLabel?: string;
/** Whether or not the menu is open */
Expand All @@ -19,7 +19,7 @@ export interface Props extends MenuGroupDescriptor {
onClose(title: string): void;
}

export default class MenuGroup extends React.Component<Props, never> {
export class MenuGroup extends React.Component<MenuGroupProps, never> {
render() {
const {
accessibilityLabel,
Expand Down
2 changes: 1 addition & 1 deletion src/components/ActionMenu/components/MenuGroup/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export {default, Props} from './MenuGroup';
export {MenuGroup, MenuGroupProps} from './MenuGroup';
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import {SaveMinor} from '@shopify/polaris-icons';
import {mountWithAppProvider, trigger} from 'test-utilities/legacy';

import {Popover, ActionList} from 'components';
import MenuAction from '../../MenuAction';
import MenuGroup, {Props} from '../MenuGroup';
import {MenuAction} from '../../MenuAction';
import {MenuGroup} from '../MenuGroup';

describe('<MenuGroup />', () => {
const mockProps: Props = {
const mockProps = {
title: 'title',
actions: [],
active: undefined,
Expand Down Expand Up @@ -80,7 +80,7 @@ describe('<MenuGroup />', () => {
});

it('passes `actions` into the <ActionList />', () => {
const mockActions: Props['actions'] = [
const mockActions = [
{content: 'mock content 1'},
{content: 'mock content 2'},
];
Expand Down
Loading