-
Notifications
You must be signed in to change notification settings - Fork 78
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
feat: update fundamental-styles to 0.12.0-rc.44 #1203
Changes from 1 commit
dbe76ce
f611682
9ddc4e0
c5d9a8b
dd52ab2
b0a88e1
9552d7e
286f6ac
fdfcc50
360c4f9
d3f82f3
bb64844
410e943
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,7 +8,7 @@ import 'fundamental-styles/dist/icon.css'; | |
and focus, and for fun. Icons can be used adaptively if desired, but at | ||
this point they are used more as visual elements within other | ||
components. */ | ||
const Icon = React.forwardRef(({ glyph, size, className, ...props }, ref) => { | ||
const Icon = React.forwardRef(({ ariaHidden, ariaLabel, glyph, size, className, isInButton, ...props }, ref) => { | ||
|
||
const iconClasses = classnames( | ||
{ | ||
|
@@ -22,9 +22,13 @@ const Icon = React.forwardRef(({ glyph, size, className, ...props }, ref) => { | |
style = { fontSize: ICON_SIZES[size] }; | ||
} | ||
|
||
const Tag = isInButton ? 'i' : 'span'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was hesitant to use the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. After the discussion this morning, I think they're in the process of moving all icons to their own We can probably just go ahead and use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 👍 If we could use the |
||
|
||
return ( | ||
<span | ||
<Tag | ||
{...props} | ||
aria-hidden={ariaHidden} | ||
aria-label={ariaLabel} | ||
className={iconClasses} | ||
ref={ref} | ||
style={style} /> | ||
|
@@ -36,8 +40,22 @@ Icon.displayName = 'Icon'; | |
Icon.propTypes = { | ||
/** The icon to include. See the icon page for the list of icons */ | ||
glyph: PropTypes.string.isRequired, | ||
/** The value for the `aria-hidden` attribute. Set to `true` when there is already visible text explaining the icon, or the icon is purely for decoration. */ | ||
ariaHidden: PropTypes.bool, | ||
/** Text to describe the icon. The value is placed in the `aria-label` attribute. */ | ||
|
||
ariaLabel: (props) => { | ||
if ( | ||
(!props.ariaHidden && !props.ariaLabel) || | ||
(!props.ariaHidden && typeof props.ariaLabel !== 'string') | ||
) { | ||
return new Error('ariaLabel is required if ariaHidden is false and must be a string'); | ||
} | ||
}, | ||
/** CSS class(es) to add to the element */ | ||
className: PropTypes.string, | ||
/** If the icon is in a button */ | ||
isInButton: PropTypes.bool, | ||
/** Size of the component: 's', 'm', 'l', 'xl' */ | ||
size: PropTypes.oneOf(Object.keys(ICON_SIZES)) | ||
}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it work to just do something like:
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lint complains
Declare only one React component per file
Not sure if it's cleaner to disable it / if we want to 🤷♂️
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Eh, I think it's fine the way you have it