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

[Tag] Improve outline behavior #2428

Merged
merged 10 commits into from
May 16, 2018
Merged
Show file tree
Hide file tree
Changes from 5 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
2 changes: 2 additions & 0 deletions packages/core/src/common/_color-aliases.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ $pt-intent-danger: $red3 !default;
$pt-app-background-color: $light-gray5 !default;
$pt-dark-app-background-color: $dark-gray3 !default;

$pt-outline-color: rgba($blue3, 0.6);

$pt-text-color: $dark-gray1 !default;
$pt-text-color-muted: $gray1 !default;
$pt-text-color-disabled: rgba($pt-text-color-muted, 0.5) !default;
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/common/_mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ $pt-dark-intent-text-colors: (
}

@mixin focus-outline($offset: 2px) {
outline: rgba($blue3, 0.5) auto 2px;
outline: $pt-outline-color auto 2px;
outline-offset: $offset;
-moz-outline-radius: 6px;
}
Expand Down
37 changes: 23 additions & 14 deletions packages/core/src/components/tag-input/_tag-input.scss
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@
@import "../forms/common";
@import "../tag/common";

$ti-padding: ($pt-input-height - $tag-height) / 2;
$tag-input-padding: ($pt-input-height - $tag-height) / 2;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

was a bit confused by the namespace look of $ti so named this more classicly... if you feel strongly, I can revert back, but this seems more legible to me


$ti-icon-padding: ($pt-input-height - $pt-icon-size-standard) / 2;
$ti-icon-padding-large: ($pt-input-height-large - $pt-icon-size-large) / 2;
$tag-input-icon-padding: ($pt-input-height - $pt-icon-size-standard) / 2;
$tag-input-icon-padding-large: ($pt-input-height-large - $pt-icon-size-large) / 2;
Copy link
Contributor

Choose a reason for hiding this comment

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

can you add !default to all these (surviving) vars please?


$tag-input-outline-color: $pt-outline-color;
Copy link
Contributor

@giladgray giladgray May 8, 2018

Choose a reason for hiding this comment

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

remove this alias, use original name directly also unused, please delete.

$tag-input-outline-offset: 1px;
$tag-input-outline-size: 2px;
Copy link
Contributor

Choose a reason for hiding this comment

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

these two vars are unused; please remove


.#{$ns}-tag-input {
@include pt-flex-container(row, $fill: ".#{$ns}-tag-input-values");
Expand All @@ -17,34 +21,39 @@ $ti-icon-padding-large: ($pt-input-height-large - $pt-icon-size-large) / 2;
height: auto;
min-height: $pt-input-height;
padding-right: 0;
padding-left: $ti-padding;
padding-left: $tag-input-padding;

.#{$ns}-tag-input-icon {
// margins to center icon in one-line input
margin-top: $ti-icon-padding;
margin-right: $ti-icon-padding;
margin-left: $ti-icon-padding - $ti-padding;
margin-top: $tag-input-icon-padding;
margin-right: $tag-input-icon-padding;
margin-left: $tag-input-icon-padding - $tag-input-padding;
color: $pt-icon-color;
}

.#{$ns}-tag-input-values {
@include pt-flex-container(row, $ti-padding);
@include pt-flex-container(row, $tag-input-padding);
flex-wrap: wrap;
align-items: center;
// fill vertical height
align-self: stretch;
margin-top: $ti-padding;
margin-right: $ti-icon-padding;
margin-top: $tag-input-padding;
margin-right: $tag-input-icon-padding;

> * {
margin-bottom: $ti-padding;
margin-bottom: $tag-input-padding;
}
}

.#{$ns}-tag {
position: relative;
Copy link
Contributor

Choose a reason for hiding this comment

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

don't think this chance is necessary. leftover from previous attempt?

// NOTE: in order to wrap long words, you must set explicit width on TagInput,
// or use .#{$ns}-fill CSS class modifier.
overflow-wrap: break-word;

