Skip to content

Commit

Permalink
Reformat subcomponents to export named values
Browse files Browse the repository at this point in the history
Tidy up a few bits of spacing along the way so consistently have a
single line between export declarations
  • Loading branch information
BPScott committed Aug 28, 2019
1 parent 1cd66ee commit 1779f92
Show file tree
Hide file tree
Showing 267 changed files with 584 additions and 730 deletions.
6 changes: 3 additions & 3 deletions src/components/ActionList/components/Item/Item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ 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';
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 {UnstyledLink} from 'components';
import Item from '../Item';
import {Item} from '../Item';
import TextStyle from '../../../../TextStyle';

describe('<Item />', () => {
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';
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ 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 @@ -5,10 +5,10 @@ import {mountWithAppProvider, trigger} from 'test-utilities/legacy';
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
6 changes: 3 additions & 3 deletions src/components/ActionMenu/components/MenuGroup/MenuGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ import {MenuGroupDescriptor} from '../../../../types';

import ActionList from '../../../ActionList';
import Popover from '../../../Popover';
import MenuAction from '../MenuAction';
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
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,14 @@ import Popover from '../../../Popover';

import styles from './RollupActions.scss';

export interface Props {
export interface RollupActionsProps {
/** Collection of actions for the list */
items?: ActionListItemDescriptor[];
/** Collection of sectioned action items */
sections?: ActionListSection[];
}

type ComposedProps = Props & WithAppProviderProps;
type ComposedProps = RollupActionsProps & WithAppProviderProps;

interface State {
rollupOpen: boolean;
Expand Down Expand Up @@ -77,4 +77,4 @@ class RollupActions extends React.PureComponent<ComposedProps, State> {
};
}

export default withAppProvider<Props>()(RollupActions);
export default withAppProvider<RollupActionsProps>()(RollupActions);
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export {default, Props} from './RollupActions';
export {default as RollupActions, RollupActionsProps} from './RollupActions';
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ import {
Section as ActionListSection,
} from '../../../../ActionList/components';

import RollupActions, {Props} from '../RollupActions';
import RollupActions, {RollupActionsProps} from '../RollupActions';

type Wrapper = ReactWrapper<Props, any>;
type Wrapper = ReactWrapper<RollupActionsProps, any>;

describe('<RollupActions />', () => {
const mockProps: Props = {
const mockProps = {
items: undefined,
sections: undefined,
};
Expand All @@ -28,7 +28,7 @@ describe('<RollupActions />', () => {
});

describe('items', () => {
const mockItems: Props['items'] = [
const mockItems = [
{
content: 'mock content 1',
url: 'https://www.google.com',
Expand Down Expand Up @@ -68,7 +68,7 @@ describe('<RollupActions />', () => {
});

describe('sections', () => {
const mockSections: Props['sections'] = [
const mockSections = [
{
title: 'mock title 1',
items: [
Expand Down
9 changes: 3 additions & 6 deletions src/components/ActionMenu/components/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
export {default as MenuAction, Props as MenuActionProps} from './MenuAction';
export {MenuAction, MenuActionProps} from './MenuAction';

export {default as MenuGroup, Props as MenuGroupProps} from './MenuGroup';
export {MenuGroup, MenuGroupProps} from './MenuGroup';

export {
default as RollupActions,
Props as RollupActionsProps,
} from './RollupActions';
export {RollupActions, RollupActionsProps} from './RollupActions';
8 changes: 4 additions & 4 deletions src/components/Autocomplete/components/ComboBox/ComboBox.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ interface State {
popoverWasActive: boolean;
}

export interface Props {
export interface ComboBoxProps {
/** A unique identifier for the ComboBox */
id?: string;
/** Collection of options to be listed */
Expand Down Expand Up @@ -54,14 +54,14 @@ export interface Props {
onEndReached?(): void;
}

export default class ComboBox extends React.PureComponent<Props, State> {
export class ComboBox extends React.PureComponent<ComboBoxProps, State> {
static getDerivedStateFromProps(
{
options: nextOptions,
selected: nextSelected,
actionsBefore: nextActionsBefore,
actionsAfter: nextActionsAfter,
}: Props,
}: ComboBoxProps,
{navigableOptions, selectedOptions, comboBoxId}: State,
) {
const optionsChanged =
Expand Down Expand Up @@ -129,7 +129,7 @@ export default class ComboBox extends React.PureComponent<Props, State> {
});
}

componentDidUpdate(_: Props, prevState: State) {
componentDidUpdate(_: ComboBoxProps, prevState: State) {
const {contentBefore, contentAfter, emptyState} = this.props;
const {navigableOptions, popoverWasActive} = this.state;

Expand Down
5 changes: 1 addition & 4 deletions src/components/Autocomplete/components/ComboBox/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
import ComboBox from './ComboBox';

export {Props} from './ComboBox';
export default ComboBox;
export {ComboBox} from './ComboBox';
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import React from 'react';
import {shallow} from 'enzyme';
import {OptionList, ActionList, Popover} from 'components';
import {mountWithAppProvider, trigger} from 'test-utilities/legacy';
import TextField from '../../TextField';
import {TextField} from '../../TextField';
import {Key} from '../../../../../types';
import ComboBox from '..';
import {ComboBox} from '..';

describe('<ComboBox/>', () => {
const options = [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import React from 'react';
import {ComboBoxContext} from '../ComboBox/context';
import BaseTextField, {Props as TextFieldProps} from '../../../TextField';

export default function TextField(props: TextFieldProps) {
export function TextField(props: TextFieldProps) {
return (
<ComboBoxContext.Consumer>
{({selectedOptionId, comboBoxId}) => (
Expand Down
4 changes: 1 addition & 3 deletions src/components/Autocomplete/components/TextField/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
import TextField from './TextField';

export default TextField;
export {TextField} from './TextField';
4 changes: 2 additions & 2 deletions src/components/Autocomplete/components/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
export {default as ComboBox} from './ComboBox';
export {ComboBox} from './ComboBox';

export {default as TextField} from './TextField';
export {TextField} from './TextField';
8 changes: 8 additions & 0 deletions src/components/Avatar/images/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,17 @@
export {default as avatarOne} from './avatar-1.svg';

export {default as avatarTwo} from './avatar-2.svg';

export {default as avatarThree} from './avatar-3.svg';

export {default as avatarFour} from './avatar-4.svg';

export {default as avatarFive} from './avatar-5.svg';

export {default as avatarSix} from './avatar-6.svg';

export {default as avatarSeven} from './avatar-7.svg';

export {default as avatarEight} from './avatar-8.svg';

export {default as avatarNine} from './avatar-9.svg';
4 changes: 2 additions & 2 deletions src/components/ButtonGroup/components/Item/Item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ import {Props as ButtonProps} from '../../../Button';

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

export interface Props {
export interface ItemProps {
button: React.ReactElement<ButtonProps>;
}

interface State {
focused: boolean;
}

export default class Item extends React.PureComponent<Props, State> {
export class Item extends React.PureComponent<ItemProps, State> {
state: State = {focused: false};

render() {
Expand Down
5 changes: 1 addition & 4 deletions src/components/ButtonGroup/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';
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 {Button} from 'components';
import Item from '../Item';
import {Item} from '../Item';

describe('<Item />', () => {
describe('button', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/ButtonGroup/components/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export {default as Item, Props as ItemProps} from './Item';
export {Item, ItemProps} from './Item';
4 changes: 2 additions & 2 deletions src/components/Card/components/Header/Header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ import Heading from '../../../Heading';

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

export interface Props {
export interface HeaderProps {
title?: React.ReactNode;
actions?: DisableableAction[];
children?: React.ReactNode;
}

export default function Header({children, title, actions}: Props) {
export function Header({children, title, actions}: HeaderProps) {
const actionMarkup = actions ? (
<ButtonGroup>{buttonsFrom(actions, {plain: true})}</ButtonGroup>
) : null;
Expand Down
5 changes: 1 addition & 4 deletions src/components/Card/components/Header/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
import Header from './Header';

export {Props} from './Header';
export default Header;
export {Header, HeaderProps} from './Header';
Loading

0 comments on commit 1779f92

Please sign in to comment.