You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

styles.js 5.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. // @flow
  2. import { StyleSheet } from 'react-native';
  3. import { ColorSchemeRegistry, schemeColor } from '../../../color-scheme';
  4. import { BoxModel, ColorPalette, createStyleSheet } from '../../../styles';
  5. import { PREFERRED_DIALOG_SIZE } from '../../constants';
  6. const BORDER_RADIUS = 5;
  7. export const FIELD_UNDERLINE = ColorPalette.transparent;
  8. /**
  9. * NOTE: These Material guidelines based values are currently only used in
  10. * dialogs (and related) but later on it would be nice to export it into a base
  11. * Material feature.
  12. */
  13. export const MD_FONT_SIZE = 16;
  14. export const MD_ITEM_HEIGHT = 48;
  15. export const MD_ITEM_MARGIN_PADDING = 16;
  16. export const PLACEHOLDER_COLOR = ColorPalette.lightGrey;
  17. /**
  18. * The React {@code Component} styles of {@code BottomSheet}. These have
  19. * been implemented as per the Material Design guidelines:
  20. * {@link https://material.io/guidelines/components/bottom-sheets.html}.
  21. */
  22. export const bottomSheetStyles = {
  23. sheetAreaCover: {
  24. backgroundColor: ColorPalette.transparent,
  25. flex: 1
  26. },
  27. /**
  28. * Style for the container of the sheet.
  29. */
  30. sheetContainer: {
  31. alignItems: 'stretch',
  32. flex: 1,
  33. flexDirection: 'column',
  34. justifyContent: 'flex-end'
  35. },
  36. sheetItemContainer: {
  37. flex: -1,
  38. maxHeight: '60%',
  39. paddingHorizontal: MD_ITEM_MARGIN_PADDING
  40. }
  41. };
  42. export const brandedDialog = createStyleSheet({
  43. /**
  44. * The style of bold {@code Text} rendered by the {@code Dialog}s of the
  45. * feature authentication.
  46. */
  47. boldDialogText: {
  48. fontWeight: 'bold'
  49. },
  50. buttonFarLeft: {
  51. borderBottomLeftRadius: BORDER_RADIUS
  52. },
  53. buttonFarRight: {
  54. borderBottomRightRadius: BORDER_RADIUS
  55. },
  56. buttonWrapper: {
  57. alignItems: 'stretch',
  58. borderRadius: BORDER_RADIUS,
  59. flexDirection: 'row'
  60. },
  61. closeWrapper: {
  62. alignSelf: 'flex-end',
  63. padding: BoxModel.padding
  64. },
  65. mainWrapper: {
  66. alignSelf: 'stretch',
  67. padding: BoxModel.padding * 2,
  68. // The added bottom padding is to compensate the empty space around the
  69. // close icon.
  70. paddingBottom: BoxModel.padding * 3
  71. },
  72. overlay: {
  73. ...StyleSheet.absoluteFillObject,
  74. alignItems: 'center',
  75. backgroundColor: 'rgba(127, 127, 127, 0.6)',
  76. flexDirection: 'row',
  77. justifyContent: 'center',
  78. padding: 30
  79. }
  80. });
  81. /**
  82. * Reusable (colored) style for text in any branded dialogs.
  83. */
  84. const brandedDialogText = {
  85. color: schemeColor('text'),
  86. fontSize: MD_FONT_SIZE,
  87. textAlign: 'center'
  88. };
  89. export const inputDialog = createStyleSheet({
  90. bottomField: {
  91. marginBottom: 0
  92. },
  93. fieldWrapper: {
  94. ...brandedDialog.mainWrapper,
  95. paddingBottom: BoxModel.padding * 2
  96. },
  97. formMessage: {
  98. alignSelf: 'flex-start',
  99. fontStyle: 'italic',
  100. margin: BoxModel.margin
  101. }
  102. });
  103. /**
  104. * Default styles for the items of a {@code BottomSheet}-based menu.
  105. *
  106. * These have been implemented as per the Material Design guidelines:
  107. * {@link https://material.io/guidelines/components/bottom-sheets.html}.
  108. */
  109. ColorSchemeRegistry.register('BottomSheet', {
  110. /**
  111. * Style for the {@code Icon} element in a generic item of the menu.
  112. */
  113. iconStyle: {
  114. color: schemeColor('icon'),
  115. fontSize: 24
  116. },
  117. /**
  118. * Style for the label in a generic item rendered in the menu.
  119. */
  120. labelStyle: {
  121. color: schemeColor('label'),
  122. flexShrink: 1,
  123. fontSize: MD_FONT_SIZE,
  124. marginLeft: 32,
  125. opacity: 0.90
  126. },
  127. /**
  128. * Bottom sheet's base style.
  129. */
  130. sheet: {
  131. backgroundColor: schemeColor('background')
  132. },
  133. /**
  134. * Container style for a generic item rendered in the menu.
  135. */
  136. style: {
  137. alignItems: 'center',
  138. flexDirection: 'row',
  139. height: MD_ITEM_HEIGHT
  140. },
  141. /**
  142. * Additional style that is not directly used as a style object.
  143. */
  144. underlayColor: ColorPalette.overflowMenuItemUnderlay
  145. });
  146. /**
  147. * Color schemed styles for all the component based on the abstract dialog.
  148. */
  149. ColorSchemeRegistry.register('Dialog', {
  150. button: {
  151. backgroundColor: schemeColor('buttonBackground'),
  152. flex: 1,
  153. padding: BoxModel.padding * 1.5
  154. },
  155. /**
  156. * Separator line for the buttons in a dialog.
  157. */
  158. buttonSeparator: {
  159. borderRightColor: schemeColor('border'),
  160. borderRightWidth: 1
  161. },
  162. buttonLabel: {
  163. color: schemeColor('buttonLabel'),
  164. fontSize: MD_FONT_SIZE,
  165. textAlign: 'center'
  166. },
  167. /**
  168. * Style of the close icon on a dialog.
  169. */
  170. closeStyle: {
  171. color: schemeColor('icon'),
  172. fontSize: MD_FONT_SIZE
  173. },
  174. /**
  175. * Base style of the dialogs.
  176. */
  177. dialog: {
  178. alignItems: 'stretch',
  179. backgroundColor: schemeColor('background'),
  180. borderColor: schemeColor('border'),
  181. borderRadius: BORDER_RADIUS,
  182. borderWidth: 1,
  183. flex: 1,
  184. flexDirection: 'column',
  185. maxWidth: PREFERRED_DIALOG_SIZE
  186. },
  187. /**
  188. * Field on an input dialog.
  189. */
  190. field: {
  191. ...brandedDialogText,
  192. borderBottomWidth: 1,
  193. borderColor: schemeColor('border'),
  194. margin: BoxModel.margin,
  195. textAlign: 'left'
  196. },
  197. /**
  198. * Style for the field label on an input dialog.
  199. */
  200. fieldLabel: {
  201. ...brandedDialogText,
  202. margin: BoxModel.margin,
  203. textAlign: 'left'
  204. },
  205. text: {
  206. ...brandedDialogText
  207. },
  208. topBorderContainer: {
  209. borderTopColor: schemeColor('border'),
  210. borderTopWidth: 1
  211. }
  212. });