style.ts 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. const textStyles: string[] = ["color", "fontSize", "textAlign", "fontWeight", "lineHeight", "lineBreak"];
  2. const scalableStyles: string[] = ["left", "top", "right", "bottom", "width", "height",
  3. "margin", "marginLeft", "marginRight", "marginTop", "marginBottom",
  4. "padding", "paddingLeft", "paddingRight", "paddingTop", "paddingBottom",
  5. "borderWidth", "borderLeftWidth", "borderRightWidth", "borderTopWidth", "borderBottomWidth"];
  6. const layoutAffectedStyles: string[] = [
  7. "margin", "marginTop", "marginBottom", "marginLeft", "marginRight",
  8. "padding", "paddingTop", "paddingBottom", "paddingLeft", "paddingRight",
  9. "width", "height"];
  10. type Style = {
  11. left: number,
  12. top: number,
  13. right: number,
  14. bottom: number,
  15. width: number,
  16. height: number,
  17. maxWidth: number,
  18. maxHeight: number,
  19. minWidth: number,
  20. minHeight: number,
  21. margin: number,
  22. marginLeft: number,
  23. marginRight: number,
  24. marginTop: number,
  25. marginBottom: number,
  26. padding: number,
  27. paddingLeft: number,
  28. paddingRight: number,
  29. paddingTop: number,
  30. paddingBottom: number,
  31. borderWidth: number,
  32. borderLeftWidth: number,
  33. borderRightWidth: number,
  34. borderTopWidth: number,
  35. borderBottomWidth: number,
  36. flexDirection: "column" | "row",
  37. justifyContent: "flex-start" | "center" | "flex-end" | "space-between" | "space-around",
  38. alignItems: "flex-start" | "center" | "flex-end" | "stretch",
  39. alignSelf: "flex-start" | "center" | "flex-end" | "stretch",
  40. flex: number,
  41. flexWrap: "wrap" | "nowrap",
  42. position: "relative" | "absolute",
  43. hidden: boolean,
  44. scale: number
  45. }
  46. const getDefaultStyle = () => ({
  47. left: undefined,
  48. top: undefined,
  49. right: undefined,
  50. bottom: undefined,
  51. width: undefined,
  52. height: undefined,
  53. maxWidth: undefined,
  54. maxHeight: undefined,
  55. minWidth: undefined,
  56. minHeight: undefined,
  57. margin: undefined,
  58. marginLeft: undefined,
  59. marginRight: undefined,
  60. marginTop: undefined,
  61. marginBottom: undefined,
  62. padding: undefined,
  63. paddingLeft: undefined,
  64. paddingRight: undefined,
  65. paddingTop: undefined,
  66. paddingBottom: undefined,
  67. borderWidth: undefined,
  68. flexDirection: undefined,
  69. justifyContent: undefined,
  70. alignItems: undefined,
  71. alignSelf: undefined,
  72. flex: undefined,
  73. flexWrap: undefined,
  74. position: undefined,
  75. hidden: false,
  76. scale: 1
  77. })
  78. export {
  79. getDefaultStyle, scalableStyles, textStyles, layoutAffectedStyles
  80. }