Skip to content

Commit

Permalink
Move shared component mixins to global_styles (#2551)
Browse files Browse the repository at this point in the history
* Move euiPanel mixin to global_styling for easier overriding

* Move button mixin to global_styling

* Move loading mixin to global_styling

* Move popover mixin to global_styling

* Move form, switch, and range mixins and variables to global_styling

* Add changelog entry

* Move changelog item to "breaking changes" heading

* Move buttons variables to global_styling

* Move buttons variables to global_styling

* Consolidate form variables files

* Remove form variable imports in form mixin file

* Move beta_badge mixins to global_styling

* Move tooltip variables and mixins to global_styling

* Refactor panel mixin to require entire selector

* Add note to changelog about panel mixin selector

* Remove $euiPanelBorderColor as it was not used

* Renaming mixin `fasBetaBadge` to `euiHasBetaBadge`

and removing the `.` portion of the selector

* Combined `form_control_layout` mixins into `form` file

* Adding `!default`s to global variables

* Move panel variables to global

* Cleanup

- Moved range variables into form
- Moved keyframes into utility/_animations
- Moved button_toggle mixin out of buttons and back into component specific folder
- Moved euiHiddenSelectableInput from switch specific to form
- Moved hexToRGB function from helper mixin to color function file

* Update tense in the CL

Co-Authored-By: Caroline Horn <[email protected]>
  • Loading branch information
johnbarrierwilson and cchaos authored Dec 5, 2019
1 parent 20caa88 commit 395dc9f
Show file tree
Hide file tree
Showing 75 changed files with 171 additions and 265 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@ No public interface changes since `16.2.1`.
- Fixed `EuiSwitch` clicking on disabled label ([#2575](https://github.com/elastic/eui/pull/2575))
- Fixed `EuiComboBox` options list closing when clicking outside the component after scrolling ([#2589](https://github.com/elastic/eui/pull/2589))

**Breaking Changes**

- Moved any shared component-level Sass variables and mixins into the `global_styling` directory ([#2551](https://github.com/elastic/eui/pull/2551))
- Reworked `euiPanel()` mixin to require the entirety of a selector (i.e. require the '.' in addition to the string) ([#2551](https://github.com/elastic/eui/pull/2551))

## [`16.1.0`](https://github.com/elastic/eui/tree/v16.1.0)

- Updated compressed styles for `EuiButtonGroup` to include a background color ([#2568](https://github.com/elastic/eui/pull/2568))
Expand Down
2 changes: 0 additions & 2 deletions src/components/badge/_badge.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
@import '../button/variables';

/**
* 1. Accounts for the border
*/
Expand Down
1 change: 0 additions & 1 deletion src/components/badge/beta_badge/_index.scss
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
@import 'mixins';
@import 'beta_badge';
3 changes: 0 additions & 3 deletions src/components/button/_button.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
@import '../loading/mixins';

// This file has lots of modifiers and is somewhat nesty by nature
//sass-lint:disable nesting-depth

Expand Down Expand Up @@ -79,7 +77,6 @@
// Create button modifiers based upon the map.
@each $name, $color in $euiButtonTypes {
.euiButton--#{$name} {

@if ($name == 'ghost') {
// Ghost is unique and ALWAYS sits against a dark background.
color: $color;
Expand Down
3 changes: 0 additions & 3 deletions src/components/button/_index.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
@import 'variables';
@import 'mixins';

@import 'button';
@import 'button_empty/index';
@import 'button_icon/index';
Expand Down
2 changes: 0 additions & 2 deletions src/components/button/button_group/_button_group.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
@import '../../form/variables';

.euiButtonGroup {
max-width: 100%;
display: flex;
Expand Down
1 change: 1 addition & 0 deletions src/components/button/button_toggle/_index.scss
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
@import 'mixins';
@import 'button_toggle';
12 changes: 12 additions & 0 deletions src/components/button/button_toggle/_mixins.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// BUTTON TOGGLES
// Pointer events and interactions are handled by the input (checkbox/radio)
// and not the button, this mixin helps to target that element for states
@mixin euiButtonToggleStates {
@at-root {
.euiButtonToggle__input:enabled:hover + #{&},
.euiButtonToggle__input:enabled:focus + #{&},
.euiButtonToggle__input:enabled:active + #{&} {
@content;
}
}
}
16 changes: 6 additions & 10 deletions src/components/card/_card.scss
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
@import '../panel/mixins';
@import '../badge/beta_badge/mixins';

// Start with a base of EuiPanel styles
@include euiPanel($selector: 'euiCard');
@include euiPanel($selector: '.euiCard');

/**
* 1. Footer is always at the bottom.
Expand All @@ -16,10 +13,7 @@
display: flex;
flex-direction: column;
padding: $euiCardSpacing;
min-height: 1px; /* 2 */

// This creates a bunch of sub selectors for the beta badge
@include hasBetaBadge($selector: 'euiCard', $spacing: $euiCardSpacing); // sass-lint:disable-line mixins-before-declarations
min-height: 1px; /* 2 */// sass-lint:disable-line mixins-before-declarations

&.euiCard-isDisabled {
cursor: not-allowed; // duplicate property due to Chrome bug
Expand Down Expand Up @@ -99,14 +93,17 @@

&.euiCard--isSelectable {
position: relative;
padding-bottom: $euiCardSpacing + $euiCardGraphicHeight;
padding-bottom: $euiCardSpacing + $euiCardBottomNodeHeight;
}

&.euiCard-isSelected {
transition: all $euiAnimSpeedFast $euiAnimSlightResistance;
}
}

// This creates a bunch of sub selectors for the beta badge
@include euiHasBetaBadge($selector: '.euiCard', $spacing: $euiCardSpacing);

// Selectable cards don't work well without a border
.euiCard--plain:not(.euiCard--isSelectable) {
border: none;
Expand Down Expand Up @@ -212,4 +209,3 @@
.euiCard--hasChildren .euiCard__description {
margin-bottom: $euiCardSpacing;
}

2 changes: 1 addition & 1 deletion src/components/card/_mixins.scss
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
position: absolute;
bottom: 0;
left: 0;
height: $euiCardGraphicHeight !important; // sass-lint:disable-line no-important -- To override .euiButtonEmpty--xSmall
height: $euiCardBottomNodeHeight !important; // sass-lint:disable-line no-important -- To override .euiButtonEmpty--xSmall
width: 100%;
overflow: hidden;
// Subtract 1px from border radius since it sits inside a border-radius
Expand Down
5 changes: 1 addition & 4 deletions src/components/card/_variables.scss
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
@import '../panel/variables';

$euiCardSpacing: map-get($euiPanelPaddingModifiers, 'paddingMedium');
$euiCardTitleSize: 18px; // Hardcoded pixel value for theme parity.
$euiCardGraphicHeight: 40px; // Actual height of the svg used in EuiCardGraphic
$euiCardBottomNodeHeight: $euiSizeXXL;

$euiCardSelectButtonBorders: (
text: $euiColorSuccess, // Default for selected
Expand Down
4 changes: 1 addition & 3 deletions src/components/card/checkable_card/_checkable_card.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
@import '../../panel/mixins';

@include euiPanel('euiCheckableCard');
@include euiPanel($selector: '.euiCheckableCard');

.euiCheckableCard {
transition: border-color $euiAnimSpeedNormal ease-in;
Expand Down
2 changes: 0 additions & 2 deletions src/components/color_picker/_color_picker.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
@import '../form/mixins';

.euiColorPicker {
position: relative;
width: $euiColorPickerWidth;
Expand Down
4 changes: 0 additions & 4 deletions src/components/color_picker/_hue.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
@import '../form/_mixins';
@import '../form/range/_variables';
@import '../form/range/_mixins';

// This wraps the range. It is needed because there is no way to do a linear gradeint in ie11 for the track
.euiHue {
// sass-lint:disable-block no-color-literals
Expand Down
2 changes: 0 additions & 2 deletions src/components/color_picker/color_stops/_color_stops.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
@import '../../form/range/_variables';

.euiColorStops:not(.euiColorStops-isDisabled) {
&:focus {
outline: 2px solid $euiFocusRingColor;
Expand Down
2 changes: 0 additions & 2 deletions src/components/combo_box/_combo_box.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
@import '../form/form_control_layout/mixins';

.euiComboBox {
@include euiFormControlSize(auto, $includeAlternates: true);
position: relative;
Expand Down
4 changes: 0 additions & 4 deletions src/components/combo_box/_index.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
@import '../form/variables';
@import '../form/mixins';
@import '../form/form_control_layout/mixins';

@import 'combo_box';
@import 'combo_box_input/index';
@import 'combo_box_options_list/index';
2 changes: 0 additions & 2 deletions src/components/context_menu/_context_menu_panel.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
@import '../popover/mixins';

.euiContextMenuPanel {
width: 100%;
visibility: visible;
Expand Down
1 change: 0 additions & 1 deletion src/components/control_bar/_index.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
@import '../header/variables';
@import '../button/variables';
@import '../nav_drawer/variables';
@import 'variables';
@import 'control_bar';
4 changes: 0 additions & 4 deletions src/components/date_picker/_date_picker_range.scss
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
@import '../form/variables';
@import '../form/mixins';
@import '../form/form_control_layout/variables';

/**
* 1. Account for inner box-shadow style border
*/
Expand Down
2 changes: 0 additions & 2 deletions src/components/date_picker/super_date_picker/_mixins.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
@import '../../form/form_control_layout/variables';

@mixin euiSuperDatePickerText {
@include euiFormControlText;
display: block;
Expand Down
4 changes: 1 addition & 3 deletions src/components/drag_and_drop/_droppable.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
@import '../panel/mixins';

.euiDroppable {
$euiDroppableColor: $euiColorSecondary;
transition: background-color $euiAnimSpeedExtraSlow ease;
Expand All @@ -20,7 +18,7 @@
}
}

@include euiPanel('euiDroppable--withPanel');
@include euiPanel($selector: '.euiDroppable--withPanel');

.euiDroppable--noGrow {
flex-grow: 0;
Expand Down
3 changes: 0 additions & 3 deletions src/components/facet/_index.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,2 @@
@import '../button/variables';
@import '../button/mixins';

@import 'facet_button';
@import 'facet_group';
2 changes: 0 additions & 2 deletions src/components/filter_group/_filter_button.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
@import '../form/variables';

.euiFilterButton {
background-color: $euiFormBackgroundColor;
height: $euiFormControlHeight;
Expand Down
2 changes: 0 additions & 2 deletions src/components/filter_group/_filter_group.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
@import '../form/variables';

.euiFilterGroup {
display: inline-flex;
max-width: 100%;
Expand Down
3 changes: 0 additions & 3 deletions src/components/filter_group/_index.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
@import '../form/variables';
@import '../form/mixins';

@import 'filter_group';
@import 'filter_button';
@import 'filter_select_item';
2 changes: 0 additions & 2 deletions src/components/flyout/_flyout.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
@import '../form/variables';

.euiFlyout {
border-left: $euiBorderThin;
// The mixin augments the above
Expand Down
3 changes: 0 additions & 3 deletions src/components/form/_index.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
@import 'variables';
@import 'mixins';

@import 'checkbox/index';
@import 'described_form_group/index';
@import 'field_number/index';
Expand Down
1 change: 0 additions & 1 deletion src/components/form/checkbox/_index.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
@import '../variables';
@import 'checkbox';
@import 'checkbox_group';
2 changes: 0 additions & 2 deletions src/components/form/file_picker/_file_picker.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
@import '../form_control_layout/mixins';

/**
* REMEMBER: --large modifiers must come last to override --compressed
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
@import '../variables';
@import '../mixins';

.euiFormControlLayout {
// Let the height expand as needed
@include euiFormControlSize($includeAlternates: true);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
@import '../variables';
@import '../mixins';

.euiFormControlLayoutDelimited {
// Match just the regular drop shadow of inputs
@include euiFormControlDefaultShadow;
Expand Down
2 changes: 0 additions & 2 deletions src/components/form/form_control_layout/_index.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
@import 'variables';
@import 'mixins';
@import 'form_control_layout';
@import 'form_control_layout_delimited';
@import 'form_control_layout_icons';
Expand Down
42 changes: 0 additions & 42 deletions src/components/form/form_control_layout/_mixins.scss

This file was deleted.

9 changes: 0 additions & 9 deletions src/components/form/form_control_layout/_variables.scss

This file was deleted.

1 change: 0 additions & 1 deletion src/components/form/radio/_index.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
@import '../variables';
@import 'radio';
@import 'radio_group';
3 changes: 0 additions & 3 deletions src/components/form/range/_index.scss
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
@import 'variables';
@import 'mixins';

@import 'range';
@import 'range_highlight';
@import 'range_input';
Expand Down
2 changes: 0 additions & 2 deletions src/components/form/range/_range_tooltip.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
@import '../../tool_tip/variables';

.euiRangeTooltip {
// Keeps tooltip (value) aligned to percentage of actual slider
display: block;
Expand Down
16 changes: 0 additions & 16 deletions src/components/form/range/_variables.scss

This file was deleted.

1 change: 0 additions & 1 deletion src/components/form/switch/_index.scss
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
@import '../variables';
@import 'switch';
8 changes: 0 additions & 8 deletions src/components/form/switch/_mixins.scss

This file was deleted.

1 change: 0 additions & 1 deletion src/components/loading/_index.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
@import 'variables';
@import 'mixins';
@import 'loading_kibana';
@import 'loading_chart';
@import 'loading_content';
Expand Down
2 changes: 0 additions & 2 deletions src/components/modal/_index.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
@import '../form/variables';

@import 'modal';
2 changes: 0 additions & 2 deletions src/components/page/page_content/_page_content_header.scss
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
@import '../../panel/variables';

.euiPageContentHeader {
display: flex;
flex-direction: row;
Expand Down
Loading

0 comments on commit 395dc9f

Please sign in to comment.