mirror of
https://github.com/ionic-team/ionic-framework.git
synced 2025-08-18 19:21:34 +08:00
298 lines
5.7 KiB
SCSS
298 lines
5.7 KiB
SCSS
|
|
// Core Button Variables
|
|
// --------------------------------------------------
|
|
|
|
$button-font-size: 1.6rem !default;
|
|
$button-margin: 0.4rem 0 !default;
|
|
$button-padding: 0 2rem !default;
|
|
$button-height: 4.4rem !default;
|
|
$button-border-width: 1px !default;
|
|
$button-border-radius: 4px !default;
|
|
$button-icon-size: 2.5rem !default;
|
|
|
|
$button-large-font-size: 2rem !default;
|
|
$button-large-height: 5.4rem !default;
|
|
$button-large-padding: 1.4rem !default;
|
|
$button-large-icon-size: 3.6rem !default;
|
|
|
|
$button-small-font-size: 1.3rem !default;
|
|
$button-small-height: 2.8rem !default;
|
|
$button-small-padding: 1.1rem !default;
|
|
$button-small-icon-size: 2.1rem !default;
|
|
|
|
$button-fab-size: 56px;
|
|
|
|
$button-round-border-radius: 64px !default;
|
|
$button-round-padding: 0 2.6rem !default;
|
|
|
|
|
|
// Core Button
|
|
// --------------------------------------------------
|
|
|
|
button,
|
|
[button] {
|
|
position: relative;
|
|
display: inline-flex;
|
|
flex-shrink: 0;
|
|
flex-flow: row nowrap;
|
|
align-items: center;
|
|
justify-content: center;
|
|
|
|
will-change: transform;
|
|
|
|
margin: $button-margin;
|
|
line-height: 1.1;
|
|
|
|
@include appearance(none);
|
|
|
|
vertical-align: top; // the better option for most scenarios
|
|
vertical-align: -webkit-baseline-middle; // the best for those that support it
|
|
|
|
font-family: inherit;
|
|
font-variant: inherit;
|
|
font-style: inherit;
|
|
|
|
white-space: nowrap;
|
|
text-overflow: ellipsis;
|
|
overflow: hidden;
|
|
|
|
cursor: pointer;
|
|
user-select: none;
|
|
|
|
border: 1px solid #ccc;
|
|
padding: $button-padding;
|
|
min-height: $button-height;
|
|
// Default button has no background
|
|
background: transparent;
|
|
|
|
text-align: center;
|
|
font-size: $button-font-size;
|
|
border: transparent;
|
|
border-radius: $button-border-radius;
|
|
|
|
&[icon] {
|
|
font-size: $button-icon-size;
|
|
background: none;
|
|
border: none;
|
|
}
|
|
|
|
&[large] {
|
|
padding: 0 $button-large-padding;
|
|
min-width: ($button-large-padding * 4);
|
|
min-height: $button-large-height;
|
|
font-size: $button-large-font-size;
|
|
|
|
&[icon] {
|
|
font-size: $button-large-icon-size;
|
|
}
|
|
}
|
|
|
|
&[small] {
|
|
padding: 0 $button-small-padding;
|
|
min-width: ($button-small-padding * 3);
|
|
min-height: $button-small-height;
|
|
font-size: $button-small-font-size;
|
|
|
|
&[icon] {
|
|
font-size: $button-small-icon-size;
|
|
}
|
|
}
|
|
|
|
|
|
// Core Button Types
|
|
// --------------------------------------------------
|
|
|
|
&[clear] {
|
|
border-color: transparent;
|
|
background: none;
|
|
}
|
|
|
|
&[outline] {
|
|
background: none;
|
|
|
|
&.activated {
|
|
opacity: 0.3 !important;
|
|
}
|
|
}
|
|
|
|
&[block] {
|
|
display: flex;
|
|
clear: both;
|
|
margin-right: 0;
|
|
margin-left: 0;
|
|
width: 100%;
|
|
|
|
&:after {
|
|
clear: both;
|
|
}
|
|
}
|
|
|
|
&[full] {
|
|
width: 100%;
|
|
border-radius: 0;
|
|
}
|
|
|
|
&.disabled,
|
|
&[disabled] {
|
|
opacity: .4;
|
|
cursor: default !important;
|
|
pointer-events: none;
|
|
}
|
|
|
|
&[round] {
|
|
border-radius: $button-round-border-radius;
|
|
padding: $button-round-padding;
|
|
}
|
|
|
|
// FABulous buttons (Floating action button from material)
|
|
|
|
&[fab] {
|
|
position: absolute;
|
|
width: $button-fab-size;
|
|
height: $button-fab-size;
|
|
line-height: $button-fab-size;
|
|
min-width: 0;
|
|
vertical-align: middle;
|
|
|
|
border-radius: 50%;
|
|
background-clip: padding-box;
|
|
|
|
overflow: hidden;
|
|
|
|
transition: .2s linear;
|
|
transition-property: background-color;
|
|
|
|
font-size: 14px;
|
|
|
|
&[fab-center] {
|
|
left: 50%;
|
|
margin-left: -$button-fab-size/2;
|
|
}
|
|
&[fab-top] {
|
|
top: 16px;
|
|
}
|
|
&[fab-right] {
|
|
right: 16px;
|
|
}
|
|
&[fab-bottom] {
|
|
bottom: 16px;
|
|
}
|
|
&[fab-left] {
|
|
left: 16px;
|
|
}
|
|
|
|
.icon {
|
|
flex: 1;
|
|
}
|
|
}
|
|
}
|
|
|
|
[full],
|
|
[full] > button,
|
|
[full] > [button] {
|
|
display: flex;
|
|
margin-right: 0;
|
|
margin-left: 0;
|
|
width: 100%;
|
|
border-radius: 0;
|
|
|
|
&[outline][outline] {
|
|
border-right-width: 0;
|
|
border-left-width: 0;
|
|
}
|
|
}
|
|
|
|
.padding > button[block]:first-child,
|
|
.padding > [button][block]:first-child {
|
|
margin-top: 0;
|
|
}
|
|
|
|
.icon-left:before {
|
|
font-size: 1.5em;
|
|
margin-top: -0.1em;
|
|
margin-right: 0.25em;
|
|
}
|
|
|
|
.icon-right:before {
|
|
order: 2;
|
|
font-size: 1.5em;
|
|
margin-top: -0.1em;
|
|
margin-left: 0.25em;
|
|
}
|
|
|
|
|
|
// Button Misc
|
|
// --------------------------------------------------
|
|
|
|
a[button] {
|
|
color: inherit;
|
|
text-decoration: none;
|
|
}
|
|
|
|
|
|
// Core Button Mixins
|
|
// --------------------------------------------------
|
|
|
|
@mixin button-default($bg-color, $fg-color) {
|
|
background-color: $bg-color;
|
|
color: $fg-color;
|
|
transition: background-color,opacity 100ms linear;
|
|
|
|
&:hover,
|
|
&.hover {
|
|
opacity: 0.88;
|
|
color: $fg-color;
|
|
text-decoration: none;
|
|
}
|
|
|
|
&.activated {
|
|
opacity: 1;
|
|
background-color: darken($bg-color, 12%);
|
|
}
|
|
}
|
|
|
|
@mixin button-clear($fg-color) {
|
|
&[clear] {
|
|
color: $fg-color;
|
|
background: none;
|
|
}
|
|
}
|
|
|
|
@mixin button-outline($fg-color) {
|
|
&[outline] {
|
|
border: 1px solid $fg-color;
|
|
background: transparent;
|
|
color: $fg-color;
|
|
|
|
&.activated {
|
|
color: white;
|
|
background-color: rgb(red($fg-color), green($fg-color), blue($fg-color));//, 0.15);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
// Core Button Color Generation
|
|
// --------------------------------------------------
|
|
|
|
@each $color, $value in $colors {
|
|
|
|
button[#{$color}],
|
|
[button][#{$color}] {
|
|
|
|
@if lightness(get-color($color, base)) > 90 {
|
|
$fg-color: get-color($color, inverse);
|
|
} @else {
|
|
$fg-color: get-color($color, base);
|
|
}
|
|
|
|
@include button-default(get-color($color, base),
|
|
get-color($color, inverse));
|
|
|
|
@include button-clear($fg-color);
|
|
|
|
@include button-outline(get-color($color, light));
|
|
}
|
|
|
|
}
|