Skip to content

Commit

Permalink
feat(pf4-brand): introduce brand component (patternfly#633)
Browse files Browse the repository at this point in the history
affects: @patternfly/react-core, @patternfly/react-docs
  • Loading branch information
amarie401 authored and tlabaj committed Sep 19, 2018
1 parent 69a6aa2 commit 53ed4d1
Show file tree
Hide file tree
Showing 14 changed files with 125 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@ import { css } from '@patternfly/react-styles';
import PropTypes from 'prop-types';

const propTypes = {
/** Additional classes added to the Avatar. */
className: PropTypes.string,
/** Attribute that specifies the URL of the image for the Avatar. */
src: PropTypes.string,
/** Attribute that specifies the alt text of the image for the Avatar. */
alt: PropTypes.string.isRequired
};

const defaultProps = {
/** Additional classes added to the Avatar. */
className: '',
/** Attribute that specifies the URL of the image for the Avatar. */
src: ''
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react';
import { Avatar } from '@patternfly/react-core';
import avatarImg from '../../../../../react-docs/src/assets/img_avatar.png';
import avatarImg from './img_avatar.png';

class SimpleAvatar extends React.Component {
static title = 'Simple Avatar';
Expand Down
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;
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 packages/patternfly-4/react-core/src/components/Brand/Brand.js
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;
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();
});
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=""
/>
`;
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;
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
@@ -0,0 +1 @@
export { default as Brand } from './Brand';
1 change: 1 addition & 0 deletions packages/patternfly-4/react-core/src/components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@ export * from './TextArea';
export * from './Dropdown';
export * from './Select';
export * from './Avatar';
export * from './Brand';
2 changes: 1 addition & 1 deletion packages/patternfly-4/react-tokens/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"build": "node build/generateTokens.js"
},
"devDependencies": {
"@patternfly/patternfly-next": "1.0.43",
"@patternfly/patternfly-next": "1.0.44",
"css": "^2.2.3",
"fs-extra": "^6.0.1",
"glob": "^7.1.2"
Expand Down
4 changes: 4 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,10 @@
version "1.0.43"
resolved "https://registry.yarnpkg.com/@patternfly/patternfly-next/-/patternfly-next-1.0.43.tgz#64498a29c690b1713fef7e07d0eac701ef064c9a"

"@patternfly/patternfly-next@1.0.44":
version "1.0.44"
resolved "https://registry.yarnpkg.com/@patternfly/patternfly-next/-/patternfly-next-1.0.44.tgz#556a48dcfbb24a01f65363656c725a35a731bb0c"

"@samverschueren/stream-to-observable@^0.3.0":
version "0.3.0"
resolved "https://registry.yarnpkg.com/@samverschueren/stream-to-observable/-/stream-to-observable-0.3.0.tgz#ecdf48d532c58ea477acfcab80348424f8d0662f"
Expand Down

0 comments on commit 53ed4d1

Please sign in to comment.