Skip to content

Commit

Permalink
Add defaults to borders and adjust shadows (#1079)
Browse files Browse the repository at this point in the history
  • Loading branch information
cchaos authored Aug 2, 2018
1 parent cc594a6 commit d4d5baf
Show file tree
Hide file tree
Showing 14 changed files with 65 additions and 46 deletions.
5 changes: 5 additions & 0 deletions src-docs/src/views/button/button_toggle.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export default class extends Component {
label="Toggle Me"
iconType={this.state.toggle0On ? 'check' : 'cross'}
onChange={this.onToggle0Change}
isSelected={this.state.toggle0On}
/>

 
Expand All @@ -46,6 +47,7 @@ export default class extends Component {
label={this.state.toggle1On ? 'I\'m a filled toggle' : 'I\'m a primary toggle'}
fill={this.state.toggle1On}
onChange={this.onToggle1Change}
isSelected={this.state.toggle1On}
/>

 
Expand All @@ -54,6 +56,7 @@ export default class extends Component {
label="Toggle Me"
iconType={this.state.toggle4On ? 'eye' : 'eyeClosed'}
onChange={this.onToggle4Change}
isSelected={this.state.toggle4On}
isEmpty
isIconOnly
/>
Expand All @@ -68,6 +71,7 @@ export default class extends Component {
isDisabled
label="Can't toggle this"
fill={this.state.toggle2On}
isSelected={this.state.toggle2On}
/>

 
Expand All @@ -76,6 +80,7 @@ export default class extends Component {
isDisabled
label="Can't toggle this either"
fill={this.state.toggle3On}
isSelected={this.state.toggle3On}
/>
</div>
);
Expand Down
6 changes: 2 additions & 4 deletions src/components/flyout/_flyout.scss
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
$euiFlyoutBorderColor: tintOrShade($euiShadowColorLarge, 50%, 0%) !default; // match shadow

.euiFlyout {
@include euiBottomShadowLarge;
border-left: $euiBorderThin;
@include euiBottomShadowLarge($adjustBorders: true);
position: fixed;
top: 0;
bottom: 0;
right: 0;
border-left: 1px solid $euiFlyoutBorderColor;
z-index: $euiZModal;
background: $euiColorEmptyShade;
animation: euiFlyout $euiAnimSpeedNormal $euiAnimSlightResistance;
Expand Down
2 changes: 1 addition & 1 deletion src/components/form/range/_range.scss
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ $euiRange__levelColors: (
}

~ .euiRange__valueWrapper .euiRange__value {
@include euiBottomShadow;
@include euiBottomShadowMedium;

&.euiRange__value--right {
transform: translateX(0) translateY(-50%) scale(1.1);
Expand Down
7 changes: 2 additions & 5 deletions src/components/modal/_modal.scss
Original file line number Diff line number Diff line change
@@ -1,18 +1,15 @@
$euiModalBorderColor: tintOrShade($euiShadowColorLarge, 50%, 0%) !default; // match shadow

/**
* 1. Fix IE overflow issue (min-height) by adding a separate wrapper for the
* flex display. https://github.com/philipwalton/flexbugs#flexbug-3
*/

.euiModal {
@include euiBottomShadowLarge;
border: $euiBorderThin;
@include euiBottomShadowLarge($adjustBorders: true);
display: flex; /* 1 */

position: relative;
background-color: $euiColorEmptyShade;
border: 1px solid $euiModalBorderColor;
border-top-color: tintOrShade($euiModalBorderColor, 50%, 0%);
border-radius: $euiBorderRadius;
z-index: $euiZModal;
min-width: 50%;
Expand Down
10 changes: 7 additions & 3 deletions src/components/panel/_mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,18 @@
}

&.#{$selector}--shadow {
@include euiBottomShadowMedium;

@if (lightness($euiTextColor) < 50) {
border-bottom-color: rgba($euiShadowColor, .6);
border-bottom-color: rgba($euiShadowColor, .5);
} @else {
// Applied again here in case dark theme overrides light
border-bottom-color: $euiBorderColor;
}
@include euiBottomShadowMedium;

&.#{$selector}--isClickable:hover,
&.#{$selector}--isClickable:focus {
@include euiBottomShadow;
@include euiBottomShadow($color: $euiShadowColor, $opacity: .2);
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/components/popover/__snapshots__/popover.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ exports[`EuiPopover props isOpen renders true 1`] = `
<div>
<div
aria-live="assertive"
class="euiPanel euiPanel--paddingMedium euiPanel--shadow euiPopover__panel euiPopover__panel-bottom euiPopover__panel-isOpen"
class="euiPanel euiPanel--paddingMedium euiPopover__panel euiPopover__panel-bottom euiPopover__panel-isOpen"
style="top: 16px; left: -22px; z-index: 0;"
>
<div
Expand All @@ -121,7 +121,7 @@ exports[`EuiPopover props ownFocus defaults to false 1`] = `
<div>
<div
aria-live="assertive"
class="euiPanel euiPanel--paddingMedium euiPanel--shadow euiPopover__panel euiPopover__panel-bottom euiPopover__panel-isOpen"
class="euiPanel euiPanel--paddingMedium euiPopover__panel euiPopover__panel-bottom euiPopover__panel-isOpen"
style="top: 16px; left: -22px; z-index: 0;"
>
<div
Expand Down Expand Up @@ -154,7 +154,7 @@ exports[`EuiPopover props ownFocus renders true 1`] = `
</p>
<div
aria-live="off"
class="euiPanel euiPanel--paddingMedium euiPanel--shadow euiPopover__panel euiPopover__panel-bottom euiPopover__panel-isOpen"
class="euiPanel euiPanel--paddingMedium euiPopover__panel euiPopover__panel-bottom euiPopover__panel-isOpen"
style="top: 16px; left: -22px; z-index: 0;"
tabindex="0"
>
Expand Down Expand Up @@ -182,7 +182,7 @@ exports[`EuiPopover props panelClassName is rendered 1`] = `
<div>
<div
aria-live="assertive"
class="euiPanel euiPanel--paddingMedium euiPanel--shadow euiPopover__panel euiPopover__panel-bottom euiPopover__panel-isOpen test"
class="euiPanel euiPanel--paddingMedium euiPopover__panel euiPopover__panel-bottom euiPopover__panel-isOpen test"
style="top: 16px; left: -22px; z-index: 0;"
>
<div
Expand All @@ -209,7 +209,7 @@ exports[`EuiPopover props panelPaddingSize is rendered 1`] = `
<div>
<div
aria-live="assertive"
class="euiPanel euiPanel--paddingSmall euiPanel--shadow euiPopover__panel euiPopover__panel-bottom euiPopover__panel-isOpen"
class="euiPanel euiPanel--paddingSmall euiPopover__panel euiPopover__panel-bottom euiPopover__panel-isOpen"
style="top: 16px; left: -22px; z-index: 0;"
>
<div
Expand Down
1 change: 1 addition & 0 deletions src/components/popover/_popover.scss
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
opacity: 0; /* 2 */
visibility: hidden; /* 2 */
transform: translateY(0) translateX(0) translateZ(0); /* 2 */
@include euiBottomShadow($adjustBorders: true);

&.euiPopover__panel-isOpen {
opacity: 1;
Expand Down
1 change: 0 additions & 1 deletion src/components/popover/popover.js
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,6 @@ export class EuiPopover extends Component {
className={panelClasses}
paddingSize={panelPaddingSize}
tabIndex={tabIndex}
hasShadow
aria-live={ariaLive}
style={this.state.popoverStyles}
>
Expand Down
7 changes: 2 additions & 5 deletions src/components/toast/_toast.scss
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
.euiToast {
@include euiBottomShadowLarge;
border: $euiBorderThin;
@include euiBottomShadowLarge($adjustBorders: true);

position: relative;
padding: $euiSize;
background-color: $euiColorEmptyShade;
border: $euiBorderThin;
@if (lightness($euiTextColor) < 50) {
border-bottom-color: rgba($euiShadowColor, .6);
}
width: 100%;

&:hover .euiToast__closeButton,
Expand Down
2 changes: 1 addition & 1 deletion src/components/tool_tip/_tool_tip.scss
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/

.euiToolTip {
@include euiBottomShadow;
@include euiBottomShadow($color: $euiShadowColor);
@include euiFontSizeS();

position: absolute; /* 1 */
Expand Down
29 changes: 22 additions & 7 deletions src/global_styling/mixins/_shadow.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
$euiShadowColor: $euiColorMediumShade !default;
$euiShadowColorLarge: $euiColorSlightHue !default;

@mixin euiSlightShadow($color: $euiShadowColor, $opacity: .3) {
box-shadow: 0 2px 2px -1px rgba($color, $opacity);
}
Expand All @@ -27,22 +24,38 @@ $euiShadowColorLarge: $euiColorSlightHue !default;
0 0px 2px 0 rgba($color, $opacity);
}

@mixin euiBottomShadow($color: $euiShadowColor, $opacity: .2) {
// adjustBorder allows the border color to match the drop shadow better so that there's better
// distinction between element bounds and the shadow (crisper borders)
@mixin euiBottomShadow($color: $euiShadowColorLarge, $opacity: .1, $adjustBorders: false) {
box-shadow:
0 12px 24px 0 rgba($color, $opacity),
0 6px 12px 0 rgba($color, $opacity),
0 4px 4px 0 rgba($color, $opacity),
0 2px 2px 0 rgba($color, $opacity);

// Never adjust borders if the border color is already on the dark side (dark theme)
@if ($adjustBorders and not (lightness($euiBorderColor) < 50)) {
border-color: tint($color, 75%);
border-top-color: tint($color, 80%);
border-bottom-color: tint($color, 55%);
}
}

@mixin euiBottomShadowLarge($color: $euiShadowColorLarge, $opacity: .2) {
@mixin euiBottomShadowLarge($color: $euiShadowColorLarge, $opacity: .1, $adjustBorders: false) {
box-shadow:
0 64px 64px 0 rgba($color, $opacity),
0 32px 32px 0 rgba($color, $opacity),
0 40px 64px 0 rgba($color, $opacity),
0 24px 32px 0 rgba($color, $opacity),
0 16px 16px 0 rgba($color, $opacity),
0 8px 8px 0 rgba($color, $opacity),
0 4px 4px 0 rgba($color, $opacity),
0 2px 2px 0 rgba($color, $opacity);

// Never adjust borders if the border color is already on the dark side (dark theme)
@if ($adjustBorders and not (lightness($euiBorderColor) < 50)) {
border-color: tint($color, 70%);
border-top-color: tint($color, 85%);
border-bottom-color: tint($color, 55%);
}
}

@mixin euiSlightShadowHover($color: $euiShadowColor, $opacity: .3) {
Expand All @@ -55,6 +68,8 @@ $euiShadowColorLarge: $euiColorSlightHue !default;
@include euiSlightShadowHover($color, $opacity);
}

// Overflow shadows are useful when a middle element scrolls independently from
// any top and/or bottom elements
@mixin euiOverflowShadowTop {
box-shadow: 0 ($euiSize *-1) $euiSize (-$euiSize / 2) $euiColorEmptyShade;
z-index: 2;
Expand Down
14 changes: 7 additions & 7 deletions src/global_styling/variables/_animations.scss
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
// Animations

$euiAnimSlightBounce: cubic-bezier(0.34,1.61,0.7,1);
$euiAnimSlightResistance: cubic-bezier(0.694, 0.0482, 0.335, 1);
$euiAnimSlightBounce: cubic-bezier(0.34,1.61,0.7,1) !default;
$euiAnimSlightResistance: cubic-bezier(0.694, 0.0482, 0.335, 1) !default;

$euiAnimSpeedExtraFast: 90ms;
$euiAnimSpeedFast: 150ms;
$euiAnimSpeedNormal: 250ms;
$euiAnimSpeedSlow: 350ms;
$euiAnimSpeedExtraSlow: 500ms;
$euiAnimSpeedExtraFast: 90ms !default;
$euiAnimSpeedFast: 150ms !default;
$euiAnimSpeedNormal: 250ms !default;
$euiAnimSpeedSlow: 350ms !default;
$euiAnimSpeedExtraSlow: 500ms !default;

@keyframes euiAnimFadeIn {
0% {
Expand Down
14 changes: 7 additions & 7 deletions src/global_styling/variables/_borders.scss
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// Borders

$euiBorderWidthThin: 1px;
$euiBorderWidthThick: 2px;
$euiBorderWidthThin: 1px !default;
$euiBorderWidthThick: 2px !default;

$euiBorderColor: $euiColorLightShade;
$euiBorderRadius: 4px;
$euiBorderThick: $euiBorderWidthThick solid $euiBorderColor;
$euiBorderThin: $euiBorderWidthThin solid $euiBorderColor;
$euiBorderEditable: $euiBorderWidthThick dotted $euiBorderColor;
$euiBorderColor: $euiColorLightShade !default;
$euiBorderRadius: 4px !default;
$euiBorderThick: $euiBorderWidthThick solid $euiBorderColor !default;
$euiBorderThin: $euiBorderWidthThin solid $euiBorderColor !default;
$euiBorderEditable: $euiBorderWidthThick dotted $euiBorderColor !default;
3 changes: 3 additions & 0 deletions src/global_styling/variables/_shadows.scss
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
// Shadows
// Transparency only affects the use of variable this outside of the shadow mixins (borders)
$euiShadowColor: $euiColorMediumShade !default;
$euiShadowColorLarge: shade(saturate($euiColorSlightHue, 25%), 50%) !default;

0 comments on commit d4d5baf

Please sign in to comment.