&.#{$ns}-active {
@include focus-outline(0);
Copy link
Contributor

Choose a reason for hiding this comment

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

i kinda think we want to adjust outline offset on all tags, not just in tag inputs:

image
(note how the outline touches the neighboring tags)

image

so this change should move back to core tag styles.

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 don't think that's the right move, but did it anyway, Not sure what to do with outline design in general

}
}

.#{$ns}-input-ghost {
Expand All @@ -71,13 +80,13 @@ $ti-icon-padding-large: ($pt-input-height-large - $pt-icon-size-large) / 2;
}

&.#{$ns}-large {
@include pt-flex-margin(row, $ti-icon-padding-large);
@include pt-flex-margin(row, $tag-input-icon-padding-large);
height: auto;
min-height: $pt-input-height-large;

.#{$ns}-tag-input-icon {
margin-top: $ti-icon-padding-large;
margin-left: $ti-icon-padding-large - $ti-padding;
margin-top: $tag-input-icon-padding-large;
margin-left: $tag-input-icon-padding-large - $tag-input-padding;
}

.#{$ns}-input-ghost {
Expand Down
2 changes: 2 additions & 0 deletions packages/core/src/components/tag-input/tag-input.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Tag inputs render [`Tag`](#core/components/tag)s inside an input, followed by an

@reactExample TagInputExample

@## JavaScript API

**`TagInput` must be controlled,** meaning the `values` prop is required and event handlers are strongly suggested. Typing in the input and pressing <kbd class="@ns-key">enter</kbd> will **add new items** by invoking callbacks. If `addOnBlur` is set to true, clicking out of the component will also trigger the callback to add new items. A `separator` prop is supported to allow multiple items to be added at once; the default splits on commas.

**Tags can be removed** by clicking their <span class="@ns-icon-standard @ns-icon-cross"></span> buttons, or by pressing <kbd class="@ns-key">backspace</kbd> repeatedly. Arrow keys can also be used to focus on a particular tag before removing it. The cursor must be at the beginning of the text input for these interactions.
Expand Down
6 changes: 2 additions & 4 deletions packages/core/src/components/tag/_common.scss
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,6 @@ $tag-padding-large: ($tag-height-large - $pt-icon-size-large) / 2 !default;
&.#{$ns}-tag-removable {
padding-right: $tag-height;
}

&.#{$ns}-active {
@include focus-outline(0);
}
}

@mixin pt-tag-large() {
Expand Down Expand Up @@ -106,6 +102,7 @@ $tag-padding-large: ($tag-height-large - $pt-icon-size-large) / 2 !default;
background-color: rgba($background-color, $opacity - 0.15);
}

&.pt-active,
Copy link
Contributor

Choose a reason for hiding this comment

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

pt#{$ns}

&:active {
background-color: rgba($background-color, $opacity - 0.3);
}
Expand All @@ -120,6 +117,7 @@ $tag-padding-large: ($tag-height-large - $pt-icon-size-large) / 2 !default;
background-color: rgba($background-color, $opacity + 0.1);
}

&.pt-active,
Copy link
Contributor

Choose a reason for hiding this comment

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

#{$ns}

&:active {
background-color: rgba($background-color, $opacity + 0.2);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/core/src/components/tag/tag.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ export class Tag extends React.PureComponent<ITagProps, {}> {
) : null;

return (
<span {...htmlProps} className={tagClasses}>
<span {...htmlProps} className={tagClasses} tabIndex={interactive ? 0 : -1}>
Copy link
Contributor

Choose a reason for hiding this comment

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

i think we want undefined in the false case (emphasis mine):

A negative value (usually tabindex="-1") means that the element should be focusable, but should not be reachable via sequential keyboard navigation. Mostly useful to create accessible widgets with JavaScript.
https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes/tabindex

{children}
{removeButton}
</span>
Expand Down