-
Notifications
You must be signed in to change notification settings - Fork 843
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added EuiTextAlign - Implementing in the same way as EuiTextColor
- Loading branch information
cchaos
committed
Apr 18, 2018
1 parent
7331b56
commit 87de5a2
Showing
10 changed files
with
158 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import React from 'react'; | ||
|
||
import { | ||
EuiText, | ||
EuiTextAlign, | ||
EuiCode, | ||
EuiSpacer, | ||
} from '../../../../src/components'; | ||
|
||
export default () => ( | ||
<div> | ||
<EuiText> | ||
<EuiTextAlign textAlign="left"> | ||
<p>Left aligned paragraph.</p> | ||
</EuiTextAlign> | ||
<EuiTextAlign textAlign="center"> | ||
<p>Center aligned paragraph.</p> | ||
</EuiTextAlign> | ||
<EuiTextAlign textAlign="right"> | ||
<p>Right aligned paragraph.</p> | ||
</EuiTextAlign> | ||
</EuiText> | ||
<EuiSpacer /> | ||
<EuiText textAlign="center"> | ||
<p>You can also pass alignment to <EuiCode>EuiText</EuiCode> directly with a prop</p> | ||
</EuiText> | ||
<EuiText textAlign="center" color="secondary"> | ||
<p>And in conjuction with coloring.</p> | ||
</EuiText> | ||
</div> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -285,4 +285,5 @@ export { | |
export { | ||
EuiText, | ||
EuiTextColor, | ||
EuiTextAlign, | ||
} from './text'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`EuiTextAlign is rendered 1`] = ` | ||
<div | ||
aria-label="aria-label" | ||
class="euiTextAlign euiTextAlign--left testClass1 testClass2" | ||
data-test-subj="test subject string" | ||
/> | ||
`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
@import 'text'; | ||
@import 'text_color'; | ||
@import 'text_align'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
.euiTextAlign--left { | ||
text-align: left; | ||
} | ||
|
||
.euiTextAlign--right { | ||
text-align: right; | ||
} | ||
|
||
.euiTextAlign--center { | ||
text-align: center; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,3 +5,7 @@ export { | |
export { | ||
EuiTextColor, | ||
} from './text_color'; | ||
|
||
export { | ||
EuiTextAlign, | ||
} from './text_align'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import classNames from 'classnames'; | ||
|
||
export const alignmentToClassNameMap = { | ||
'left': 'euiTextAlign--left', | ||
'right': 'euiTextAlign--right', | ||
'center': 'euiTextAlign--center', | ||
}; | ||
|
||
export const ALIGNMENTS = Object.keys(alignmentToClassNameMap); | ||
|
||
export const EuiTextAlign = ({ | ||
children, | ||
className, | ||
textAlign, | ||
...rest, | ||
}) => { | ||
const classes = classNames( | ||
'euiTextAlign', | ||
alignmentToClassNameMap[textAlign], | ||
className | ||
); | ||
|
||
return ( | ||
<div | ||
className={classes} | ||
{...rest} | ||
> | ||
{children} | ||
</div> | ||
); | ||
}; | ||
|
||
EuiTextAlign.propTypes = { | ||
children: PropTypes.node, | ||
className: PropTypes.string, | ||
textAlign: PropTypes.oneOf(ALIGNMENTS), | ||
}; | ||
|
||
EuiTextAlign.defaultProps = { | ||
textAlign: 'left', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import React from 'react'; | ||
import { render } from 'enzyme'; | ||
import { requiredProps } from '../../test'; | ||
|
||
import { EuiTextAlign } from './text_align'; | ||
|
||
describe('EuiTextAlign', () => { | ||
test('is rendered', () => { | ||
const component = render( | ||
<EuiTextAlign {...requiredProps} /> | ||
); | ||
|
||
expect(component) | ||
.toMatchSnapshot(); | ||
}); | ||
}); |