-
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 all commits
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
import classnames from 'classnames'; | ||
import Icon from '../Icon/Icon'; | ||
import PropTypes from 'prop-types'; | ||
import React from 'react'; | ||
import useUniqueId from '../utils/useUniqueId'; | ||
import { BUTTON_OPTIONS, BUTTON_TYPES } from '../utils/constants'; | ||
import 'fundamental-styles/dist/icon.css'; | ||
import 'fundamental-styles/dist/button.css'; | ||
|
||
/** A **Button** allows users to perform an action. The priority of buttons within a page should be considered. | ||
|
@@ -19,12 +19,15 @@ const Button = React.forwardRef(({ | |
disabledMessage, | ||
enabledMessage, | ||
glyph, | ||
iconBeforeText, | ||
iconProps, | ||
selected, | ||
disabled, | ||
typeAttr, | ||
onClick, | ||
children, | ||
className, | ||
textClassName, | ||
...props | ||
}, ref) => { | ||
|
||
|
@@ -34,13 +37,17 @@ const Button = React.forwardRef(({ | |
[`fd-button--${option}`]: !!option, | ||
[`fd-button--${type}`]: !!type, | ||
'fd-button--compact': compact, | ||
[`sap-icon--${glyph}`]: !!glyph, | ||
'is-selected': selected, | ||
'is-disabled': disabled | ||
}, | ||
className | ||
); | ||
|
||
const buttonTextClasses = classnames( | ||
'fd-button__text', | ||
textClassName | ||
); | ||
|
||
const ariaDisabled = props['aria-disabled']; | ||
let disabledInAnyWay = disabled || ariaDisabled; | ||
|
||
|
@@ -76,6 +83,18 @@ const Button = React.forwardRef(({ | |
} | ||
return content; | ||
}; | ||
|
||
const renderIcon = () => { | ||
const content = glyph ? ( | ||
<Icon | ||
{...iconProps} | ||
ariaHidden | ||
glyph={glyph} /> | ||
) : null; | ||
|
||
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. Does it work to just do something like:
} 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. lint complains 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 commentThe reason will be displayed to describe this comment to others. Learn more. Eh, I think it's fine the way you have it |
||
return content; | ||
}; | ||
|
||
return ( | ||
<> | ||
<button | ||
|
@@ -86,7 +105,9 @@ const Button = React.forwardRef(({ | |
ref={ref} | ||
selected={selected} | ||
type={typeAttr}> | ||
{children} | ||
{iconBeforeText && renderIcon()} | ||
{children && <span className={buttonTextClasses}>{children}</span>} | ||
{!iconBeforeText && renderIcon()} | ||
</button> | ||
{renderButtonStateMessage()} | ||
</> | ||
|
@@ -134,10 +155,16 @@ Button.propTypes = { | |
enabledMessage: validateStateTransitionMessage, | ||
/** The icon to include. See the icon page for the list of icons */ | ||
glyph: PropTypes.string, | ||
/** Indicates the importance of the button: 'empahsized' or 'transparent' */ | ||
/** Determines whether the icon should be placed before the text */ | ||
iconBeforeText: PropTypes.bool, | ||
/** Additional props to be spread to the Icon component */ | ||
iconProps: PropTypes.object, | ||
/** Indicates the importance of the button: 'emphasized' or 'transparent' */ | ||
option: PropTypes.oneOf(BUTTON_OPTIONS), | ||
/** Set to **true** to set state of the button to "selected" */ | ||
selected: PropTypes.bool, | ||
/** CSS class(es) to add to the text element */ | ||
textClassName: PropTypes.string, | ||
/** Sets the variation of the component. Primarily used for styling: 'standard', | ||
'positive', | ||
'negative', | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,7 +53,7 @@ export const types = () => ( | |
|
||
types.storyName = 'Types'; | ||
|
||
/** Button can have an icon with text or just and icon. */ | ||
/** Button can have an icon with text or just an icon. Be sure to use an `aria-label` if there is no text. */ | ||
|
||
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. Can we add aria-label to the <Button glyph='alert' option='emphasized' /> in this file. |
||
export const icons = () => ( | ||
<div className='fddocs-container'> | ||
|
@@ -65,7 +65,8 @@ export const icons = () => ( | |
<Button glyph='edit' type='ghost'>Edit</Button> | ||
<Button glyph='warning' type='attention'>Ignore</Button> | ||
<div className='fddocs-container--break' /> | ||
<Button glyph='alert' option='emphasized' /> | ||
<Button aria-label='See warning' glyph='alert' | ||
option='emphasized' /> | ||
<Button aria-label='Add to cart' glyph='cart' /> | ||
<Button aria-label='Filter' glyph='cart' | ||
option='transparent' /> | ||
|
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.
Do all these icons need aria-hidden attributes like we do in widgets?