forked from patternfly/patternfly-react
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(pf4-brand): introduce brand component (patternfly#633)
affects: @patternfly/react-core, @patternfly/react-docs
- Loading branch information
Showing
14 changed files
with
125 additions
and
4 deletions.
There are no files selected for viewing
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
2 changes: 1 addition & 1 deletion
2
packages/patternfly-4/react-core/src/components/Avatar/examples/SimpleAvatar.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
File renamed without changes
9 changes: 9 additions & 0 deletions
9
packages/patternfly-4/react-core/src/components/Brand/Brand.d.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,9 @@ | ||
import { SFC, HTMLProps, ReactNode } from 'react'; | ||
import { Omit } from '../../typeUtils'; | ||
|
||
export interface BrandProps extends HTMLProps<HTMLImageElement> { | ||
src?: string; | ||
alt: string; | ||
} | ||
declare const Brand: SFC<BrandProps>; | ||
export default Brand; |
10 changes: 10 additions & 0 deletions
10
packages/patternfly-4/react-core/src/components/Brand/Brand.docs.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { Brand } from '@patternfly/react-core'; | ||
import Simple from './examples/SimpleBrand'; | ||
|
||
export default { | ||
title: 'Brand', | ||
components: { | ||
Brand | ||
}, | ||
examples: [Simple] | ||
}; |
28 changes: 28 additions & 0 deletions
28
packages/patternfly-4/react-core/src/components/Brand/Brand.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import React from 'react'; | ||
import { css } from '@patternfly/react-styles'; | ||
import PropTypes from 'prop-types'; | ||
|
||
const propTypes = { | ||
/** Additional classes added to the Brand. */ | ||
className: PropTypes.string, | ||
/** Attribute that specifies the URL of the image for the Brand. */ | ||
src: PropTypes.string, | ||
/** Attribute that specifies the alt text of the image for the Brand. */ | ||
alt: PropTypes.string.isRequired | ||
}; | ||
|
||
const defaultProps = { | ||
className: '', | ||
src: '' | ||
}; | ||
|
||
const Brand = ({ 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} /> | ||
); | ||
|
||
Brand.propTypes = propTypes; | ||
Brand.defaultProps = defaultProps; | ||
|
||
export default Brand; |
8 changes: 8 additions & 0 deletions
8
packages/patternfly-4/react-core/src/components/Brand/Brand.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
import Brand from './Brand'; | ||
|
||
test('simple brand', () => { | ||
const view = shallow(<Brand alt="brand" />); | ||
expect(view).toMatchSnapshot(); | ||
}); |
9 changes: 9 additions & 0 deletions
9
packages/patternfly-4/react-core/src/components/Brand/__snapshots__/Brand.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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`simple brand 1`] = ` | ||
<img | ||
alt="brand" | ||
className="pf-c-brand" | ||
src="" | ||
/> | ||
`; |
13 changes: 13 additions & 0 deletions
13
packages/patternfly-4/react-core/src/components/Brand/examples/SimpleBrand.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
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 brandImg from './pf_logo.svg'; | ||
|
||
class SimpleBrand extends React.Component { | ||
static title = 'Simple Brand'; | ||
|
||
render() { | ||
return <Brand src={brandImg} alt="Brand Image" />; | ||
} | ||
} | ||
|
||
export default SimpleBrand; |
37 changes: 37 additions & 0 deletions
37
packages/patternfly-4/react-core/src/components/Brand/examples/pf_logo.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 @@ | ||
export { default as Brand } from './Brand'; |
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
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
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