Skip to content

Commit

Permalink
Convert all Less files to Sass in discover, use EUI variable scope (e…
Browse files Browse the repository at this point in the history
…lastic#21290)

Discover now uses sass for its styling
  • Loading branch information
going-confetti authored and cjcenizal committed Aug 23, 2018
1 parent 33c1969 commit 46e7569
Show file tree
Hide file tree
Showing 43 changed files with 340 additions and 402 deletions.
Empty file.
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -121,9 +121,9 @@ describe('discover field chooser directives', function () {

const getSections = function (ctx) {
return {
selected: $('.discover-selected-fields', ctx),
popular: $('.discover-popular-fields', ctx),
unpopular: $('.discover-unpopular-fields', ctx),
selected: $('.dscFieldList--selected', ctx),
popular: $('.dscFieldList--popular', ctx),
unpopular: $('.dscFieldList--unpopular', ctx),
};
};

Expand Down Expand Up @@ -157,7 +157,7 @@ describe('discover field chooser directives', function () {

function find(popularity) {
return section[popularity]
.find('.discover-field-name')
.find('.dscFieldName')
.map((i, el) => $(el).text())
.toArray();
}
Expand Down
216 changes: 216 additions & 0 deletions src/core_plugins/kibana/public/discover/_discover.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,216 @@
// SASSTODO: replace the margin-top value with a variable
.dscSidebar__listHeader {
margin-top: 5px;
}

// SASSTODO: replace the padding-top value with a variable
.dscFieldList--popular {
padding-top: 10px;
}

// SASSTODO: replace the z-index value with a variable
.dscWrapper {
padding-right: 0;
padding-left: 21px;
z-index: 1
}

.dscWrapper__content {
padding-right: $euiSize;
clear: both;
}

.dscTimechart {
display: block;
position: relative;

// SASSTODO: the visualizing component should have an option or a modifier
.series > rect {
fill-opacity: 0.5;
stroke-width: 1;
}
}

.dscTimechart__header {
display: flex;
justify-content: center;
min-height: $euiSizeXXL;
padding: $euiSizeXS 0;
}

.dscOverlay {
position: absolute;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: 20;
padding-top: $euiSizeM;

opacity: 0.75;
text-align: center;
background-color: transparent;
}

.dscTable {
overflow: auto;

// SASSTODO: add a monospace modifier to the doc-table component
.discover-table-row {
font-family: $euiCodeFontFamily;
}
}

// SASSTODO: replace the padding value with a variable
.dscTable__footer {
background-color: $euiColorLightShade;
padding: 5px 10px;
text-align: center;
}

/**
* 1. When switching between open and closed, the toggle changes size
* slightly which is a problem because it forces the entire table to
* re-render which is SLOW.
*/
.dscTable__openButton {
appearance: none;
background-color: transparent;
padding: 0;
border: none;
width: 14px; /* 1 */
height: 14px;
}

/**
* 1. Override sidebar-item-title styles.
*/
.dscSidebarItem {
position: relative;
display: flex;
align-items: center;
justify-content: space-between;
padding-top: 0 !important; /* 1 */
padding-bottom: 0 !important; /* 1 */
height: $euiSizeXL;

&:hover,
&:focus {
.dscSidebarItem__action {
opacity: 1;
}
}
}

.dscSidebarItem--active {
background: shade($euiColorLightestShade, 5%);
color: $euiColorFullShade;
font-weight: bold;
}

/**
* 1. Truncate long text so it doesn't push the actions outside of the container.
*/
.dscSidebarItem__label {
overflow: hidden; /* 1 */
text-overflow: ellipsis; /* 1 */
}

/**
* 1. Only visually hide the action, so that it's still accessible to screen readers.
* 2. When tabbed to, this element needs to be visible for keyboard accessibility.
*/
.dscSidebarItem__action {
opacity: 0; /* 1 */

&:focus {
opacity: 1; /* 2 */
}
}

// SASSTODO: replace the padding value with a variable
.dscFieldDetails {
padding: 10px;
background-color: shade($euiColorLightestShade, 5%);
color: shade($euiColorEmptyShade, 65%);
}

// SASSTODO: replace the padding and margin values with variables
.dscFieldDetails__progress {
background-color: rgba(0, 0, 0, 0.8);
padding: 3px;
border-radius: $euiBorderRadius;
margin-left: 3px;
margin-right: 3px;
}

// SASSTODO: replace the margin-top value with a variable
.dscFieldDetailsItem {
margin-top: 5px;
}

.dscFieldDetails__filter {
cursor: pointer;
}

.dscFieldDetailsItem__title {
line-height: 1.5;
display: flex;
align-items: center;
justify-content: space-between;
}

/**
* 1. If the field name is very long, don't let it squash the buttons.
*/
.dscFieldDetailsItem__buttonGroup {
flex: 0 0 auto; /* 1 */
}

.dscFieldDetailsItem__button {
appearance: none;
border: none;
padding: 0;
background-color: transparent;
}

.dscField--noResults {
color: $euiColorDarkShade;
}

// SASSTODO: replace the margin-right value with a variables
.dscField__icon {
margin-right: 5px;
text-align: center;
display: inline-block;
width: $euiSizeM;
color: $euiColorDarkShade;
}

.dscResults {
h3 {
margin: -20px 0 10px 0;
text-align: center;
}
}

.dscResults__interval {
display: inline-block;
width: auto;
}

.dscSkipButton {
position: absolute;
left: -10000px;
top: $euiSizeXS;
width: 1px;
height: 1px;
overflow: hidden;

&:focus {
left: initial;
right: $euiSize;
width: auto;
height: auto;
}
}
20 changes: 20 additions & 0 deletions src/core_plugins/kibana/public/discover/_hacks.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// SASSTODO: the classname is dinamically generated with ng-class
.tab-discover {
overflow: hidden;
}

// SASSTODO: these are Angular Bootstrap classes. Will be replaced by EUI
.dscFieldDetails {
.progress {
background-color: shade($euiColorLightestShade, 5%);
margin-bottom: 0;
border-radius: 0;
}

.progress-bar {
padding-left: 10px;
text-align: right;
line-height: 20px;
max-width: 100%;
}
}
16 changes: 16 additions & 0 deletions src/core_plugins/kibana/public/discover/_index.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
@import 'components/fetch_error/index';
@import 'directives/index';

@import '../../../../ui/public/styles/local_search';

@import 'hacks';

// Discover plugin styles

// Prefix all styles with "dsc" to avoid conflicts.
// Examples
// dscTable
// dscTable__footer
// monChart__legend--small
// monChart__legend-isLoading
@import 'discover';
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
@import 'fetch_error';
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ import {
EuiSpacer,
} from '@elastic/eui';

import './fetch_error.less';

const DiscoverFetchError = ({ fetchError }) => {
if (!fetchError) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
data-test-subj="field-{{::field.name}}"
ng-click="onClickToggleDetails($event, field)"
kbn-accessible-click
class="sidebar-item-title discover-sidebar-item"
class="sidebar-item-title dscSidebarItem"
>
<field-name
class="discover-sidebar-item-label"
class="dscField dscSidebarItem__label"
field="field"
></field-name>

Expand All @@ -18,7 +18,7 @@
ng-click="toggleDisplay(field)"
ng-class="::field.display ? 'kuiButton--danger' : 'kuiButton--primary'"
ng-bind="::field.display ? 'remove' : 'add'"
class="discover-sidebar-item-action kuiButton kuiButton--small"
class="dscSidebarItem__action kuiButton kuiButton--small"
data-test-subj="fieldToggle-{{::field.name}}"
></button>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,13 @@ app.directive('discoverField', function ($compile) {
detailsElem = $(detailsHtml);
$compile(detailsElem)(detailScope);
$elem.append(detailsElem).addClass('active');
$elem.find('.dscSidebarItem').addClass('dscSidebarItem--active');
} else {
delete field.details;
detailScope.$destroy();
detailsElem.remove();
$elem.removeClass('active');
$elem.find('.dscSidebarItem').removeClass('dscSidebarItem--active');
}
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,12 @@
</div>
</div>

<div class="discover-sidebar-list-header sidebar-list-header" ng-if="fields.length">
<div class="dscSidebar__listHeader sidebar-list-header" ng-if="fields.length">
<h3 class="sidebar-list-header-label" id="selected_fields" tabindex="0">
Selected fields
</h3>
</div>
<ul class="list-unstyled discover-selected-fields" >
<ul class="list-unstyled dscFieldList--selected" >
<discover-field
ng-repeat="field in fields.raw|filter:{display:true}"
field="field"
Expand Down Expand Up @@ -82,7 +82,7 @@ <h3 class="euiFlexItem sidebar-list-header-label" id="available_fields" tabindex
</div>
</div>

<div class="sidebar-item discover-field-details" ng-show="showFilter" id="discoverFieldFilter" data-test-subj="discoverFieldFilter">
<div class="sidebar-item dscFieldDetails" ng-show="showFilter" id="discoverFieldFilter" data-test-subj="discoverFieldFilter">
<form role="form">
<div class="form-group">
<label for="discoverFieldChooserFilterAggregatable">
Expand Down Expand Up @@ -147,7 +147,7 @@ <h3 class="euiFlexItem sidebar-list-header-label" id="available_fields" tabindex
<ul
ng-show="(popularFields | filter:filter.isFieldFiltered).length > 0"
ng-class="{ 'hidden-sm': !showFields, 'hidden-xs': !showFields }"
class="list-unstyled sidebar-well discover-popular-fields">
class="list-unstyled sidebar-well dscFieldList--popular">
<li class="sidebar-item sidebar-list-header">
<h6>Popular</h6>
</li>
Expand All @@ -164,7 +164,7 @@ <h6>Popular</h6>

<ul
ng-class="{ 'hidden-sm': !showFields, 'hidden-xs': !showFields }"
class="list-unstyled discover-unpopular-fields">
class="list-unstyled dscFieldList--unpopular">
<discover-field
ng-repeat="field in unpopularFields | filter:filter.isFieldFiltered"
field="field"
Expand Down
Loading

0 comments on commit 46e7569

Please sign in to comment.