mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-11-07 06:57:02 +08:00
443 lines
11 KiB
SCSS
443 lines
11 KiB
SCSS
// _mixins.scss
|
|
//
|
|
// Useful utilities and mixins for SCSS files.
|
|
|
|
@mixin button-style($bgColor, $borderColor, $activeBgColor, $activeBorderColor, $color) {
|
|
color: $color;
|
|
background-color: $bgColor;
|
|
border-color: $borderColor;
|
|
|
|
// Give desktop users something to play with
|
|
&:hover {
|
|
color: $color;
|
|
text-decoration: none;
|
|
}
|
|
&.active, &:active {
|
|
background-color: $activeBgColor;
|
|
box-shadow: inset 0px 1px 3px rgba(0,0,0,0.15);
|
|
border-color: $activeBorderColor;
|
|
}
|
|
}
|
|
|
|
@mixin button-clear($color, $fontSize:"") {
|
|
&.button-clear {
|
|
color: $color;
|
|
background: none;
|
|
box-shadow: none;
|
|
|
|
@if $fontSize != "" {
|
|
font-size: $fontSize;
|
|
}
|
|
}
|
|
}
|
|
|
|
@mixin button-outline($color, $textColor:"") {
|
|
&.button-outline {
|
|
border-color: $color;
|
|
@if $textColor == "" {
|
|
$textColor: $color;
|
|
}
|
|
color: $textColor;
|
|
&.active, &:active {
|
|
background-color: $color;
|
|
color: #fff;
|
|
box-shadow: none;
|
|
}
|
|
}
|
|
}
|
|
|
|
@mixin item-style($bgColor, $borderColor, $color) {
|
|
color: $color;
|
|
background-color: $bgColor;
|
|
border-color: $borderColor;
|
|
|
|
// Give desktop users something to play with
|
|
&:hover {
|
|
color: $color;
|
|
text-decoration: none;
|
|
}
|
|
&.active, &:active {
|
|
background-color: darken($bgColor, 8%);
|
|
box-shadow: inset 0px 1px 3px rgba(0,0,0,0.12);
|
|
border-color: darken($borderColor, 10%);
|
|
}
|
|
}
|
|
|
|
//$bgColor, $borderColor, $color,
|
|
@mixin item-style-active($activeBgColor, $activeBorderColor, $activeColor) {
|
|
&.active, &:active {
|
|
color: $activeColor;
|
|
background-color: $activeBgColor;
|
|
border-color: $activeBorderColor;
|
|
|
|
.list-item-content {
|
|
background-color: $activeBgColor;
|
|
color: $activeColor;
|
|
}
|
|
}
|
|
};
|
|
|
|
@mixin bar-style($bgColor, $borderColor, $color) {
|
|
background-color: $bgColor;
|
|
border-color: $borderColor;
|
|
background-image: linear-gradient(0deg, $borderColor, $borderColor 50%, transparent 50%);
|
|
|
|
color: $color;
|
|
|
|
.title {
|
|
color: $color;
|
|
}
|
|
}
|
|
|
|
@mixin tab-style($bgColor, $borderColor, $color) {
|
|
background-color: $bgColor;
|
|
border-color: $borderColor;
|
|
color: $color;
|
|
}
|
|
|
|
|
|
// UTILITY MIXINS
|
|
// --------------------------------------------------
|
|
|
|
// Clearfix
|
|
// --------
|
|
// For clearing floats like a boss h5bp.com/q
|
|
@mixin clearfix {
|
|
*zoom: 1;
|
|
&:before,
|
|
&:after {
|
|
display: table;
|
|
content: "";
|
|
// Fixes Opera/contenteditable bug:
|
|
// http://nicolasgallagher.com/micro-clearfix-hack/#comment-36952
|
|
line-height: 0;
|
|
}
|
|
&:after {
|
|
clear: both;
|
|
}
|
|
}
|
|
// Center-align a block level element
|
|
// ----------------------------------
|
|
@mixin center-block() {
|
|
display: block;
|
|
margin-left: auto;
|
|
margin-right: auto;
|
|
}
|
|
|
|
|
|
// Sizing shortcuts
|
|
// -------------------------
|
|
@mixin size($height, $width) {
|
|
width: $width;
|
|
height: $height;
|
|
}
|
|
@mixin square($size) {
|
|
@include size($size, $size);
|
|
}
|
|
|
|
// Placeholder text
|
|
// -------------------------
|
|
@mixin placeholder($color: $input-color-placeholder) {
|
|
&:-moz-placeholder {
|
|
color: $color;
|
|
}
|
|
&:-ms-input-placeholder {
|
|
color: $color;
|
|
}
|
|
&::-webkit-input-placeholder {
|
|
color: $color;
|
|
}
|
|
}
|
|
|
|
// Text overflow
|
|
// -------------------------
|
|
// Requires inline-block or block for proper styling
|
|
@mixin text-overflow() {
|
|
overflow: hidden;
|
|
text-overflow: ellipsis;
|
|
white-space: nowrap;
|
|
}
|
|
|
|
|
|
// FONTS
|
|
// --------------------------------------------------
|
|
|
|
@mixin font-family-serif() {
|
|
font-family: $serif-font-family;
|
|
}
|
|
@mixin font-family-sans-serif() {
|
|
font-family: $sans-font-family;
|
|
}
|
|
@mixin font-family-monospace() {
|
|
font-family: $mono-font-family;
|
|
}
|
|
@mixin font-shorthand($size: $baseFontSize, $weight: normal, $lineHeight: $baseLineHeight) {
|
|
font-size: $size;
|
|
font-weight: $weight;
|
|
line-height: $lineHeight;
|
|
}
|
|
@mixin font-serif($size: $baseFontSize, $weight: normal, $lineHeight: $baseLineHeight) {
|
|
@include font-family-serif();
|
|
@include font-shorthand($size, $weight, $lineHeight);
|
|
}
|
|
@mixin font-sans-serif($size: $baseFontSize, $weight: normal, $lineHeight: $baseLineHeight) {
|
|
@include font-family-sans-serif();
|
|
@include font-shorthand($size, $weight, $lineHeight);
|
|
}
|
|
@mixin font-monospace($size: $baseFontSize, $weight: normal, $lineHeight: $baseLineHeight) {
|
|
@include font-family-monospace();
|
|
@include font-shorthand($size, $weight, $lineHeight);
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// CSS3 PROPERTIES
|
|
// --------------------------------------------------
|
|
|
|
// Border Radius
|
|
@mixin border-radius($radius) {
|
|
-webkit-border-radius: $radius;
|
|
-moz-border-radius: $radius;
|
|
border-radius: $radius;
|
|
}
|
|
|
|
// Single Corner Border Radius
|
|
@mixin border-top-left-radius($radius) {
|
|
-webkit-border-top-left-radius: $radius;
|
|
-moz-border-radius-topleft: $radius;
|
|
border-top-left-radius: $radius;
|
|
}
|
|
@mixin border-top-right-radius($radius) {
|
|
-webkit-border-top-right-radius: $radius;
|
|
-moz-border-radius-topright: $radius;
|
|
border-top-right-radius: $radius;
|
|
}
|
|
@mixin border-bottom-right-radius($radius) {
|
|
-webkit-border-bottom-right-radius: $radius;
|
|
-moz-border-radius-bottomright: $radius;
|
|
border-bottom-right-radius: $radius;
|
|
}
|
|
@mixin border-bottom-left-radius($radius) {
|
|
-webkit-border-bottom-left-radius: $radius;
|
|
-moz-border-radius-bottomleft: $radius;
|
|
border-bottom-left-radius: $radius;
|
|
}
|
|
|
|
// Single Side Border Radius
|
|
@mixin border-top-radius($radius) {
|
|
@include border-top-right-radius($radius);
|
|
@include border-top-left-radius($radius);
|
|
}
|
|
@mixin border-right-radius($radius) {
|
|
@include border-top-right-radius($radius);
|
|
@include border-bottom-right-radius($radius);
|
|
}
|
|
@mixin border-bottom-radius($radius) {
|
|
@include border-bottom-right-radius($radius);
|
|
@include border-bottom-left-radius($radius);
|
|
}
|
|
@mixin border-left-radius($radius) {
|
|
@include border-top-left-radius($radius);
|
|
@include border-bottom-left-radius($radius);
|
|
}
|
|
|
|
// Drop shadows
|
|
@mixin box-shadow($shadow...) {
|
|
-webkit-box-shadow: $shadow;
|
|
-moz-box-shadow: $shadow;
|
|
box-shadow: $shadow;
|
|
}
|
|
|
|
// Transitions
|
|
@mixin transition($transition...) {
|
|
-webkit-transition: $transition;
|
|
transition: $transition;
|
|
}
|
|
@mixin transition-delay($transition-delay) {
|
|
-webkit-transition-delay: $transition-delay;
|
|
transition-delay: $transition-delay;
|
|
}
|
|
@mixin transition-duration($transition-duration) {
|
|
-webkit-transition-duration: $transition-duration;
|
|
transition-duration: $transition-duration;
|
|
}
|
|
|
|
// Transformations
|
|
@mixin rotate($degrees) {
|
|
-webkit-transform: rotate($degrees);
|
|
transform: rotate($degrees);
|
|
}
|
|
@mixin scale($ratio) {
|
|
-webkit-transform: scale($ratio);
|
|
transform: scale($ratio);
|
|
}
|
|
@mixin translate($x, $y) {
|
|
-webkit-transform: translate($x, $y);
|
|
transform: translate($x, $y);
|
|
}
|
|
@mixin skew($x, $y) {
|
|
-webkit-transform: skew($x, $y);
|
|
transform: skew($x, $y);
|
|
-webkit-backface-visibility: hidden; // See https://github.com/twitter/bootstrap/issues/5319
|
|
}
|
|
@mixin translate3d($x, $y, $z) {
|
|
-webkit-transform: translate3d($x, $y, $z);
|
|
transform: translate3d($x, $y, $z);
|
|
}
|
|
|
|
// Backface visibility
|
|
// Prevent browsers from flickering when using CSS 3D transforms.
|
|
// Default value is `visible`, but can be changed to `hidden
|
|
// See git pull https://github.com/dannykeane/bootstrap.git backface-visibility for examples
|
|
@mixin backface-visibility($visibility){
|
|
-webkit-backface-visibility: $visibility;
|
|
backface-visibility: $visibility;
|
|
}
|
|
|
|
// Background clipping
|
|
@mixin background-clip($clip) {
|
|
-webkit-background-clip: $clip;
|
|
-moz-background-clip: $clip;
|
|
background-clip: $clip;
|
|
}
|
|
|
|
// Background sizing
|
|
@mixin background-size($size) {
|
|
-webkit-background-size: $size;
|
|
-moz-background-size: $size;
|
|
-o-background-size: $size;
|
|
background-size: $size;
|
|
}
|
|
|
|
|
|
// Box sizing
|
|
@mixin box-sizing($boxmodel) {
|
|
-webkit-box-sizing: $boxmodel;
|
|
-moz-box-sizing: $boxmodel;
|
|
box-sizing: $boxmodel;
|
|
}
|
|
|
|
// User select
|
|
// For selecting text on the page
|
|
@mixin user-select($select) {
|
|
-webkit-user-select: $select;
|
|
-moz-user-select: $select;
|
|
-ms-user-select: $select;
|
|
-o-user-select: $select;
|
|
user-select: $select;
|
|
}
|
|
|
|
// CSS3 Content Columns
|
|
@mixin content-columns($columnCount, $columnGap: $gridGutterWidth) {
|
|
-webkit-column-count: $columnCount;
|
|
-moz-column-count: $columnCount;
|
|
column-count: $columnCount;
|
|
-webkit-column-gap: $columnGap;
|
|
-moz-column-gap: $columnGap;
|
|
column-gap: $columnGap;
|
|
}
|
|
|
|
// Optional hyphenation
|
|
@mixin hyphens($mode: auto) {
|
|
word-wrap: break-word;
|
|
-webkit-hyphens: $mode;
|
|
-moz-hyphens: $mode;
|
|
-ms-hyphens: $mode;
|
|
-o-hyphens: $mode;
|
|
hyphens: $mode;
|
|
}
|
|
|
|
@mixin box-orient($orientation) {
|
|
box-orient: $orientation;
|
|
-webkit-box-orient: $orientation;
|
|
-moz-box-orient: $orientation;
|
|
}
|
|
|
|
@mixin box-flex($flex) {
|
|
box-flex: 1;
|
|
-webkit-box-flex: $flex;
|
|
-moz-box-flex: $flex;
|
|
}
|
|
|
|
@mixin display-flex {
|
|
display: -webkit-box;
|
|
display: -webkit-flex;
|
|
display: -moz-flex;
|
|
display: -ms-flexbox;
|
|
display: flex;
|
|
}
|
|
|
|
@mixin dislay-inline-flex {
|
|
display: -webkit-inline-box;
|
|
display: -webkit-inline-flex;
|
|
display: -moz-inline-flex;
|
|
display: -ms-inline-flexbox;
|
|
display: inline-flex;
|
|
}
|
|
|
|
@mixin flex-direction($value: row) {
|
|
@if $value == row-reverse {
|
|
-webkit-box-direction: reverse;
|
|
-webkit-box-orient: horizontal;
|
|
} @else if $value == column {
|
|
-webkit-box-direction: normal;
|
|
-webkit-box-orient: vertical;
|
|
} @else if $value == column-reverse {
|
|
-webkit-box-direction: reverse;
|
|
-webkit-box-orient: vertical;
|
|
} @else {
|
|
-webkit-box-direction: normal;
|
|
-webkit-box-orient: horizontal;
|
|
}
|
|
-webkit-flex-direction: $value;
|
|
-moz-flex-direction: $value;
|
|
-ms-flex-direction: $value;
|
|
flex-direction: $value;
|
|
}
|
|
|
|
@mixin flex-wrap($value: nowrap) {
|
|
// No Webkit Box fallback.
|
|
-webkit-flex-wrap: $value;
|
|
-moz-flex-wrap: $value;
|
|
@if $value == nowrap {
|
|
-ms-flex-wrap: none;
|
|
} @else {
|
|
-ms-flex-wrap: $value;
|
|
}
|
|
flex-wrap: $value;
|
|
}
|
|
|
|
@mixin flex($fg: 1, $fs: null, $fb: null) {
|
|
-webkit-box-flex: $fg;
|
|
-webkit-flex: $fg $fs $fb;
|
|
-moz-box-flex: $fg;
|
|
-moz-flex: $fg $fs $fb;
|
|
-ms-flex: $fg $fs $fb;
|
|
flex: $fg $fs $fb;
|
|
}
|
|
|
|
@mixin flex-flow($values: (row nowrap)) {
|
|
// No Webkit Box fallback.
|
|
-webkit-flex-flow: $values;
|
|
-moz-flex-flow: $values;
|
|
-ms-flex-flow: $values;
|
|
flex-flow: $values;
|
|
}
|
|
|
|
@mixin align-items($value: stretch) {
|
|
@if $value == flex-start {
|
|
-webkit-box-align: start;
|
|
-ms-flex-align: start;
|
|
} @else if $value == flex-end {
|
|
-webkit-box-align: end;
|
|
-ms-flex-align: end;
|
|
} @else {
|
|
-webkit-box-align: $value;
|
|
-ms-flex-align: $value;
|
|
}
|
|
-webkit-align-items: $value;
|
|
-moz-align-items: $value;
|
|
align-items: $value;
|
|
} |