-
Notifications
You must be signed in to change notification settings - Fork 841
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
Add types for EuiEmptyPrompt, EuiCode(Block), EuiCallOut #1010
Merged
spalger
merged 8 commits into
elastic:master
from
spalger:types/EuiEmptyPrompt-EuiCodeBlock-EuiCallOut
Jul 13, 2018
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
f445276
[types] add types for EuiEmptyPrompt
9397296
[types] add types for EuiCode and EuiCodeBlock
042560f
[types] add types for EuiCallOut
93886bf
add note to changelog
ecf2de3
[types/EuiEmptyPrompt] remove HTMLAttributes<> to avoid collision at …
b22189b
[types/EuiEmptyPrompt] re-enable HTMLAttributes, but omit "title" att…
c56ed86
[types/EuiCallOut] omit "title" attribute from HTMLAttributes
5430177
Merge branch 'master' of github.com:elastic/eui into types/EuiEmptyPr…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
/// <reference path="../common.d.ts" /> | ||
/// <reference path="../icon/index.d.ts" /> | ||
|
||
import { SFC, ReactNode, HTMLAttributes } from 'react'; | ||
|
||
declare module '@elastic/eui' { | ||
/** | ||
* EuiCallOut type defs | ||
* | ||
* @see './code.js' | ||
*/ | ||
|
||
type Color = 'primary' | 'success' | 'warning' | 'danger'; | ||
type Size = 's' | 'm'; | ||
|
||
export interface EuiCallOutProps { | ||
title?: ReactNode, | ||
iconType?: IconType, | ||
color?: Color, | ||
size?: Size, | ||
} | ||
|
||
export const EuiCallOut: SFC< | ||
CommonProps & EuiCallOutProps & Omit<HTMLAttributes<HTMLDivElement>, 'title'> | ||
>; | ||
} |
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,57 @@ | ||
/// <reference path="../common.d.ts" /> | ||
|
||
import { SFC, HTMLAttributes } from 'react'; | ||
|
||
declare module '@elastic/eui' { | ||
type FontSize = 's' | 'm' | 'l'; | ||
type PaddingSize = 'none' | 's' | 'm' | 'l'; | ||
|
||
// there isn't a specific type for the <code> element, and MDN | ||
// says that it only supports the HTMLElement interface | ||
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/code | ||
type HTMLCodeElement = HTMLElement | ||
|
||
interface EuiCodeSharedProps { | ||
paddingSize?: PaddingSize; | ||
|
||
/** | ||
* Sets the syntax highlighting for a specific language | ||
* See http://highlightjs.readthedocs.io/en/latest/css-classes-reference.html#language-names-and-aliases | ||
* for options | ||
*/ | ||
language?: string; | ||
|
||
overflowHeight?: number; | ||
fontSize?: FontSize; | ||
transparentBackground?: boolean; | ||
} | ||
|
||
|
||
/** | ||
* EuiCode type defs | ||
* | ||
* @see './code.js' | ||
*/ | ||
|
||
export interface EuiCodeProps extends EuiCodeSharedProps { | ||
inline?: true | ||
} | ||
|
||
export const EuiCode: SFC< | ||
CommonProps & EuiCodeProps & HTMLAttributes<HTMLCodeElement> | ||
>; | ||
|
||
/** | ||
* EuiCodeBlock type defs | ||
* | ||
* @see './code_block.js' | ||
*/ | ||
|
||
export interface EuiCodeBlockProps extends EuiCodeSharedProps { | ||
inline?: false | ||
} | ||
|
||
export const EuiCodeBlock: SFC< | ||
CommonProps & EuiCodeBlockProps & HTMLAttributes<HTMLCodeElement> | ||
>; | ||
} |
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,28 @@ | ||
/// <reference path="../common.d.ts" /> | ||
/// <reference path="../icon/index.d.ts" /> | ||
/// <reference path="../title/index.d.ts" /> | ||
|
||
import { SFC, ReactNode, HTMLAttributes } from 'react'; | ||
|
||
declare module '@elastic/eui' { | ||
/** | ||
* EuiEmptyPrompt type defs | ||
* | ||
* @see './empty_prompt.js' | ||
*/ | ||
|
||
export interface EuiEmptyPromptProps { | ||
iconType?: IconType; | ||
iconColor?: IconColor; | ||
title?: ReactNode; | ||
titleSize?: EuiTitleSize; | ||
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. Hmm, eventually it looks like we'll need to align our naming. Some of these are prefixed and some are not. |
||
body?: ReactNode; | ||
actions?: ReactNode; | ||
} | ||
|
||
export const EuiEmptyPrompt: SFC< | ||
CommonProps & EuiEmptyPromptProps & Omit<HTMLAttributes<HTMLDivElement>, 'title'> | ||
>; | ||
|
||
|
||
} |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Hmm, the
title
prop collides with thetitle
attribute fromHTMLAttributes<HTMLDivElement>
, so TypeScript seems to be requiring that values in that prop meet bothReactNode
andstring
which is weird... Experimenting...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.
Okay, I just removed
HTMLAttributes<HTMLDivElement>
from the prop types signature for now, we can always add specific properties down the road if needed.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.
You can keep using HTMLAttributes and use Omit (defined in common.d.ts) to omit the original title prop
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.
Awesome, I figured there must be a way to do that, couldn't figure it out.