-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
[Forms] Add <Label> and <FormGroup> examples #2433
Conversation
add space between form group label and requiredLabelPreview: documentation | landing | table |
@@ -10,7 +10,7 @@ Form groups | |||
Markup: | |||
<div class="#{$ns}-form-group"> | |||
<label class="#{$ns}-label" for="example-form-group-input-a"> | |||
Label A | |||
<span class="#{$ns}-label-text">Label A</span> |
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 not just use <strong>
tags if all you want is bold? it's both semantic and requires no additional styles or 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.
cause if we change this in the future, we'll also have to change the tag. poor maintanability
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 that tag isn't going anywhere! it's the semantic browser way of saying "make this text stronger," which is exactly what you're trying to do here.
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.
please try it. i'm quite confident it'll work beautifully and we won't have to add another -text
class for one style rule.
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 I meant is that I don't like tying a visual to a specific tag. if in the future I want to get rid of bold and do another visual style, I'll have to change the tag because <strong>
will no longer make sense.
did it anyway, kind of a bummer tho cause I still need to override the font-weight
of the <strong>
(default is 700, we want 600)
change label-text to a strong tagPreview: documentation | landing | table |
@@ -31,6 +31,10 @@ label.#{$ns}-label { | |||
display: block; | |||
margin: 0 0 ($pt-grid-size * 1.5); | |||
|
|||
strong { |
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 does not belong here. 1) it should already be true. 2) if not, it should be applied such that all strong
tags look the same in blueprint.
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.
so 1) not true yet 2) not that simple. the boldness is a function of the font size.
since 600 is the most common "bold" weight for 14px text (our default UI font size), I suppose it's fair to default <strong>
to 600 weight. I can then remove this rule, 👍 or 👎 ?
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.
sounds good, I'll address as soon as I can!
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!
@@ -4,6 +4,17 @@ Form groups support more complex form controls than [simple labels](#core/compon | |||
such as [control groups](#core/components/forms/control-group) or [`NumericInput`](#core/components/forms/numeric-input). | |||
They also support additional helper text to aid with user navigation. | |||
|
|||
@reactExample FormGroupExample | |||
|
|||
@## JavaScript API |
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're still in the habit of CSS API appearing before JS API so there's no good reason to move only this one.
@@ -54,14 +54,14 @@ export class FormGroup extends React.PureComponent<IFormGroupProps, {}> { | |||
* | |||
* Defaults to `<span class={Classes.TEXT_MUTED}>(required)</span>`. | |||
*/ | |||
public static DEFAULT_REQUIRED_CONTENT = <span className={Classes.TEXT_MUTED}>(required)</span>; | |||
public static DEFAULT_REQUIRED_CONTENT = <span className={Classes.TEXT_MUTED}> (required)</span>; |
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 doesn't fix the issue if the user supplies their own required label. instead add {" "}
in the JSX itself between the two elements (at the end of line 64).
|
||
@reactExample LabelExample | ||
|
||
@## JavaScript API |
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.
again with the moving JS before CSS
@@ -87,7 +87,7 @@ export class FormGroup extends React.PureComponent<IFormGroupProps, {}> { | |||
|
|||
private maybeRenderRequiredLabel() { | |||
const { requiredLabel } = this.props; | |||
return requiredLabel === true ? FormGroup.DEFAULT_REQUIRED_CONTENT : requiredLabel; | |||
return requiredLabel === true ? FormGroup.DEFAULT_REQUIRED_CONTENT : <span> {requiredLabel}</span>; |
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.
see comment above
checked={helperText} | ||
onChange={this.handleHelperTextChange} | ||
/>, | ||
<Switch key="disabled" label="Disabled" checked={disabled} onChange={this.handleDisabledChange} />, |
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.
put this switch first please (alph)
@@ -0,0 +1,61 @@ | |||
/* | |||
* Copyright 2016 Palantir Technologies, Inc. All rights reserved. |
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.
2018
@@ -0,0 +1,62 @@ | |||
/* | |||
* Copyright 2016 Palantir Technologies, Inc. All rights reserved. |
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.
2018
move css back on top of JSPreview: documentation | landing | table |
correct copyright yearPreview: documentation | landing | table |
@llorca test failures because you changed the rendered markup |
remove strong rule from label cssPreview: documentation | landing | table |
would need your help to fix tests, I'm not familiar with how they work |
make default strong 600 weightPreview: documentation | landing | table |
typoPreview: documentation | landing | table |
merge conflictsPreview: documentation | landing | table |
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 PR needs some more thought given #2460
@@ -77,6 +77,29 @@ label.#{$ns}-label { | |||
Disabled labels | |||
|
|||
Markup: | |||
<<<<<<< HEAD |
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.
merge conflict
inline: false, | ||
}; | ||
|
||
protected className = "docs-label-example"; |
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.
these are not necessary. let's only add them when required for custom styles
inline: boolean; | ||
} | ||
|
||
export class LabelExample extends BaseExample<ILabelExampleState> { |
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.
given #2460, do we really want to add a Label
example if we're gonna kill it for FormGroup
soon?
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'd say it doesn't hurt to have one for now, helps with testing and comparing with FormGroup
. will be easy enough to remove it if we really kill Label
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.
rewrite to use new Example
component
address commentsPreview: documentation | landing | table |
@llorca tests failing due to added space. |
add show/hide required label in form group examplePreview: documentation | landing | table |
|
|
ok fair! |
remove all strongsPreview: documentation | landing | table |
return requiredLabel === true ? FormGroup.DEFAULT_REQUIRED_CONTENT : requiredLabel; | ||
if (requiredLabel !== false) { | ||
const label = requiredLabel === true ? FormGroup.DEFAULT_REQUIRED_CONTENT : requiredLabel; | ||
return <span className={Classes.TEXT_MUTED}> {label}</span>; |
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 not the correct place to add the space, and it's causing the tests to fail. please remove.
return ( | ||
<div className={this.getClassName()}> | ||
<div className={classes}> | ||
<label className={Classes.LABEL} htmlFor={labelFor}> | ||
{label} | ||
{this.maybeRenderRequiredLabel()} |
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.
better to add a space between the two elements here, or via margin in CSS. {label}{" "}{this...}
protected renderOptions() { | ||
const { disabled, helperText, inline, requiredLabel } = this.state; | ||
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.
fragment!!!
protected renderOptions() { | ||
const { disabled, helperText, inline } = this.state; | ||
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.
fragment!!!
requiredLabel: boolean; | ||
} | ||
|
||
export class FormGroupExample extends BaseExample<IFormGroupExampleState> { |
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.
rewrite for new example syntax
inline: boolean; | ||
} | ||
|
||
export class LabelExample extends BaseExample<ILabelExampleState> { |
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.
rewrite to use new Example
component
gonna have to change the code or a test to make this work. |
closing as stale. let's do all this as part of #2460 |
fixes #2416
Label
andFormGroup