Skip to content
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

Closed
wants to merge 15 commits into from
Closed

Conversation

llorca
Copy link
Contributor

@llorca llorca commented Apr 27, 2018

fixes #2416

  • add JS examples for Label and FormGroup

@llorca llorca requested a review from giladgray April 27, 2018 23:19
@blueprint-bot
Copy link

add space between form group label and requiredLabel

Preview: 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>
Copy link
Contributor

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.

Copy link
Contributor Author

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

Copy link
Contributor

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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)

@blueprint-bot
Copy link

change label-text to a strong tag

Preview: documentation | landing | table

@@ -31,6 +31,10 @@ label.#{$ns}-label {
display: block;
margin: 0 0 ($pt-grid-size * 1.5);

strong {
Copy link
Contributor

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.

Copy link
Contributor Author

@llorca llorca Apr 28, 2018

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 👎 ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Copy link
Contributor Author

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!

Copy link
Contributor Author

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
Copy link
Contributor

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>;
Copy link
Contributor

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
Copy link
Contributor

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>;
Copy link
Contributor

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} />,
Copy link
Contributor

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.
Copy link
Contributor

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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2018

@blueprint-bot
Copy link

move css back on top of JS

Preview: documentation | landing | table

@blueprint-bot
Copy link

correct copyright year

Preview: documentation | landing | table

@giladgray
Copy link
Contributor

@llorca test failures because you changed the rendered markup

@blueprint-bot
Copy link

remove strong rule from label css

Preview: documentation | landing | table

@llorca
Copy link
Contributor Author

llorca commented May 4, 2018

would need your help to fix tests, I'm not familiar with how they work

@blueprint-bot
Copy link

make default strong 600 weight

Preview: documentation | landing | table

@blueprint-bot
Copy link

typo

Preview: documentation | landing | table

@blueprint-bot
Copy link

merge conflicts

Preview: documentation | landing | table

Copy link
Contributor

@giladgray giladgray left a 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
Copy link
Contributor

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";
Copy link
Contributor

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> {
Copy link
Contributor

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?

Copy link
Contributor Author

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

Copy link
Contributor

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

@blueprint-bot
Copy link

address comments

Preview: documentation | landing | table

@giladgray
Copy link
Contributor

@llorca tests failing due to added space.

@llorca llorca requested a review from giladgray May 15, 2018 23:59
@blueprint-bot
Copy link

add show/hide required label in form group example

Preview: documentation | landing | table

@llorca
Copy link
Contributor Author

llorca commented May 16, 2018

  • still need to fix tests
  • after working with example options, I’m having second guesses about broadly making all labels bold, but I’d still want it in specific cases, so I want to allow consumers to apply CSS to it. I’m thinking removing <strong></strong> and add a <span> with Classes.LABEL_TEXT like I had originally
    • pros: proper targetable classname, and we can omit the new <span> from the CSS markup (tho it would come for free with the React component)
    • cons: ??

@giladgray
Copy link
Contributor

<strong> seems more than sufficient here: if you want a bold label, simply wrap the label text in a <strong> tag and voila it's perfect.

@llorca
Copy link
Contributor Author

llorca commented May 16, 2018

ok fair!

@llorca llorca changed the title [Forms] Bolder labels [Forms] Add <Label> and <FormGroup> examples May 16, 2018
@blueprint-bot
Copy link

remove all strongs

Preview: 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>;
Copy link
Contributor

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()}
Copy link
Contributor

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 [
[
Copy link
Contributor

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 [
[
Copy link
Contributor

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> {
Copy link
Contributor

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> {
Copy link
Contributor

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

@giladgray
Copy link
Contributor

gonna have to change the code or a test to make this work.

@giladgray
Copy link
Contributor

closing as stale. let's do all this as part of #2460

@giladgray giladgray closed this May 29, 2018
@giladgray giladgray deleted the al/label-bold branch October 14, 2018 17:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[bug] missing space between label and requiredLabel
3 participants