-
Notifications
You must be signed in to change notification settings - Fork 842
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* `EuiTitle` Converted to TS * `EuiTitle` exported `EuiTitleTextTransform` * `EuiTitle` code review fix * `EuiTitle` code review fix * `EuiTitle` fixed exported idents and refactored `EuiTitleProps` * `EuiTitle` fixed exported idents
- Loading branch information
1 parent
149d8c7
commit ce003eb
Showing
12 changed files
with
57 additions
and
89 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
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
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
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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 @@ | ||
export { EuiTitle } from './title'; |
This file was deleted.
Oops, something went wrong.
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,51 @@ | ||
import React, { FunctionComponent, ReactElement } from 'react'; | ||
import classNames from 'classnames'; | ||
import { CommonProps, keysOf } from '../common'; | ||
|
||
const titleSizeToClassNameMap = { | ||
xxxs: 'euiTitle--xxxsmall', | ||
xxs: 'euiTitle--xxsmall', | ||
xs: 'euiTitle--xsmall', | ||
s: 'euiTitle--small', | ||
m: 'euiTitle--medium', | ||
l: 'euiTitle--large', | ||
}; | ||
|
||
export const TITLE_SIZES = keysOf(titleSizeToClassNameMap); | ||
export type EuiTitleSize = keyof typeof titleSizeToClassNameMap; | ||
|
||
const textTransformToClassNameMap = { | ||
uppercase: 'euiTitle--uppercase', | ||
}; | ||
|
||
export const TEXT_TRANSFORM = keysOf(textTransformToClassNameMap); | ||
export type EuiTitleTextTransform = keyof typeof textTransformToClassNameMap; | ||
|
||
export type EuiTitleProps = CommonProps & { | ||
children: ReactElement<any>; | ||
className?: string; | ||
size?: EuiTitleSize; | ||
textTransform?: EuiTitleTextTransform; | ||
}; | ||
|
||
export const EuiTitle: FunctionComponent<EuiTitleProps> = ({ | ||
size = 'm', | ||
children, | ||
className, | ||
textTransform, | ||
...rest | ||
}) => { | ||
const classes = classNames( | ||
'euiTitle', | ||
titleSizeToClassNameMap[size], | ||
textTransform ? textTransformToClassNameMap[textTransform] : undefined, | ||
className | ||
); | ||
|
||
const props = { | ||
className: classes, | ||
...rest, | ||
}; | ||
|
||
return React.cloneElement(children, props); | ||
}; |