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

fix editable text classes #2413

Merged
merged 3 commits into from
Apr 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 15 additions & 14 deletions packages/core/src/components/editable-text/_editable-text.scss
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
inset 0 0 0 1px $pt-divider-black;
}

&.#{$ns}-editable-editing::before {
&.#{$ns}-editable-text-editing::before {
box-shadow: input-transition-shadow($input-shadow-color-focus, true), $input-box-shadow-focus;
background-color: $input-background-color;
}
Expand All @@ -37,16 +37,16 @@

@each $intent, $color in $pt-intent-colors {
&.#{$ns}-intent-#{$intent} {
.#{$ns}-editable-input,
.#{$ns}-editable-content {
.#{$ns}-editable-text-input,
.#{$ns}-editable-text-content {
color: $color;
}

&:hover::before {
box-shadow: input-transition-shadow($color), inset border-shadow(0.4, $color, 1px);
}

&.#{$ns}-editable-editing::before {
&.#{$ns}-editable-text-editing::before {
box-shadow: input-transition-shadow($color, true), $input-box-shadow-focus;
}
}
Expand All @@ -58,7 +58,7 @@
inset 0 0 0 1px $pt-dark-divider-white;
}

&.#{$ns}-editable-editing::before {
&.#{$ns}-editable-text-editing::before {
box-shadow: input-transition-shadow($dark-input-shadow-color-focus, true),
$pt-dark-input-box-shadow;
background-color: $dark-input-background-color;
Expand All @@ -70,24 +70,24 @@

@each $intent, $color in $pt-dark-intent-text-colors {
&.#{$ns}-intent-#{$intent} {
.#{$ns}-editable-content {
.#{$ns}-editable-text-content {
color: $color;
}

&:hover::before {
box-shadow: input-transition-shadow($color), inset border-shadow(0.4, $color, 1px);
}

&.#{$ns}-editable-editing::before {
&.#{$ns}-editable-text-editing::before {
box-shadow: input-transition-shadow($color, true), $pt-dark-input-box-shadow;
}
}
}
}
}

.#{$ns}-editable-input,
.#{$ns}-editable-content {
.#{$ns}-editable-text-input,
.#{$ns}-editable-text-content {
display: inherit;
position: relative;
// inherit and respect parent bounds and text styles
Expand All @@ -102,7 +102,8 @@
resize: none;
}

.#{$ns}-editable-input {
.#{$ns}-editable-text-input {
@include pt-input-placeholder();
// reset browser input styles (we're using an input solely because you can type in it)
border: none;
box-shadow: none;
Expand All @@ -121,21 +122,21 @@
}
}

.#{$ns}-editable-content {
.#{$ns}-editable-text-content {
overflow: hidden;
// magical number to account for slight increase in input width for cursor bar
padding-right: 2px;
text-overflow: ellipsis;
// preserve so trailing whitespace is included in scrollWidth
white-space: pre;

.#{$ns}-editable-editing > & {
.#{$ns}-editable-text-editing > & {
position: absolute;
left: 0;
visibility: hidden;
}

.#{$ns}-editable-placeholder > & {
.#{$ns}-editable-text-placeholder > & {
color: $input-placeholder-color;

.#{$ns}-dark & {
Expand All @@ -147,7 +148,7 @@
.#{$ns}-editable-text.#{$ns}-multiline {
display: block;

.#{$ns}-editable-content {
.#{$ns}-editable-text-content {
overflow: auto;
white-space: pre-wrap;
word-wrap: break-word;
Expand Down
3 changes: 2 additions & 1 deletion packages/core/src/components/editable-text/editableText.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ export class EditableText extends AbstractPureComponent<IEditableTextProps, IEdi
};

private maybeRenderInput(value: string) {
const { maxLength, multiline } = this.props;
const { maxLength, multiline, placeholder } = this.props;
if (!this.state.isEditing) {
return undefined;
}
Expand All @@ -288,6 +288,7 @@ export class EditableText extends AbstractPureComponent<IEditableTextProps, IEdi
onBlur: this.toggleEditing,
onChange: this.handleTextChange,
onKeyDown: this.handleKeyEvent,
placeholder,
ref: this.refHandlers.input,
style: {
height: this.state.inputHeight,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export class EditableTextExample extends BaseExample<IEditableTextExampleState>
maxLines={12}
minLines={3}
multiline={true}
placeholder="Edit report... (controlled)"
placeholder="Edit report... (controlled, multiline)"
selectAllOnFocus={this.state.selectAllOnFocus}
confirmOnEnterKey={this.state.confirmOnEnterKey}
value={this.state.report}
Expand Down Expand Up @@ -86,12 +86,9 @@ export class EditableTextExample extends BaseExample<IEditableTextExampleState>
key="focus"
onChange={this.toggleSelectAll}
/>,
<Switch
checked={this.state.confirmOnEnterKey}
label="Swap keypress for confirm and newline (multiline only)"
key="swap"
onChange={this.toggleSwap}
/>,
<Switch checked={this.state.confirmOnEnterKey} key="swap" onChange={this.toggleSwap}>
Swap keypress for confirm and newline<br />(multiline only)
</Switch>,
],
];
}
Expand Down