mirror of https://github.com/grafana/grafana
grafana/ui: fix button icon styles (#20084)
Fix spacing and margins in case you use icon only button.pull/20143/head
parent
a5e8e0e291
commit
6dde81d839
@ -1,20 +1,30 @@ |
||||
import React from 'react'; |
||||
import cx from 'classnames'; |
||||
import { css } from 'emotion'; |
||||
import { stylesFactory } from '../../themes'; |
||||
|
||||
const getStyles = stylesFactory(() => ({ |
||||
content: css` |
||||
white-space: nowrap; |
||||
`,
|
||||
})); |
||||
|
||||
type Props = { |
||||
icon?: string; |
||||
className: string; |
||||
iconClassName: string; |
||||
className?: string; |
||||
iconClassName?: string; |
||||
children: React.ReactNode; |
||||
}; |
||||
export function ButtonContent(props: Props) { |
||||
const { icon, className, iconClassName, children } = props; |
||||
const styles = getStyles(); |
||||
return icon ? ( |
||||
<span className={className}> |
||||
<span className={cx(styles.content, className)}> |
||||
<i className={cx([icon, iconClassName])} /> |
||||
|
||||
<span>{children}</span> |
||||
</span> |
||||
) : ( |
||||
<>{children}</> |
||||
<span className={styles.content}>{children}</span> |
||||
); |
||||
} |
||||
|
@ -1,5 +1,5 @@ |
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP |
||||
|
||||
exports[`Button renders correct html 1`] = `"<button class=\\"css-pdywgc-button\\" type=\\"button\\"><span class=\\"css-1dxly9g-button-icon-wrap\\"><i class=\\"fa fa-plus css-iu6xgj-button-icon\\"></i><span>Click me</span></span></button>"`; |
||||
exports[`Button renders correct html 1`] = `"<button class=\\"css-1ffx2x7-button\\" type=\\"button\\"><span class=\\"css-16tmax3 css-1dxly9g-button-icon-wrap\\"><i class=\\"fa fa-plus\\"></i> <span>Click me</span></span></button>"`; |
||||
|
||||
exports[`LinkButton renders correct html 1`] = `"<a class=\\"css-pdywgc-button\\"><span class=\\"css-1dxly9g-button-icon-wrap\\"><i class=\\"fa fa-plus css-iu6xgj-button-icon\\"></i><span>Click me</span></span></a>"`; |
||||
exports[`LinkButton renders correct html 1`] = `"<a class=\\"css-1ffx2x7-button\\"><span class=\\"css-16tmax3 css-1dxly9g-button-icon-wrap\\"><i class=\\"fa fa-plus\\"></i> <span>Click me</span></span></a>"`; |
||||
|
Loading…
Reference in new issue