Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(List): Convert list to TypeScript
- Loading branch information
1 parent
c5bbc00
commit 022d2df
Showing
11 changed files
with
71 additions
and
132 deletions.
There are no files selected for viewing
16 changes: 0 additions & 16 deletions
16
packages/patternfly-4/react-core/src/components/List/List.d.ts
This file was deleted.
Oops, something went wrong.
37 changes: 0 additions & 37 deletions
37
packages/patternfly-4/react-core/src/components/List/List.js
This file was deleted.
Oops, something went wrong.
4 changes: 2 additions & 2 deletions
4
packages/patternfly-4/react-core/src/components/List/List.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
packages/patternfly-4/react-core/src/components/List/List.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import * as React from 'react'; | ||
import styles from '@patternfly/patternfly/components/List/list.css'; | ||
import { css, getModifier } from '@patternfly/react-styles'; | ||
|
||
export enum ListVariant { | ||
grid = 'grid', | ||
inline = 'inline' | ||
} | ||
|
||
export interface ListProps extends React.HTMLProps<HTMLUListElement> { | ||
/** Anything that can be rendered inside of the list */ | ||
children?: React.ReactNode; | ||
/** Additional classes added to the list. */ | ||
className?: string; | ||
/** Adds list variant styles */ | ||
variant?: ListVariant; | ||
} | ||
|
||
export const List: React.FunctionComponent<ListProps> = ({ | ||
className = '', | ||
children = null, | ||
variant = null, | ||
...props | ||
}) => ( | ||
<ul {...props} className={css(styles.list, variant && getModifier(styles.modifiers, variant), className)}> | ||
{children} | ||
</ul> | ||
); |
9 changes: 0 additions & 9 deletions
9
packages/patternfly-4/react-core/src/components/List/ListItem.d.ts
This file was deleted.
Oops, something went wrong.
20 changes: 0 additions & 20 deletions
20
packages/patternfly-4/react-core/src/components/List/ListItem.js
This file was deleted.
Oops, something went wrong.
9 changes: 9 additions & 0 deletions
9
packages/patternfly-4/react-core/src/components/List/ListItem.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import * as React from 'react'; | ||
|
||
export interface ListItemProps extends React.HTMLProps<HTMLLIElement> { | ||
/** Anything that can be rendered inside of list item */ | ||
children: React.ReactNode; | ||
/** Additional props are spread to the container <li> */ | ||
} | ||
|
||
export const ListItem: React.FunctionComponent<ListItemProps> = ({ children = null, ...props }) => <li {...props}>{children}</li>; |
74 changes: 30 additions & 44 deletions
74
packages/patternfly-4/react-core/src/components/List/__snapshots__/List.test.js.snap
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,115 +1,101 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`list grid list 1`] = ` | ||
<List | ||
className="" | ||
<Component | ||
variant="grid" | ||
> | ||
<ul | ||
className="pf-c-list" | ||
> | ||
<ListItems> | ||
<List | ||
className="" | ||
variant={null} | ||
> | ||
<Component> | ||
<ul | ||
className="pf-c-list" | ||
> | ||
<ListItem> | ||
<Component> | ||
<li> | ||
First | ||
</li> | ||
</ListItem> | ||
<ListItem> | ||
</Component> | ||
<Component> | ||
<li> | ||
Second | ||
</li> | ||
</ListItem> | ||
<ListItem> | ||
</Component> | ||
<Component> | ||
<li> | ||
Third | ||
</li> | ||
</ListItem> | ||
</Component> | ||
</ul> | ||
</List> | ||
</Component> | ||
</ListItems> | ||
</ul> | ||
</List> | ||
</Component> | ||
`; | ||
|
||
exports[`list inline list 1`] = ` | ||
<List | ||
className="" | ||
<Component | ||
variant="inline" | ||
> | ||
<ul | ||
className="pf-c-list pf-m-inline" | ||
> | ||
<ListItems> | ||
<List | ||
className="" | ||
variant={null} | ||
> | ||
<Component> | ||
<ul | ||
className="pf-c-list" | ||
> | ||
<ListItem> | ||
<Component> | ||
<li> | ||
First | ||
</li> | ||
</ListItem> | ||
<ListItem> | ||
</Component> | ||
<Component> | ||
<li> | ||
Second | ||
</li> | ||
</ListItem> | ||
<ListItem> | ||
</Component> | ||
<Component> | ||
<li> | ||
Third | ||
</li> | ||
</ListItem> | ||
</Component> | ||
</ul> | ||
</List> | ||
</Component> | ||
</ListItems> | ||
</ul> | ||
</List> | ||
</Component> | ||
`; | ||
|
||
exports[`list simple list 1`] = ` | ||
<List | ||
className="" | ||
variant={null} | ||
> | ||
<Component> | ||
<ul | ||
className="pf-c-list" | ||
> | ||
<ListItems> | ||
<List | ||
className="" | ||
variant={null} | ||
> | ||
<Component> | ||
<ul | ||
className="pf-c-list" | ||
> | ||
<ListItem> | ||
<Component> | ||
<li> | ||
First | ||
</li> | ||
</ListItem> | ||
<ListItem> | ||
</Component> | ||
<Component> | ||
<li> | ||
Second | ||
</li> | ||
</ListItem> | ||
<ListItem> | ||
</Component> | ||
<Component> | ||
<li> | ||
Third | ||
</li> | ||
</ListItem> | ||
</Component> | ||
</ul> | ||
</List> | ||
</Component> | ||
</ListItems> | ||
</ul> | ||
</List> | ||
</Component> | ||
`; |
2 changes: 0 additions & 2 deletions
2
packages/patternfly-4/react-core/src/components/List/index.d.ts
This file was deleted.
Oops, something went wrong.
2 changes: 0 additions & 2 deletions
2
packages/patternfly-4/react-core/src/components/List/index.js
This file was deleted.
Oops, something went wrong.
2 changes: 2 additions & 0 deletions
2
packages/patternfly-4/react-core/src/components/List/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export { List } from './List'; | ||
export { ListItem } from './ListItem'; |