Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding <span/> and <i/> to tag options #42

Merged
merged 1 commit into from Mar 28, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,4 @@ site/bundle.js
.react-playground
site/build
site/node_modules
.idea
6 changes: 3 additions & 3 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@

declare module "react-icons-kit" {
import * as React from 'react'

export interface IconProp {
icon: any
size?: number | string
tag?: string
style?: React.CSSProperties
className?: string
onClick?: React.MouseEventHandler<HTMLDivElement>
Expand Down Expand Up @@ -40,7 +41,7 @@ declare module "react-icons-kit/typicons"
declare module "react-icons-kit/noto_emoji_regular"

declare module "react-icons-kit/feather"


declare module "react-icons-kit/icomoon/*"

Expand All @@ -67,4 +68,3 @@ declare module "react-icons-kit/typicons/*"
declare module "react-icons-kit/noto_emoji_regular/*"

declare module "react-icons-kit/feather/*"

12 changes: 8 additions & 4 deletions src/Icon.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@ import PropTypes from 'prop-types';
import SvgIcon from './SvgIcon';

export const Icon = (props) => {
const { style, className, icon, size, ...others} = props; //eslint-disable-line
const { style, className, icon, size, tag, ...others} = props; //eslint-disable-line

const Tag = tag;

return (
<div {...others} style={{display: 'inline-block',...style}} className={className}>
<Tag {...others} style={{display: 'inline-block',...style}} className={className}>
<SvgIcon size={props.size} icon={props.icon} title={props.title} />
</div>
</Tag>
);
};

Expand All @@ -23,13 +25,15 @@ export const withBaseIcon = (defaultProps) => props => {

Icon.defaultProps = {
size: 16,
fill: 'currentColor'
fill: 'currentColor',
tag: 'i'
};

Icon.propTypes = {
icon: PropTypes.object.isRequired,
size: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
style: PropTypes.object,
tag: PropTypes.oneOf(['i','span','div']),
className: PropTypes.string
};

Expand Down