stylesheet.ts 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. import {
  2. type ViewStyle,
  3. StyleSheet
  4. } from "react-native";
  5. import type {
  6. MarkdownDynamicStyles
  7. } from "./type";
  8. import type {
  9. Mutable
  10. } from "../../types";
  11. const stylesheet = StyleSheet.create({
  12. typographyScroll: {
  13. paddingHorizontal: 8,
  14. flexDirection: "row"
  15. },
  16. toolbarContainer: {
  17. borderBottomWidth: 0,
  18. paddingHorizontal: 8,
  19. flexDirection: "row",
  20. alignItems: "center",
  21. paddingVertical: 4,
  22. flexWrap: "wrap"
  23. },
  24. toolbarSeparator: {
  25. marginHorizontal: 6,
  26. height: 18
  27. },
  28. previewContainer: {
  29. minHeight: 150
  30. },
  31. typographyPill: {
  32. justifyContent: "center",
  33. paddingHorizontal: 10,
  34. alignItems: "center",
  35. paddingVertical: 4,
  36. marginRight: 6,
  37. borderWidth: 0
  38. },
  39. toolbarAction: {
  40. justifyContent: "center",
  41. alignItems: "center",
  42. marginHorizontal: 2,
  43. padding: 6
  44. },
  45. tabsContainer: {
  46. flexDirection: "row"
  47. },
  48. switchContainer: {
  49. justifyContent: "center",
  50. marginLeft: "auto",
  51. paddingRight: 8
  52. },
  53. editorInput: {
  54. textAlignVertical: "top",
  55. minHeight: 100,
  56. height: 250
  57. },
  58. tabButton: {
  59. paddingHorizontal: 16,
  60. paddingVertical: 10
  61. },
  62. container: {
  63. width: "100%"
  64. }
  65. });
  66. export const useStyles = ({
  67. spreadBehaviour,
  68. radiuses,
  69. borders,
  70. colors,
  71. spaces
  72. }: MarkdownDynamicStyles) => {
  73. const styles = {
  74. container: {
  75. alignSelf: "auto"
  76. } as Mutable<ViewStyle>,
  77. tabButtonInactive: {
  78. borderBottomColor: "transparent"
  79. },
  80. toolbarContainer: {
  81. backgroundColor: colors.content.container.subtle,
  82. borderColor: colors.content.border.subtle,
  83. borderTopRightRadius: radiuses.form,
  84. borderTopLeftRadius: radiuses.form,
  85. borderWidth: borders.line
  86. },
  87. toolbarSeparator: {
  88. backgroundColor: colors.content.border.subtle,
  89. width: borders.line
  90. },
  91. toolbarAction: {
  92. borderRadius: radiuses.actions
  93. },
  94. previewContainer: {
  95. backgroundColor: colors.content.container.default,
  96. borderColor: colors.content.border.subtle,
  97. borderRadius: radiuses.form,
  98. borderWidth: borders.line,
  99. padding: spaces.spacingMd
  100. },
  101. tabButtonActive: {
  102. borderBottomColor: colors.content.container.primary
  103. },
  104. tabButton: {
  105. borderBottomWidth: borders.indicator
  106. },
  107. typographyPill: {
  108. backgroundColor: colors.content.container.subtle,
  109. borderColor: colors.content.border.subtle,
  110. borderRadius: radiuses.chip
  111. },
  112. tabsContainer: {
  113. borderBottomColor: colors.content.border.subtle,
  114. borderBottomWidth: borders.line,
  115. marginBottom: spaces.spacingSm
  116. },
  117. editorInput: {
  118. backgroundColor: colors.content.container.default,
  119. borderColor: colors.content.border.subtle,
  120. borderBottomRightRadius: radiuses.form,
  121. borderBottomLeftRadius: radiuses.form,
  122. color: colors.content.text.high,
  123. borderWidth: borders.line,
  124. padding: spaces.spacingMd
  125. }
  126. };
  127. if (spreadBehaviour === "baseline") {
  128. styles.container.alignSelf = spreadBehaviour;
  129. styles.container.width = "auto";
  130. } else if (spreadBehaviour === "stretch") {
  131. styles.container.alignSelf = spreadBehaviour;
  132. styles.container.width = "100%";
  133. }
  134. return styles;
  135. };
  136. export default stylesheet;