Advertisement
Guest User

Untitled

a guest
Jun 25th, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.86 KB | None | 0 0
  1. # RC UI
  2.  
  3. ## Install
  4.  
  5. ### package.json
  6.  
  7. ```ts
  8. npm i rcui
  9. // or
  10. yarn add rcui
  11. ```
  12.  
  13. ## Using
  14.  
  15. ```tsx
  16. import {
  17. RuiAvatar,
  18. RuiTooltip,
  19. RuiButton,
  20. RuiIconography,
  21. RuiLink,
  22. RuiCircularProgress,
  23. ThemeProvider,
  24. } from 'rcui';
  25. ```
  26.  
  27. ```html
  28. <ThemeProvider>
  29. <div>
  30. <RuiTooltip title="children">
  31. <div>children</div>
  32. </RuiTooltip>
  33. <RuiAvatar color="lake">SH</RuiAvatar>
  34. <RuiAvatar color="lake">SH</RuiAvatar>
  35. <RuiButton>Cool</RuiButton>
  36. <RuiButton variant="round">Button</RuiButton>
  37. <RuiIconography icon="star" />
  38. <RuiLink>123456</RuiLink>
  39. <RuiCircularProgress />
  40. <RuiCircularProgress size="{30}" color="secondary" />
  41. </div>
  42. </ThemeProvider>
  43. ```
  44.  
  45. ## Coding Style Guideline
  46.  
  47. We base on `styled-component` and `material-ui` to implement our RCUI library currently, we should separate the file in a different folder, let can make our code more readable and independent.
  48.  
  49. ### Rules:
  50.  
  51. 1. All about material-UI base component we should put that in the `styles` folder in target component,
  52.  
  53. - The `styled` component to contain the material component with custom `styled`, make we using that like our custom component, and name format should be `Styled[Name]`, make that short and readable, example: `StyledIcon`.
  54. - ```ts
  55. export { StyledIcon };
  56. ```
  57.  
  58. ````
  59. 2. Example compoent structure:
  60. ![alt text](./component_structure.png)
  61. * `styles`: styled component wrapper.
  62. * `assets`: all resource using in component, like `.png, .svg...`
  63. * `index.ts`: all component and method want to export should be export with `index.ts` below `[ComponentName]` root folder.
  64. * `TextField.ts`: the target component.
  65. 3. Component export needs at least `{Rui[Name], Rui[Name]Props}`, and others should start with `Rui[Name]` like below.
  66. ```ts
  67. export { RuiButton, RuiButtonProps };
  68. ````
  69.  
  70. 4. Make the component small and readable.
  71. 5. Make sure all props from material contain in the
  72.  
  73. 6. The `Props` from material and our custom should be separated into two types, and export that using `&` like below.
  74.  
  75. ```ts
  76. type RuiBaseTextFieldProps = Pick<SomeProps, 'props1' | 'props2' | 'props3'>
  77.  
  78. type RuiTextFieldProps = {
  79. myCustomProps?: any;
  80. ...
  81. } & RuiBaseTextFieldProps;
  82. // using & to merge that props
  83. ```
  84.  
  85. 1. `RuiBase[ComponentName]Props`: contain all export Props from material.
  86. 2. `Rui[ComponentName]Props`: contain all export Props we design.
  87.  
  88. <br>
  89. <br>
  90. <br>
  91.  
  92. # Debug with vscode
  93.  
  94. ## Launch Debug
  95.  
  96. ```bash
  97. ctrl + shift + p
  98. ```
  99.  
  100. Typing `task` and choice `Run Storybook`, that will serve the application.
  101.  
  102. Press `F5` to run `Launch Chrome` and you can using vscode debug in the IDE now.
  103.  
  104. ## Attach Debug
  105.  
  106. **_Before you using attach debug, you should close all of chrome, and using terminal to open chrome._**
  107.  
  108. ```bash
  109. ctrl + shift + p
  110. ```
  111.  
  112. Typing `task` and choice `Open debug browser`, that will open the browser in the debug mode.
  113.  
  114. Press `F5` to run `Attach Browser` and you can using vscode debug in the IDE now.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement