@availity/app-icon
Advanced tools
Comparing version 1.1.4 to 1.2.0
@@ -7,2 +7,4 @@ export interface AppIconProps { | ||
className?: string; | ||
src?: string; | ||
alt?: string; | ||
children?: any; | ||
@@ -9,0 +11,0 @@ } |
@@ -8,2 +8,4 @@ import React from 'react'; | ||
size, | ||
src: image, | ||
alt, | ||
branded, | ||
@@ -19,2 +21,3 @@ className, | ||
size && `app-icon-${size}`, | ||
image && 'border-0', | ||
] | ||
@@ -26,3 +29,7 @@ .filter(a => a) | ||
<Tag {...props} className={classname}> | ||
{children} | ||
{image ? ( | ||
<img className="w-100 h-100 align-baseline" src={image} alt={alt} /> | ||
) : ( | ||
children | ||
)} | ||
{branded && <span className="caret" />} | ||
@@ -40,2 +47,14 @@ </Tag> | ||
children: PropTypes.node, | ||
src: PropTypes.string, | ||
alt: (props, propName) => { | ||
if ( | ||
(props.src !== undefined && | ||
props.src !== null && | ||
props[propName] === undefined) || | ||
props[propName] === null | ||
) { | ||
return new Error('AppIcon requires and alt property for image src.'); | ||
} | ||
return null; | ||
}, | ||
}; | ||
@@ -42,0 +61,0 @@ |
@@ -6,2 +6,13 @@ # Change Log | ||
# [1.2.0](https://github.com/Availity/availity-react/compare/@availity/app-icon@1.1.4...@availity/app-icon@1.2.0) (2019-03-26) | ||
### Features | ||
* **app-icon:** added image src and alt properties to app-icon ([a73452a](https://github.com/Availity/availity-react/commit/a73452a)) | ||
## [1.1.4](https://github.com/Availity/availity-react/compare/@availity/app-icon@1.1.2...@availity/app-icon@1.1.4) (2019-03-04) | ||
@@ -8,0 +19,0 @@ |
{ | ||
"name": "@availity/app-icon", | ||
"version": "1.1.4", | ||
"version": "1.2.0", | ||
"author": "Evan Sharp <evan.sharp@availity.com>", | ||
@@ -30,3 +30,3 @@ "description": "Availity UI Kit application icon react component.", | ||
}, | ||
"gitHead": "9cfabd8f3e43ce49669337b93e13246f524276c1" | ||
"gitHead": "4d1b0b8fdd7fd0edb45ee04d0977d0bf06f88015" | ||
} |
@@ -31,2 +31,4 @@ # @availity/app-icon | ||
- **`branded`**: boolean, optional. Triggers "branded" styles. | ||
- **`src`**: string, optional. If image source is provided will render this instead of children. | ||
- **`alt`**: string, required for `src` prop. the alt property for your image source | ||
- All other props will be passed through; `className` will be merged. | ||
@@ -33,0 +35,0 @@ |
@@ -62,2 +62,10 @@ import React from 'react'; | ||
}); | ||
test('should render with image', () => { | ||
const { container } = render( | ||
<AppIcon src="/path-to-some-image" alt="icon" /> | ||
); | ||
const image = container.querySelectorAll('img')[0]; | ||
expect(image.src).toEqual('http://localhost/path-to-some-image'); | ||
}); | ||
}); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
10016
133
43