Utility classes to easily add some useful styles.
All that is required is to add the class to the HTML element. The SCSS blocks are included only for reference.
Ensure float styles are cleared going forward.
.u-clearfix {
&:after {
clear: both !important;
content: "" !important;
display: block !important;
}
}
Highlight text such as search terms, etc.
.u-highlight {
background-color: $theme-color-highlight;
}
Align items vertically centered.
.u-flex-align-center {
align-items: center;
display: flex;
}
Arrange items in a column (instead of in a row which is the dfault).
.u-flex-align-center {
display: flex;
flex-direction: column;
}
Align items at left/right with space around them (including space at the beginning and end of the row).
.u-flex-space-between {
align-items: center;
display: flex;
justify-content: space-around;
}
Align items at left/right with space between them.
.u-flex-space-between {
align-items: center;
display: flex;
justify-content: space-between;
}
Hide visually and hide from screen readers.
.u-hidden {
display: none !important;
}
Hide visually but not from screen readers.
.u-hidden-visually {
border: 0 !important;
clip: rect(0 0 0 0) !important;
height: 1px !important;
margin: -1px !important;
overflow: hidden !important;
padding: 0 !important;
position: absolute !important;
width: 1px !important;
}
For temporary elements off screen.
.u-temporary-offscreen {
position: absolute;
left: -300000px;
bottom: -300000px;
}
Display an ellipsis when text is too long and overflows.
.u-overflow-ellipsis {
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
Allow momentum scrolling on touch devices.
.u-touch-momentum-scroll {
-webkit-overflow-scrolling: touch;
overflow-y: scroll;
}
// Returns a function, that, as long as it continues to be invoked, will not
// be triggered. The function will be called after it stops being called for
// N milliseconds. If `immediate` is passed, trigger the function on the
// leading edge, instead of the trailing.
$.flexmlsUi.debounce = function (func, wait, immediate) {
var timeout;
return function() {
var context = this, args = arguments;
var later = function() {
timeout = null;
if (!immediate) { func.apply(context, args); }
};
var callNow = immediate && !timeout;
clearTimeout(timeout);
timeout = setTimeout(later, wait);
if (callNow) { func.apply(context, args); }
};
};
Returns true if running on a touch device.
Returns true if scrolling is needed for the passed in $element.