Labelable.scss 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. /**
  2. * Creates a visual theme for "labelable" form items. Provides visual styling for the
  3. * Label and error message that can be shared between many types of form fields.
  4. *
  5. * @param {string} $ui
  6. * The name of the UI being created. Can not included spaces or special punctuation
  7. * (used in CSS class names).
  8. *
  9. * @param {color} [$ui-font-color=$form-label-font-color]
  10. * The text color the label
  11. *
  12. * @param {string} [$ui-font-weight=$form-label-font-weight]
  13. * The font-weight of the label
  14. *
  15. * @param {number} [$ui-font-size=$form-label-font-size]
  16. * The font-size of the label
  17. *
  18. * @param {string} [$ui-font-family=$form-label-font-family]
  19. * The font-family the label
  20. *
  21. * @param {number} [$ui-height=$form-field-height]
  22. * The height of the label. This should be the same height as the height of fields that
  23. * this label ui will be used with. This does not actually set the height of the label
  24. * but is used to ensure that the label is centered within the given height.
  25. *
  26. * @param {number} [$ui-line-height=$form-label-line-height]
  27. * The line-height of the label
  28. *
  29. * @param {number} [$ui-horizontal-spacing=$form-label-horizontal-spacing]
  30. * Horizontal space between the label and the field body when the label is left-aligned.
  31. *
  32. * @param {number} [$ui-vertical-spacing=$form-label-vertical-spacing]
  33. * Vertical space between the label and the field body when the label is top-aligned.
  34. *
  35. * @param {number} [$ui-error-icon-background-image=$form-error-icon-background-image]
  36. * The background-image of the error icon
  37. *
  38. * @param {number} [$ui-error-icon-width=$form-error-icon-width]
  39. * The width of the error icon
  40. *
  41. * @param {number} [$ui-error-icon-height=$form-error-icon-height]
  42. * The height of the error icon
  43. *
  44. * @param {number/list} [$ui-error-icon-side-margin=$form-error-icon-side-margin]
  45. * Margin for error icons when aligned to the side of the field
  46. *
  47. * @param {number} [$ui-error-under-icon-spacing=$form-error-under-icon-spacing]
  48. * The space between the icon and the message for errors that display under the field
  49. *
  50. * @param {number/list} [$ui-error-under-padding=$form-error-under-padding]
  51. * The padding on errors that display under the form field
  52. *
  53. * @param {color} [$ui-error-msg-color=$form-error-msg-color]
  54. * The text color of form error messages
  55. *
  56. * @param {string} [$ui-error-msg-font-weight=$form-error-msg-font-weight]
  57. * The font-weight of form error messages
  58. *
  59. * @param {number} [$ui-error-msg-font-size=$form-error-msg-font-size]
  60. * The font-size of form error messages
  61. *
  62. * @param {string} [$ui-error-msg-font-family=$form-error-msg-font-family]
  63. * The font-family of form error messages
  64. *
  65. * @param {number} [$ui-error-msg-line-height=$form-error-msg-line-height]
  66. * The line-height of form error messages
  67. *
  68. * @param {number} [$ui-disabled-opacity=$form-field-disabled-opacity]
  69. * Opacity of disabled form fields
  70. *
  71. * @member Ext.form.Labelable
  72. */
  73. @mixin extjs-label-ui(
  74. $ui: null,
  75. $ui-font-color: $form-label-font-color,
  76. $ui-font-weight: $form-label-font-weight,
  77. $ui-font-size: $form-label-font-size,
  78. $ui-font-family: $form-label-font-family,
  79. $ui-height: $form-field-height,
  80. $ui-line-height: $form-label-line-height,
  81. $ui-horizontal-spacing: $form-label-horizontal-spacing,
  82. $ui-vertical-spacing: $form-label-vertical-spacing,
  83. $ui-error-icon-background-image: $form-error-icon-background-image,
  84. $ui-error-icon-width: $form-error-icon-width,
  85. $ui-error-icon-height: $form-error-icon-height,
  86. $ui-error-icon-side-margin: $form-error-icon-side-margin,
  87. $ui-error-under-icon-spacing: $form-error-under-icon-spacing,
  88. $ui-error-under-padding: $form-error-under-padding,
  89. $ui-error-msg-color: $form-error-msg-color,
  90. $ui-error-msg-font-weight: $form-error-msg-font-weight,
  91. $ui-error-msg-font-size: $form-error-msg-font-size,
  92. $ui-error-msg-font-family: $form-error-msg-font-family,
  93. $ui-error-msg-line-height: $form-error-msg-line-height,
  94. $ui-disabled-opacity: $form-field-disabled-opacity
  95. ) {
  96. $ui-error-wrap-width: $ui-error-icon-width + horizontal($ui-error-icon-side-margin);
  97. .#{$prefix}form-item-label-#{$ui} {
  98. $padding-top: round(($ui-height - $ui-line-height) / 2);
  99. color: $ui-font-color;
  100. font: $ui-font-weight #{$ui-font-size}/#{$ui-line-height} $ui-font-family;
  101. min-height: $ui-height;
  102. padding-top: $padding-top;
  103. padding-right: $ui-horizontal-spacing;
  104. @if $include-rtl {
  105. &.#{$prefix}rtl {
  106. padding-left: $ui-horizontal-spacing;
  107. padding-right: 0;
  108. }
  109. }
  110. @if $include-ie {
  111. .#{$prefix}ie8 & {
  112. // min-height triggers content-box sizing on IE8, so subtract padding
  113. min-height: $ui-height - $padding-top;
  114. }
  115. }
  116. &.#{$prefix}form-item-label-top {
  117. height: 1px;
  118. > .#{$prefix}form-item-label-inner {
  119. padding-top: round(($ui-height - $ui-line-height) / 2);
  120. padding-bottom: $ui-vertical-spacing;
  121. }
  122. }
  123. &.#{$prefix}form-item-label-top-side-error:after {
  124. width: $ui-error-wrap-width;
  125. }
  126. }
  127. .#{$prefix}form-item-body-#{$ui} {
  128. min-height: $ui-height;
  129. }
  130. .#{$prefix}form-invalid-icon-#{$ui} {
  131. width: $ui-error-icon-width;
  132. height: $ui-error-icon-height;
  133. margin: $ui-error-icon-side-margin;
  134. background: theme-background-image($ui-error-icon-background-image) no-repeat;
  135. }
  136. .#{$prefix}form-invalid-under-#{$ui} {
  137. padding: top($ui-error-under-padding) right($ui-error-under-padding) bottom($ui-error-under-padding) (left($ui-error-under-padding) + $ui-error-icon-width + $ui-error-under-icon-spacing);
  138. color: $ui-error-msg-color;
  139. font: $ui-error-msg-font-weight #{$ui-error-msg-font-size}/#{$ui-error-msg-line-height} $ui-error-msg-font-family;
  140. background: no-repeat left($ui-error-under-padding) top($ui-error-under-padding);
  141. background-image: theme-background-image($ui-error-icon-background-image);
  142. }
  143. .#{$prefix}form-error-wrap-#{$ui}.#{$prefix}form-error-wrap-side {
  144. width: $ui-error-wrap-width;
  145. }
  146. @if $ui-disabled-opacity != 1 {
  147. .#{$prefix}form-item-#{$ui}.#{$prefix}item-disabled {
  148. @include opacity($ui-disabled-opacity);
  149. }
  150. }
  151. }