Skip to content

Commit

Permalink
feat(feature): added packages from av-react to public
Browse files Browse the repository at this point in the history
  • Loading branch information
availity-bot committed Jan 31, 2019
1 parent afa8b25 commit 2c32cf3
Show file tree
Hide file tree
Showing 118 changed files with 8,620 additions and 16,656 deletions.
44 changes: 44 additions & 0 deletions packages/app-icon/AppIcon.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import React from 'react';
import PropTypes from 'prop-types';

function AppIcon({
tag: Tag,
color,
size,
branded,
className,
children,
...props
}) {
const classname = [
className,
'app-icon',
branded ? `app-icon-branded-${color}` : `app-icon-${color}`,
size && `app-icon-${size}`,
]
.filter(a => a)
.join(' ');

return (
<Tag {...props} className={classname}>
{children}
{branded && <span className="caret" />}
</Tag>
);
}

AppIcon.propTypes = {
color: PropTypes.string,
size: PropTypes.string,
branded: PropTypes.bool,
className: PropTypes.string,
tag: PropTypes.oneOfType([PropTypes.func, PropTypes.string]),
children: PropTypes.node,
};

AppIcon.defaultProps = {
tag: 'span',
color: 'black',
};

export default AppIcon;
41 changes: 41 additions & 0 deletions packages/app-icon/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# @availity/app-icon

> Availity UI Kit application icon react component.
## Installation

```bash
npm install @availity/app-icon --save
```

### Usage

```javascript
import React from 'react';
import AppIcon from '@availity/app-icon';
// ...
<AppIcon>
{/* ... */}
</AppIcon>
// ...
```

#### AppIcon (Default export)
A component which outputs one of the "App Icons" from [Availity UI Kit](http://availity.github.io/availity-uikit/v3/components#App-Icons)

##### Props

- **`size`**: string, optional. Potential values: `"lg"`, `"xl"`
- **`color`**: string, optional. Potential values: `"black"`, `"blue"`, `"green"`, `"orange"`. Default value: `"black"`
- **`branded`**: boolean, optional. Triggers "branded" styles.
- All other props will be passed through; `className` will be merged.

##### Usage

```javascript
import React from 'react';
import AppIcon from '@availity/app-icon';
// ...
<AppIcon title="Payer Space" color="green" branded size="xl">PS</AppIcon>
// ...
```
3 changes: 3 additions & 0 deletions packages/app-icon/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import AppIcon from './AppIcon';

export default AppIcon;
30 changes: 30 additions & 0 deletions packages/app-icon/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"name": "@availity/app-icon",
"version": "1.0.0",
"author": "Evan Sharp <evan.sharp@availity.com>",
"description": "Availity UI Kit application icon react component.",
"main": "index.js",
"keywords": [
"react",
"availity"
],
"repository": {
"type": "git",
"url": "https://git.availity.com/projects/PUI/repos/av-react"
},
"bugs": {
"url": "https://jira.availity.com/projects/PLT"
},
"license": "UNLICENSED",
"publishConfig": {
"registry": "https://artifactory.availity.com/artifactory/api/npm/local-npm/"
},
"devDependencies": {
"prop-types": "^15.5.8",
"react": "^16.3.0",
"react-dom": "^16.3.0"
},
"peerDependencies": {
"react": "^16.3.0"
}
}
53 changes: 53 additions & 0 deletions packages/app-icon/tests/AppIcon.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import React from 'react';
import renderer from 'react-test-renderer';
import AppIcon from '..';

describe('AppIcon', () => {
test('should render', () => {
const component = renderer.create(<AppIcon />);
const json = component.toJSON();
expect(json).toMatchSnapshot();
});

test('should render color', () => {
const component = renderer.create(<AppIcon color="green" />);
const json = component.toJSON();
expect(json).toMatchSnapshot();
});

test('should render size', () => {
const component = renderer.create(<AppIcon size="lg" />);
const json = component.toJSON();
expect(json).toMatchSnapshot();
});

test('should render children', () => {
const component = renderer.create(<AppIcon>AI</AppIcon>);
const json = component.toJSON();
expect(json).toMatchSnapshot();
});

test('should render branded', () => {
const component = renderer.create(<AppIcon branded />);
const json = component.toJSON();
expect(json).toMatchSnapshot();
});

test('should render additional classNames', () => {
const component = renderer.create(<AppIcon className="and-more" />);
const json = component.toJSON();
expect(json).toMatchSnapshot();
});

test('should render additional attributes', () => {
const component = renderer.create(<AppIcon title="Availity Icon" />);
const json = component.toJSON();
expect(json).toMatchSnapshot();
});

test('should render custom tags', () => {
const component = renderer.create(<AppIcon tag="i" />);
const json = component.toJSON();
expect(json).toMatchSnapshot();
});
});
56 changes: 56 additions & 0 deletions packages/app-icon/tests/__snapshots__/AppIcon.test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`AppIcon should render 1`] = `
<span
className="app-icon app-icon-black"
/>
`;

exports[`AppIcon should render additional attributes 1`] = `
<span
className="app-icon app-icon-black"
title="Availity Icon"
/>
`;

exports[`AppIcon should render additional classNames 1`] = `
<span
className="and-more app-icon app-icon-black"
/>
`;

exports[`AppIcon should render branded 1`] = `
<span
className="app-icon app-icon-branded-black"
>
<span
className="caret"
/>
</span>
`;

exports[`AppIcon should render children 1`] = `
<span
className="app-icon app-icon-black"
>
AI
</span>
`;

exports[`AppIcon should render color 1`] = `
<span
className="app-icon app-icon-green"
/>
`;

exports[`AppIcon should render custom tags 1`] = `
<i
className="app-icon app-icon-black"
/>
`;

exports[`AppIcon should render size 1`] = `
<span
className="app-icon app-icon-black app-icon-lg"
/>
`;
Loading

0 comments on commit 2c32cf3

Please sign in to comment.