-
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
Adds utility CSS classes to EUI #774
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
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
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,97 @@ | ||
import React from 'react'; | ||
|
||
import { | ||
EuiText, | ||
EuiCode, | ||
EuiSpacer, | ||
EuiIcon, | ||
} from '../../../../src/components'; | ||
|
||
export default () => ( | ||
<EuiText> | ||
|
||
<h4>Text</h4> | ||
|
||
<EuiSpacer /> | ||
|
||
<div className="eui-textLeft"> | ||
<EuiCode>.eui-textLeft</EuiCode> | ||
</div> | ||
|
||
<div className="eui-textCenter"> | ||
<EuiCode>.eui-textCenter</EuiCode> | ||
</div> | ||
<div className="eui-textRight"> | ||
<EuiCode>.eui-textRight</EuiCode> | ||
</div> | ||
|
||
<EuiSpacer /> | ||
|
||
<div style={{ width: 300, padding: 16, background: 'rgba(254, 228, 181, 0.5)' }} className="eui-textNoWrap"> | ||
<EuiCode>.eui-textNoWrap</EuiCode> will force text not to wrap even in small containers. | ||
</div> | ||
|
||
<EuiSpacer /> | ||
|
||
<div style={{ width: 300, padding: 16, background: 'rgba(254, 228, 181, 0.5)' }} className="eui-textBreakAll"> | ||
<EuiCode>.eui-textBreakAll</EuiCode> will break up anything. It is useful for long urls like http://www.hithereimalongurl.com/dave_will_just_ramble_on_in_a_long_sentence_like_this/?ok=cool | ||
</div> | ||
|
||
<EuiSpacer /> | ||
|
||
<div style={{ width: 300, padding: 16, background: 'rgba(254, 228, 181, 0.5)' }} className="eui-textBreakWord"> | ||
<EuiCode>.eui-textBreakWord</EuiCode> will only break up at the end of words. Long urls will still break http://www.hithereimalongurl.com/dave_will_just_ramble_on_in_a_long_sentence_like_this/?ok=cool | ||
</div> | ||
|
||
<EuiSpacer /> | ||
|
||
<div style={{ width: 300, padding: 16, background: 'rgba(254, 228, 181, 0.5)' }} className="eui-textTruncate"> | ||
<EuiCode>.eui-textTruncate</EuiCode> will ellipsis after a certain point. | ||
</div> | ||
|
||
<h4>Vertical alignment</h4> | ||
|
||
<EuiSpacer /> | ||
|
||
<div> | ||
<EuiIcon type="logoElasticStack" size="xxl" className="eui-alignTop" /> | ||
<EuiCode>.eui-alignTop</EuiCode> | ||
</div> | ||
|
||
<EuiSpacer /> | ||
|
||
<div> | ||
<EuiIcon type="logoElasticStack" size="xxl" className="eui-alignMiddle" /> | ||
<EuiCode>.eui-alignMiddle</EuiCode> | ||
</div> | ||
|
||
<EuiSpacer /> | ||
|
||
<div> | ||
<EuiIcon type="logoElasticStack" size="xxl" className="eui-alignBottom" /> | ||
<EuiCode>.eui-alignBottom</EuiCode> | ||
</div> | ||
|
||
<EuiSpacer /> | ||
|
||
<div> | ||
<EuiIcon type="logoElasticStack" size="xxl" className="eui-alignBaseline" /> | ||
<EuiCode>.eui-alignBaseline</EuiCode> | ||
</div> | ||
|
||
<EuiSpacer /> | ||
|
||
<h4>Display</h4> | ||
|
||
<EuiCode className="eui-displayBlock">.eui-displayBlock</EuiCode> | ||
|
||
<EuiSpacer /> | ||
|
||
<EuiCode className="eui-displayInline">.eui-displayInline</EuiCode> | ||
|
||
<EuiSpacer /> | ||
|
||
<EuiCode className="eui-displayInlineBlock">.eui-displayInlineBlock</EuiCode> | ||
|
||
</EuiText> | ||
); |
31 changes: 31 additions & 0 deletions
31
src-docs/src/views/utility_classes/utility_classes_example.js
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 { renderToHtml } from '../../services'; | ||
|
||
import { | ||
GuideSectionTypes, | ||
} from '../../components'; | ||
|
||
import UtilityClasses from './utility_classes'; | ||
const utilityClassesSource = require('!!raw-loader!./utility_classes'); | ||
const utilityClassesHtml = renderToHtml(UtilityClasses); | ||
|
||
export const UtilityClassesExample = { | ||
title: 'CSS utility classes', | ||
sections: [{ | ||
source: [{ | ||
type: GuideSectionTypes.JS, | ||
code: utilityClassesSource, | ||
}, { | ||
type: GuideSectionTypes.HTML, | ||
code: utilityClassesHtml, | ||
}], | ||
text: ( | ||
<p> | ||
The following CSS-only classes are provided as helper utilities. They are | ||
useful for making micro-adjustments to existing React components. | ||
</p> | ||
), | ||
demo: <UtilityClasses />, | ||
}], | ||
}; |
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 @@ | ||
@import 'utility'; |
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,38 @@ | ||
// Vertical alignment | ||
.eui-alignBaseline { vertical-align: baseline !important; } | ||
.eui-alignBottom { vertical-align: bottom !important; } | ||
.eui-alignMiddle { vertical-align: middle !important; } | ||
.eui-alignTop { vertical-align: top !important; } | ||
|
||
// Display | ||
.eui-displayBlock {display: block !important;} | ||
.eui-displayInline {display: inline !important;} | ||
.eui-displayInlineBlock {display: inline-block !important;} | ||
|
||
// Text | ||
.eui-textCenter {text-align: center !important;} | ||
.eui-textLeft {text-align: left !important;} | ||
.eui-textRight {text-align: right !important;} | ||
.eui-textBreakWord {word-break: break-word !important;} | ||
.eui-textBreakAll {word-break: break-all !important;} | ||
.eui-textNoWrap {white-space: nowrap !important;} | ||
.eui-textInheritColor {color: inherit !important;} | ||
|
||
/** | ||
* Text truncation | ||
* | ||
* Prevent text from wrapping onto multiple lines, and truncate with an | ||
* ellipsis. | ||
* | ||
* 1. Ensure that the node has a maximum width after which truncation can | ||
* occur. | ||
* 2. Fix for IE 8/9 if `word-wrap: break-word` is in effect on ancestor | ||
* nodes. | ||
*/ | ||
.eui-textTruncate { | ||
max-width: 100%; /* 1 */ | ||
overflow: hidden !important; | ||
text-overflow: ellipsis !important; | ||
white-space: nowrap !important; | ||
word-wrap: normal !important; /* 2 */ | ||
} |
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.
Why wouldn't they use
EuiTextAlign
for this?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.
They can. I think for a lot of these simple text treatments through really just some quicky classes are more convenient.
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.
Example... Here's a common one...
Dunno. Just think some of these are so common you don't necessarily want to go through the process of importing a component and writing a couple extra lines of wrappers.
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.
Yeah I agree that having those will be nice, but I was just concerned about how far we go with utility classes that duplicate the functionality of components.
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.
Should we just remove the
<EuiTextAlign>
component in favor of these utility classes?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.
I think it's ok to have both. Align gets imported into EuiText so I think we're ok there. Neither are really things that should ever change. I think it's OK to leave it.
I don't think we want many utility classes, and don't think we should take it very far. That's why I wanted to start small.