-
Notifications
You must be signed in to change notification settings - Fork 841
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moving form variables and mixins to their own file
- Loading branch information
cchaos
committed
Mar 30, 2018
1 parent
d59b6b8
commit 6480f85
Showing
3 changed files
with
152 additions
and
152 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,147 @@ | ||
@mixin euiFormControlSize { | ||
max-width: $euiFormMaxWidth; | ||
width: 100%; | ||
} | ||
|
||
@mixin euiFormControlWithIcon($isIconOptional: false) { | ||
$iconPadding: $euiSizeXXL; | ||
|
||
@if ($isIconOptional) { | ||
@at-root { | ||
#{&}--withIcon { | ||
padding-left: $iconPadding; | ||
} | ||
} | ||
} @else { | ||
padding-left: $iconPadding; | ||
} | ||
} | ||
|
||
@mixin euiFormControlIsLoading($isNextToIcon: false) { | ||
|
||
@at-root { | ||
#{&}-isLoading { | ||
@if ($isNextToIcon) { | ||
padding-right: $euiSizeXXL + $euiSize; | ||
} @else { | ||
padding-right: $euiSizeXXL; | ||
} | ||
} | ||
} | ||
} | ||
|
||
@mixin euiFormControlDefaultShadow { | ||
box-shadow: | ||
0 2px 2px -1px rgba(0, 0, 0, 0.1), | ||
0 0 0 1px transparentize($euiColorFullShade, .92), | ||
inset #{-$euiFormMaxWidth} 0 0 0 $euiFormBackgroundColor; | ||
} | ||
|
||
@mixin euiFormControlInvalidStyle { | ||
box-shadow: | ||
0 $euiSizeXS $euiSizeXS (-$euiSizeXS / 2) rgba(0, 0, 0, 0.1), | ||
0 0 0 1px transparentize($euiColorFullShade, .84), | ||
inset 0 0 0 0 $euiColorEmptyShade, | ||
inset 0 (-$euiSizeXS / 2) 0 0 $euiColorDanger; | ||
} | ||
|
||
@mixin euiFormControlFocusStyle { | ||
background: tintOrShade($euiColorEmptyShade, 0%, 20%); | ||
box-shadow: | ||
0 4px 4px -2px rgba(0, 0, 0, 0.1), | ||
0 0 0 1px transparentize($euiColorFullShade, .84), | ||
inset 0 0 0 0 tintOrShade($euiColorEmptyShade, 0%, 20%), | ||
inset 0 -2px 0 0 $euiColorPrimary; | ||
} | ||
|
||
@mixin euiFormControlDisabledStyle { | ||
cursor: not-allowed; | ||
background: darken($euiColorLightestShade, 2%); | ||
box-shadow: 0 0 0 1px transparentize($euiColorFullShade, .92); | ||
} | ||
|
||
/** | ||
* 1. Override invalid state with focus state. | ||
*/ | ||
@mixin euiFormControlStyle { | ||
@include euiFormControlSize; | ||
@include euiFormControlDefaultShadow; | ||
|
||
border: none; | ||
font-size: $euiFontSizeS; | ||
font-family: $euiFontFamily; | ||
padding: $euiSizeM; | ||
color: $euiTextColor; | ||
background: $euiFormBackgroundColor; | ||
transition: box-shadow $euiAnimSpeedNormal ease-in, background $euiAnimSpeedNormal ease-in; | ||
border-radius: 0; | ||
|
||
&--fullWidth { | ||
max-width: 100%; | ||
} | ||
|
||
&:invalid { /* 1 */ | ||
@include euiFormControlInvalidStyle; | ||
} | ||
|
||
&:focus { /* 1 */ | ||
@include euiFormControlFocusStyle; | ||
} | ||
|
||
&:disabled { | ||
@include euiFormControlDisabledStyle; | ||
} | ||
|
||
&[readOnly] { | ||
cursor: default; | ||
background: transparent; | ||
border-color: transparent; | ||
box-shadow: none; | ||
} | ||
} | ||
|
||
// CUSTOM STYLES & STATES | ||
@mixin euiCustomControl($type: null, $size: $euiSize){ | ||
|
||
@if $size { | ||
$size: $size - 2px; // subtract 2px from size to account for border size | ||
padding: $size/2; | ||
} | ||
|
||
border: 1px solid shadeOrTint($euiColorLightestShade, 18%, 30%); | ||
background: $euiColorEmptyShade no-repeat center; | ||
box-shadow: 0 2px 2px -1px rgba(0, 0, 0, 0.1); | ||
|
||
@if $type == 'round' { | ||
border-radius: $size; | ||
} @else if $type == 'square' { | ||
border-radius: $euiBorderRadius; | ||
} | ||
|
||
transition: background-color $euiAnimSpeedFast ease-in, | ||
border-color $euiAnimSpeedFast ease-in, | ||
background-image 0s ease-out $euiAnimSpeedFast; | ||
} | ||
|
||
@mixin euiCustomControl--selected($type: null){ | ||
border-color: $euiColorPrimary; | ||
background-color: $euiColorPrimary; | ||
|
||
@if $type != null { | ||
@include euiIconBackground($type, $euiColorEmptyShade); | ||
} | ||
} | ||
|
||
@mixin euiCustomControl--disabled($type: null){ | ||
border-color: $euiColorLightShade; | ||
background-color: $euiColorLightShade; | ||
box-shadow: none; | ||
@if $type != null { | ||
@include euiIconBackground($type, $euiFormCustomControlDisabledIconColor); | ||
} | ||
} | ||
|
||
@mixin euiCustomControl--focused(){ | ||
border-color: $euiColorPrimary; | ||
@include euiFocusRing; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
$euiFormMaxWidth: 400px; | ||
$euiFormBackgroundColor: tintOrShade($euiColorLightestShade, 60%, 25%); | ||
$euiFormCustomControlDisabledIconColor: shadeOrTint($euiColorMediumShade, 38%, 48.5%); // exact 508c foreground for $euiColorLightShade |