-
Notifications
You must be signed in to change notification settings - Fork 829
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
Guidelines component #263
Guidelines component #263
Conversation
Gonna set up a quick review meeting for this one. I messed around with it for an hour and played around with throwing it into another page. Likely some easy wins we can do to make it a little more flexible. Easier to run through over a zoom. |
PR has been updated based on the conversation with @elastic/kibana-design |
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.
Nice improvement! I had a few suggestions about code structure and style.
In terms of the presentation of the do's and don'ts how do you feel about either of these options?
I feel like first option is pretty strong. The benefit of doing either one of these is that our code will become much simpler because we won't need to add custom styles for adding borders to the panels.
@@ -0,0 +1,15 @@ | |||
.Guideline { |
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.
Can we lowercase the first letter of all of the classes? e.g. guideline
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 keep getting tripped up by the repetition of "guide" and "guideline". Can we use the word "rule" instead of "guideline" and add back the general "guide" prefix? So we'd end up with components such as:
GuideRule
(with classguideRule
)GuideRuleDescription
(with classguideRuleDescription
)GuideRuleTitle
(with classguideRuleTitle
)- And so on...
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.
Done
.GuidelineExample__panel { | ||
border-bottom-color: $euiColorSuccess; | ||
|
||
+ small { |
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.
Can we use a class instead of an element selector? This will be a little less brittle so the element can change without breaking anything. Also, I'm not sure small
is the appropriate element here, semantically speaking. I think it should just be a regular <p>
. I think it's typically used for small print like attribution, copyrights, and disclaimers.
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.
What about using <figure>
to wrap the whole thing and <figcaption>
for the small text?
@@ -0,0 +1,3 @@ | |||
.euiGuideGuidelineWriting { | |||
|
|||
} |
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.
Can we delete this since it's a no-op?
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.
Done
|
||
if (description) { | ||
descriptionNode = ( | ||
<GuideGuidelineDescription |
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.
Do we need a GuideGuidelineDescription
component? I think it's OK to put <EuiText className="guidelineDescription">
and the other stuff in here instead.
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 left it separate because I think there may be cases where we would want to add the description without the examples.
className, | ||
...rest, | ||
}) => { | ||
const classes = classNames('GuidelineWriting', className); |
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.
This class is a no-op, so can we remove this component and just use <EuiText><p>{children}</p></EuiText>
in the examples?
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 see your point. My thinking was to just make it easy on those who just need a quick example of copywriting. Maybe it can be a helper function inside the writing guidelines instead of it's own component?
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.
This is looking great! I just had a few last minute suggestions.
@@ -0,0 +1,67 @@ | |||
import React from 'react'; |
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 this file needs to be renamed to guide_rule_example.js
.
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.
Or can we just delete it? looks like guide_rule_example.js
already exists.
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, accidentally left that in
<EuiPanel className={panelClasses}> | ||
{children} | ||
</EuiPanel> | ||
<small>{text || typeToSubtitleTextMap[type]}</small> |
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'm OK with this or your figcaption
suggestion as long as we're not using element selectors to style them! 😄
margin-top: $euiSizeXXL * -2; | ||
} | ||
|
||
.euiTitle + &.guideRule--hasHeading { |
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 this confuses me. What's the use case in which this selector applies? Can I see a screenshot?
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.
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.
But then you would have to know you need a space and have to know what spacer size.
This way, it always adds the tightens up space before the example row only if it directly follows a title.
I did forget to change the general .euiTitle selector to the GuideRule specific ones so the selector is now .guideRule__title + &.guideRule--hasHeading
.
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.
Oh good! That works too.
{children} | ||
</div> | ||
); | ||
} |
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.
We can make this a little more efficient by conditionally assigning the component type instead of the entire component:
const ChildrenComponent = panel ? EuiPanel : 'div';
const childrenNode = (
<ChildrenComponent className="guideRule__example__panel">
{children}
</ChildrenComponent>
);
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.
Ahh yes!
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.
Could I take it further and just put the
<ChildrenComponent className="guideRule__example__panel">
{children}
</ChildrenComponent>
directly in the return
?
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.
Good idea!
EuiText, | ||
} from '../../../../src/components'; | ||
|
||
export const GuideRuleWriting = ({ |
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.
Maybe it can be a helper function inside the writing guidelines instead of it's own component?
Sounds good!
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.
Is there an example of one that has been created yet that I can look at?
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 I would just cut and paste the code into the top of guidelines/writing.js
.
Ok, I think everything has been addressed now. Again, this will probably be an evolving component as we start building out more doc pages. |
Oh except that I am still getting the console error:
by trying to use |
04ed762
to
4f23b15
Compare
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.
LGTM! I had one small note.
@@ -30,6 +29,23 @@ import { | |||
|
|||
import makeId from '../../../../src/components/form/form_row/make_id'; | |||
|
|||
export const GuideRuleWriting = ({ |
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.
Can we remove the export
here since it's only used in this example?
|
||
import { | ||
GuideRuleDescription, | ||
} from '../../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.
This causes a circular dependency because components/index.js
also imports this file. So they end up depending on each other. To solve this we just need to change this path to point to the file containing GuideRuleDescription
:
import {
GuideRuleDescription,
} from './guide_rule_description';
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 as soon as I hit comment, I saw it. 😩
Provides descriptions and examples of how to write UI text
Also fixed typos and added don't for contractions
Added more detail and explanations
Added some more don'ts and fixed examples
…y to remove the panel styling from the examples
Also only adding the EuiPanel component if panel=true versus trying to clear out the styles.
ab5f57e
to
92220a7
Compare
This creates a style guide specific component for writing out rows of guidelines.
Basic instance
Includes a top area for a heading and description and two examples (a "do" and a "dont"). Each example takes a
type
and atext
string for a more verbose caption.Leave the
heading
anddescription
props blank if you do not needs these displayed.For simple writing sample examples, use the
GuideGuidelineWriting
componentComplex example
If you don't want to encapsulate the whole example in panel-style container, add the prop
panel={false}
. Then you can use your own panel or any other component.Omitting columns
If you need to have an empty example column, use
<EuiFlexItem />
in place of theGuideGuidelineExample
.Section titles
There is also a
GuideGuidelineTitle
component that will create the correct title component and add the right amount of spacing.