Skip to content

Commit

Permalink
feat(brand): Converted brand component to typescript (#1918)
Browse files Browse the repository at this point in the history
* git mv files

* convert js to tsx

* Fix linting error
  • Loading branch information
jessiehuff authored and dlabaj committed May 16, 2019
1 parent 43d5283 commit 2c52451
Show file tree
Hide file tree
Showing 15 changed files with 100 additions and 47 deletions.

This file was deleted.

30 changes: 0 additions & 30 deletions packages/patternfly-4/react-core/src/components/Brand/Brand.js

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
title: 'Brand'
cssPrefix: null
typescript: true
---
## Simple brand

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import * as React from 'react';
import { shallow } from 'enzyme';
import Brand from './Brand';
import { Brand } from './Brand';

test('simple brand', () => {
const view = shallow(<Brand alt="brand" />);
Expand Down
21 changes: 21 additions & 0 deletions packages/patternfly-4/react-core/src/components/Brand/Brand.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import * as React from 'react';
import { css } from '@patternfly/react-styles';

export interface BrandProps extends React.DetailedHTMLProps<React.ImgHTMLAttributes<HTMLImageElement>, HTMLImageElement> {
/** Additional classes added to the Brand. */
className?: string;
/** Attribute that specifies the URL of the image for the Brand. */
src?: string;
/** Attribute that specifies the alt text of the image for the Brand. */
alt: string;
}

export const Brand: React.FunctionComponent<BrandProps> = ({
className = '',
src = '',
alt,
...props
}) => (
/** the brand component currently contains no styling the 'pf-c-brand' string will be used for the className */
<img {...props} className={css('pf-c-brand', className)} src={src} alt={alt} />
);

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './Brand';
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,8 @@ exports[`check loginpage example against snapshot 1`] = `
className=""
headerBrand={
<React.Fragment>
<Brand
<Unknown
alt="Pf-logo"
className=""
src="Brand src"
/>
</React.Fragment>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
describe('Brand Demo Test', () => {
it('Navigate to demo section', () => {
cy.visit('http://localhost:3000/');
cy.get('#brand-demo-nav-item-link').click();
cy.url().should('eq', 'http://localhost:3000/brand-demo-nav-link');
});

it('Verify has src', () => {
cy.get('img').should('have.attr', 'src')
});

it('Verify default alt', () => {
cy.get('img').should('have.attr', 'alt', 'Patternfly Logo')
});
})
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,13 @@ export const Demos: DemoInterface[] = [
componentType: Examples.AvatarDemo
},
{
id: 'label-demo',
name: 'Label Demo',
id: 'brand-demo',
name: 'Brand Demo',
componentType: Examples.BrandDemo
},
{
id: 'label-demo',
name: 'Label Demo',
componentType: Examples.LabelDemo
},
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import React from 'react';
import { Brand } from '@patternfly/react-core';
import pfLogo from './images/pfLogo.svg';

export class BrandDemo extends React.Component {
render() {
return (
<Brand src={pfLogo} alt="Patternfly Logo" />
);
}
}


Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
export * from './AlertDemo/AlertDemo';
export * from './AvatarDemo/AvatarDemo';
export * from './LabelDemo/LabelDemo';
export * from './BrandDemo/BrandDemo';
export * from './LabelDemo/LabelDemo';
export * from './NavDemo/NavDemo';
export * from './PopoverDemo/PopoverDemo'
export * from './TabsDemo/TabsDemo';
Expand Down

0 comments on commit 2c52451

Please sign in to comment.