Skip to content

Commit a33450a

Browse files
committed
refactor: update non-exported types from interface to type
1 parent f205e07 commit a33450a

File tree

14 files changed

+49
-43
lines changed

14 files changed

+49
-43
lines changed

.storybook/components/Docs/Guidelines/CodeGuidelines.mdx

+7-6
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,8 @@ Examples:
207207

208208
```css
209209
.dropdown-button__icon {
210-
transition: transform calc(var(--eds-anim-move-medium) * 1s) var(--eds-anim-ease);
210+
transition: transform calc(var(--eds-anim-move-medium) * 1s)
211+
var(--eds-anim-ease);
211212

212213
@media (prefers-reduced-motion) {
213214
transition: none;
@@ -368,7 +369,7 @@ import { Icon } from '../Icon/Icon';
368369
### Prop Type definitions
369370

370371
```tsx
371-
export interface ComponentNameProps {
372+
export type ComponentNameProps = {
372373
/**
373374
* Toggles the ability to dismiss the banner via an close button in the top right of the banner
374375
*/
@@ -388,7 +389,7 @@ The comment should begin with an import example, include a general description o
388389
389390
Example:
390391
391-
```tsx
392+
````tsx
392393
/**
393394
* `import {ButtonGroup} from "@chanzuckerberg/eds";`
394395
*
@@ -408,13 +409,13 @@ Example:
408409
* ```
409410
*/
410411
export const ButtonGroup = ({ ... })
411-
```
412+
````
412413
413414
Do not use [jsdoc tags](https://devhints.io/jsdoc) (e.g. `@example`) if possible because these will break the documentation in storybook and cause all following text to not be shown on the page. For important jsdoc tags that we really want to include, place them at the end of the comment to avoid hiding comment content. For example, we use the `@deprecated` tag so Visual Studio Code will indicate a component is deprecated for developers, but we place that at the end of a component's docstring to avoid disrupting any of the other text.
414415
415416
Example:
416417
417-
```tsx
418+
````tsx
418419
/**
419420
* The Banner component is deprecated and will be removed in an upcoming release.
420421
*
@@ -437,7 +438,7 @@ Example:
437438
*
438439
* @deprecated
439440
*/
440-
```
441+
````
441442
442443
### Export module
443444

.storybook/components/Grid/Grid.tsx

+5-5
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { ReactNode } from 'react';
33
import React from 'react';
44
import styles from './Grid.module.css';
55

6-
export interface Props {
6+
export type GridProps = {
77
/**
88
* Child node(s) that can be nested inside component
99
*/
@@ -35,9 +35,9 @@ export interface Props {
3535
| '4up'
3636
| '1-2-4up'
3737
| '1-2-1up';
38-
}
38+
};
3939

40-
export interface GridItemProps {
40+
export type GridItemProps = {
4141
/**
4242
* Child node(s) that can be nested inside component
4343
*/
@@ -46,7 +46,7 @@ export interface GridItemProps {
4646
* CSS class names that can be appended to the component.
4747
*/
4848
className?: string;
49-
}
49+
};
5050

5151
/**
5252
* The Grid component is deprecated and will be removed in an upcoming release.
@@ -64,7 +64,7 @@ export const Grid = ({
6464
children,
6565
gap,
6666
...other
67-
}: Props) => {
67+
}: GridProps) => {
6868
const componentClassName = clsx(
6969
styles['grid'],
7070
variant && styles[`grid--${variant}`],

.storybook/components/Section/Section.tsx

+4-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ import React from 'react';
44
import { Heading } from '../../../src/';
55
import type { HeadingElement } from '../../../src/components/Heading';
66
import styles from './Section.module.css';
7-
export interface Props {
7+
8+
export type SectionProps = {
89
/**
910
* Align variations:
1011
* - **center** yields a center-aligned section header
@@ -48,7 +49,7 @@ export interface Props {
4849
* Slot for node to appear to the left of the section title. Typically used for images or avatars
4950
*/
5051
titleBefore?: ReactNode;
51-
}
52+
};
5253

5354
/**
5455
* `import {Section} from "@chanzuckerberg/eds";`
@@ -67,7 +68,7 @@ export const Section = ({
6768
titleAfter,
6869
titleBefore,
6970
...other
70-
}: Props) => {
71+
}: SectionProps) => {
7172
const componentClassName = clsx(
7273
styles['section'],
7374
align === 'center' && styles['section--center'],

plop-templates/Component/Component.tsx.hbs

+3-3
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@ import clsx from 'clsx';
22
import React from 'react';
33
import styles from './{{pascalCase name}}.module.css';
44

5-
export interface Props {
5+
export type {{pascalCase name}}Props = {
66
// Component API
77
/**
88
* CSS class names that can be appended to the component.
99
*/
1010
className?: string;
1111
// Design API
1212
// Insert props/values as defined in figma for {{pascalCase name}}
13-
}
13+
};
1414

1515
/**
1616
* BETA: This component is still a work in progress and is subject to change.
@@ -23,7 +23,7 @@ export const {{pascalCase name}} = ({
2323
className,
2424
// Add other deferenced props to use
2525
...other
26-
}: Props) => {
26+
}: {{pascalCase name}}Props) => {
2727
const componentClassName = clsx(styles['{{dashCase name}}'], className);
2828

2929
return (

src/components/AppNotification/AppNotification.tsx

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import Button from '../Button';
44
import Text from '../Text';
55
import styles from './AppNotification.module.css';
66

7+
// TODO(next-major): change export to type for consistency
78
export interface AppNotificationProps {
89
// Design API
910
/**

src/components/Card/Card.tsx

+6-6
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import Text from '../Text';
99

1010
import styles from './Card.module.css';
1111

12-
export interface CardProps extends HTMLAttributes<HTMLElement> {
12+
export type CardProps = HTMLAttributes<HTMLElement> & {
1313
// Component API
1414
/**
1515
* Child node(s) that can be nested inside component
@@ -55,8 +55,8 @@ export interface CardProps extends HTMLAttributes<HTMLElement> {
5555
* Class to adjust top stripe background color. Choose from brand-background tokens utility classes.
5656
*/
5757
topStripeColor?: string;
58-
}
59-
export interface CardSubComponentProps {
58+
};
59+
export type CardSubComponentProps = {
6060
// Component API
6161
/**
6262
* Child node(s) that can be nested inside component
@@ -66,9 +66,9 @@ export interface CardSubComponentProps {
6666
* CSS class names that can be appended to the component.
6767
*/
6868
className?: string;
69-
}
69+
};
7070

71-
export interface CardHeaderProps {
71+
export type CardHeaderProps = {
7272
// Component API
7373
/**
7474
* Child node(s) that can be nested inside component. Used in place of any of the above named slots.
@@ -103,7 +103,7 @@ export interface CardHeaderProps {
103103
* The title/heading of the component
104104
*/
105105
title?: string;
106-
}
106+
};
107107

108108
/**
109109
* `import {Card} from "@chanzuckerberg/eds";`

src/components/FieldNote/FieldNote.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import Icon from '../Icon';
66
import type { IconName } from '../Icon';
77
import styles from './FieldNote.module.css';
88

9-
export interface Props {
9+
export type FieldNoteProps = {
1010
// Component API
1111
/**
1212
* Child node(s) that can be nested inside component
@@ -37,7 +37,7 @@ export interface Props {
3737
* **Default is `"default"`**.
3838
*/
3939
status?: 'default' | Extract<Status, 'warning' | 'critical'>;
40-
}
40+
};
4141

4242
/**
4343
* `import {FieldNote} from "@chanzuckerberg/eds";`
@@ -52,7 +52,7 @@ export const FieldNote = ({
5252
icon,
5353
status,
5454
...other
55-
}: Props) => {
55+
}: FieldNoteProps) => {
5656
const componentClassName = clsx(
5757
styles['field-note'],
5858
disabled && styles['field-note--disabled'],

src/components/Icon/Icon.tsx

+4-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import styles from './Icon.module.css';
77
export type { IconName } from '../../icons/spritemap';
88

99
// TODO: export union utility type of "Extract<IconName, T> | (renderProps) => ReactNode" when updating IconName usages
10-
// TODO: convert to types for consistency
10+
// TODO(next-major): convert to types for consistency
1111
interface IconPropsBase {
1212
/**
1313
* CSS class names that can be appended to the component.
@@ -52,6 +52,7 @@ interface IconPropsBase {
5252
viewBox?: string;
5353
}
5454

55+
// TODO(next-major): convert to types for consistency
5556
interface InformativeIconProps extends IconPropsBase {
5657
/**
5758
* The role of the icon.
@@ -63,6 +64,7 @@ interface InformativeIconProps extends IconPropsBase {
6364
title: string;
6465
}
6566

67+
// TODO(next-major): convert to types for consistency
6668
interface DecorativeIconProps extends IconPropsBase {
6769
/**
6870
* The role of the icon.
@@ -76,6 +78,7 @@ interface DecorativeIconProps extends IconPropsBase {
7678

7779
export type IconProps = DecorativeIconProps | InformativeIconProps;
7880

81+
// TODO(next-major): convert to types for consistency
7982
interface SvgStyle extends CSSProperties {
8083
'--icon-size'?: string;
8184
}

src/components/InputChip/InputChip.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import Text from '../Text';
66

77
import styles from './InputChip.module.css';
88

9-
export interface Props {
9+
export type InputChipProps = {
1010
// Component API
1111
/**
1212
* CSS class names that can be appended to the component.
@@ -33,7 +33,7 @@ export interface Props {
3333
* The display size of the chip
3434
*/
3535
size?: Extract<Size, 'sm' | 'md'>;
36-
}
36+
};
3737

3838
/**
3939
* `import {InputChip} from "@chanzuckerberg/eds";`
@@ -48,7 +48,7 @@ export const InputChip = ({
4848
onClick,
4949
size = 'md',
5050
...other
51-
}: Props) => {
51+
}: InputChipProps) => {
5252
const componentClassName = clsx(
5353
styles['input-chip'],
5454
isDisabled && styles[`input-chip--disabled`],

src/components/Label/Label.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import React from 'react';
55
import Text from '../Text';
66
import styles from './Label.module.css';
77

8-
export interface Props {
8+
export type LabelProps = {
99
/**
1010
* CSS class names that can be appended to the component.
1111
*/
@@ -34,7 +34,7 @@ export interface Props {
3434
* The label text string
3535
*/
3636
text: string;
37-
}
37+
};
3838

3939
/**
4040
* `import {Label} from "@chanzuckerberg/eds";`
@@ -50,7 +50,7 @@ export const Label = ({
5050
required = true,
5151
text,
5252
...other
53-
}: Props) => {
53+
}: LabelProps) => {
5454
const componentClassName = clsx(
5555
styles['label'],
5656
hideLabel && styles['u-is-vishidden'],

src/components/Menu/Menu.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import type { PopoverContext, PopoverOptions } from '../PopoverContainer';
2020
import PopoverListItem from '../PopoverListItem';
2121
import styles from './Menu.module.css';
2222

23-
// Note: added className here to prevent private interface collision within HeadlessUI
23+
// Note: added className here to prevent private API collision within HeadlessUI
2424
export type MenuProps = ExtractProps<typeof HeadlessMenu> &
2525
PopoverOptions & {
2626
// TODO: document children?

src/components/NumberIcon/NumberIcon.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import Text from '../Text';
77

88
import styles from './NumberIcon.module.css';
99

10-
export interface Props {
10+
export type NumberIconProps = {
1111
// Component API
1212
/**
1313
* (Required) Screen-reader text for the number icon.
@@ -36,7 +36,7 @@ export interface Props {
3636
* Indication of the status of the referenced item
3737
*/
3838
status?: 'completed' | 'incomplete' | 'default';
39-
}
39+
};
4040

4141
/**
4242
* `import {NumberIcon} from "@chanzuckerberg/eds";`
@@ -51,7 +51,7 @@ export const NumberIcon = ({
5151
status = 'default',
5252
size = 'lg',
5353
...other
54-
}: Props) => {
54+
}: NumberIconProps) => {
5555
const componentClassName = clsx(
5656
className,
5757
styles['number-icon'],

src/components/PopoverListItem/PopoverListItem.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import Icon, { type IconName } from '../Icon';
55
import Text from '../Text';
66
import styles from './PopoverListItem.module.css';
77

8-
export interface PopoverListItemProps {
8+
export type PopoverListItemProps = {
99
/**
1010
* Child node(s) that can be nested inside component
1111
*/
@@ -35,7 +35,7 @@ export interface PopoverListItemProps {
3535
* Text below the main menu item call-to-action, briefly describing the menu item's function
3636
*/
3737
subLabel?: string;
38-
}
38+
};
3939

4040
/**
4141
* `import {PopoverListItem} from "@chanzuckerberg/eds";`

src/components/TabGroup/TabGroup.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ import Icon, { type IconName } from '../Icon';
2424

2525
import styles from './TabGroup.module.css';
2626

27-
export interface TabGroupProps {
27+
export type TabGroupProps = {
2828
// Component API
2929
/**
3030
* Reference to another element that describes the purpose of the set of tabs.
@@ -77,9 +77,9 @@ export interface TabGroupProps {
7777
* **Default is `"default"`**.
7878
*/
7979
variant?: 'default' | 'inverse';
80-
}
80+
};
8181

82-
export interface TabProps {
82+
export type TabProps = {
8383
// Component API
8484
/**
8585
* aria-labelledby attribute that associates a tab panel with its accompanying tab title
@@ -118,7 +118,7 @@ export interface TabProps {
118118
* **NOTE**: this cannot be used with `icon`
119119
*/
120120
illustration?: ReactNode;
121-
}
121+
};
122122

123123
type TabButtonProps = RenderProps<TabContextArgs>;
124124
export type TabContextArgs = {

0 commit comments

Comments
 (0)