Skip to content

Commit

Permalink
fix(ts): nav ts props (patternfly#1242)
Browse files Browse the repository at this point in the history
  • Loading branch information
jschuler authored and tlabaj committed Jan 25, 2019
1 parent b23d027 commit 67207d8
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 5 deletions.
4 changes: 2 additions & 2 deletions packages/patternfly-4/react-core/src/components/Nav/Nav.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { Omit } from '../../typeUtils';
export interface NavProps extends Omit<HTMLProps<HTMLDivElement>, 'onSelect'> {
children?: ReactNode;
className?: string;
onSelect(groupId: number, itemId: number, event: FormEvent<HTMLInputElement>): void;
onToggle(groupId: number, expanded: boolean, event: FormEvent<HTMLInputElement>): void;
onSelect?(groupId: number, itemId: number, event: FormEvent<HTMLInputElement>): void;
onToggle?(groupId: number, expanded: boolean, event: FormEvent<HTMLInputElement>): void;
'aria-label': string;
}

Expand Down
7 changes: 6 additions & 1 deletion packages/patternfly-4/react-integration/README.md
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
# react-integration
# react-integration

1. Make your changes in packages/patternfly-4/react-core
2. `yarn build` in packages/patternfly-4/react-core
3. `yarn integration:setup` in packages/patternfly-4/react-integration
4. `yarn build:demo` in packages/patternfly-4/react-integration/demo-app-ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ import { Avatar, AvatarProps } from '@patternfly/react-core';
import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';
import NavTest from './Nav';

class myProps implements AvatarProps{
alt:string = "avatar";
class myProps implements AvatarProps {
alt: string = "avatar";
}

class App extends Component {
Expand All @@ -13,6 +14,7 @@ class App extends Component {
<div className="App">
<header className="App-header">
<Avatar src={logo} alt={new myProps().alt} />
<NavTest />
</header>
</div>
);
Expand Down
27 changes: 27 additions & 0 deletions packages/patternfly-4/react-integration/demo-app-ts/src/Nav.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { Nav, NavList, NavItem, NavProps } from '@patternfly/react-core';
import React, { Component } from 'react';

class myProps implements NavProps {
'aria-label': string = 'Test Nav Props';
}

class NavTest extends Component {
render() {
// Nav onToggle and onSelect should be optional
// https://github.com/patternfly/patternfly-react/issues/1234
return (
<Nav aria-label={new myProps()['aria-label']}>
<NavList>
<NavItem>
Link 1
</NavItem>
<NavItem>
Link 2
</NavItem>
</NavList>
</Nav>
);
}
}

export default NavTest;

0 comments on commit 67207d8

Please sign in to comment.