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 9 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 @@ -69,7 +69,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
28 changes: 14 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,10 @@
@import "../forms/common";
@import "../tag/common";

$ti-padding: ($pt-input-height - $tag-height) / 2;
$tag-input-padding: ($pt-input-height - $tag-height) / 2 !default;

$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 !default;
$tag-input-icon-padding-large: ($pt-input-height-large - $pt-icon-size-large) / 2 !default;

.#{$ns}-tag-input {
@include pt-flex-container(row, $fill: ".#{$ns}-tag-input-values");
Expand All @@ -17,27 +17,27 @@ $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;
}
}

Expand Down Expand Up @@ -71,13 +71,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
10 changes: 6 additions & 4 deletions packages/core/src/components/tag/_common.scss
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ $tag-padding-large: ($tag-height-large - $pt-icon-size-large) / 2 !default;
color: $pt-dark-text-color;
font-size: $pt-font-size-small;

&.#{$ns}-active {
Copy link
Contributor

Choose a reason for hiding this comment

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

ah dang actually i think this should be &:focus here, just to adjust the outline-offset.

and bring back this selector in .pt-tag-input .pt-tag like you had earlier

😄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

pushed another commit, hopefully I got it right this time!

@include focus-outline(0);
}

&.#{$ns}-round {
border-radius: $tag-height / 2;
}
Expand All @@ -41,10 +45,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 +106,7 @@ $tag-padding-large: ($tag-height-large - $pt-icon-size-large) / 2 !default;
background-color: rgba($background-color, $opacity - 0.15);
}

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

&.#{$ns}-active,
&:active {
background-color: rgba($background-color, $opacity + 0.2);
}
Expand Down
3 changes: 2 additions & 1 deletion packages/core/src/components/tag/tag.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export class Tag extends React.PureComponent<ITagProps, {}> {
minimal,
onRemove,
round,
tabIndex = 0,
...htmlProps
} = this.props;
const isRemovable = Utils.isFunction(onRemove);
Expand All @@ -88,7 +89,7 @@ export class Tag extends React.PureComponent<ITagProps, {}> {
) : null;

return (
<span {...htmlProps} className={tagClasses}>
<span {...htmlProps} className={tagClasses} tabIndex={interactive ? tabIndex : undefined}>
{children}
{removeButton}
</span>
Expand Down