discourse/app/assets/stylesheets/common/foundation/mixins.scss

147 lines
3.5 KiB
SCSS
Raw Normal View History

2013-02-05 14:16:51 -05:00
// --------------------------------------------------
// Mixins used throughout the theme
// --------------------------------------------------
// Media queries
// --------------------------------------------------
2018-07-12 16:38:51 -04:00
$breakpoints: (
mobile-small: 320px,
mobile-medium: 350px,
2018-07-12 16:38:51 -04:00
mobile: 550px,
tablet: 768px,
medium: 850px,
large: 1000px,
extra-large: 1140px
);
@mixin breakpoint($bp, $rule: max-width, $type: screen) {
@media #{$type} and (#{$rule}: map-get($breakpoints, $bp)) {
2018-07-12 16:41:44 -04:00
@content;
}
}
2013-12-18 11:50:51 -05:00
2013-02-05 14:16:51 -05:00
// CSS3 properties
// --------------------------------------------------
2015-03-23 10:23:42 -04:00
// Clearfix
@mixin clearfix() {
&:before,
&:after {
content: "";
display: table;
}
&:after {
clear: both;
}
2015-03-23 10:23:42 -04:00
}
//noinspection CssOptimizeSimilarProperties
2013-02-05 14:16:51 -05:00
@mixin linear-gradient($start-color, $end-color) {
background-color: $start-color;
background-image: linear-gradient(to bottom, $start-color, $end-color);
}
// Visibility
// --------------------------------------------------
@mixin hover {
.discourse-no-touch & {
&:hover {
@content;
}
}
}
2013-04-08 17:43:52 -04:00
//
// --------------------------------------------------
2014-12-23 05:52:20 -05:00
// Unselectable (avoids unwanted selections with iPad, touch laptops, etc)
2013-04-08 17:43:52 -04:00
@mixin user-select($mode) {
-webkit-user-select: $mode;
-moz-user-select: $mode;
-ms-user-select: $mode;
}
2013-04-08 17:43:52 -04:00
@mixin unselectable {
@include user-select(none);
2013-04-08 17:43:52 -04:00
}
// Stuff we repeat
@mixin post-aside {
2017-06-11 22:20:14 -04:00
border-left: 5px solid $primary-low;
background-color: blend-primary-secondary(5%);
}
2016-01-03 02:49:52 -05:00
// We still need -webkit for latest iPhone and Safari
@mixin transform($transforms) {
-webkit-transform: $transforms;
transform: $transforms;
}
@mixin appearance-none() {
// resets default browser styles
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
}
Upgrade to FontAwesome 5 (take two) (#6673) * Add missing icons to set * Revert FA5 revert This reverts commit 42572ff * use new SVG syntax in locales * Noscript page changes (remove login button, center "powered by" footer text) * Cast wider net for SVG icons in settings - include any _icon setting for SVG registry (offers better support for plugin settings) - let themes store multiple pipe-delimited icons in a setting - also replaces broken onebox image icon with SVG reference in cooked post processor * interpolate icons in locales * Fix composer whisper icon alignment * Add support for stacked icons * SECURITY: enforce hostname to match discourse hostname This ensures that the hostname rails uses for various helpers always matches the Discourse hostname * load SVG sprite with pre-initializers * FIX: enable caching on SVG sprites * PERF: use JSONP for SVG sprites so they are served from CDN This avoids needing to deal with CORS for loading of the SVG Note, added the svg- prefix to the filename so we can quickly tell in dev tools what the file is * Add missing SVG sprite JSONP script to CSP * Upgrade to FA 5.5.0 * Add support for all FA4.7 icons - adds complete frontend and backend for renamed FA4.7 icons - improves performance of SvgSprite.bundle and SvgSprite.all_icons * Fix group avatar flair preview - adds an endpoint at /svg-sprites/search/:keyword - adds frontend ajax call that pulls icon in avatar flair preview even when it is not in subset * Remove FA 4.7 font files
2018-11-26 16:49:57 -05:00
@mixin fa-rotate($degrees, $rotation) {
-ms-filter: "progid:DXImageTransform.Microsoft.BasicImage(rotation=#{$rotation})";
-webkit-transform: rotate($degrees);
-ms-transform: rotate($degrees);
transform: rotate($degrees);
}
/// Helper function to easily use an SVG inline in CSS
/// without encoding it to base64, saving bytes.
/// It also helps with browser support, especially for IE11.
///
/// @author Jakob Eriksen
/// @link http://codepen.io/jakob-e/pen/doMoML
/// @param {String} $svg - SVG image to encode
/// @return {String} - Encoded SVG data uri
@function svg-uri($svg) {
$encoded: "";
$slice: 2000;
$index: 0;
$loops: ceil(str-length($svg) / $slice);
@for $i from 1 through $loops {
$chunk: str-slice($svg, $index, $index + $slice - 1);
$chunk: str-replace($chunk, '"', "'");
$chunk: str-replace($chunk, "<", "%3C");
$chunk: str-replace($chunk, ">", "%3E");
$chunk: str-replace($chunk, "&", "%26");
$chunk: str-replace($chunk, "#", "%23");
$encoded: #{$encoded}#{$chunk};
$index: $index + $slice;
}
@return url("data:image/svg+xml;charset=utf8,#{$encoded}");
}
/// Replace `$search` with `$replace` in `$string`
/// @author Hugo Giraudel
/// @link http://sassmeister.com/gist/1b4f2da5527830088e4d
/// @param {String} $string - Initial string
/// @param {String} $search - Substring to replace
/// @param {String} $replace ('') - New value
/// @return {String} - Updated string
@function str-replace($string, $search, $replace: "") {
$index: str-index($string, $search);
@if $index {
@return str-slice($string, 1, $index - 1) + $replace +
str-replace(
str-slice($string, $index + str-length($search)),
$search,
$replace
);
}
@return $string;
}