@@ -11,10 +11,10 @@ yarn add practical-react-components-core
1111This contains all the core components. All the icons are located in a separate
1212` practical-react-components-icons ` package.
1313
14- ### Dependencies
14+ ## Dependencies
1515
1616Practical react components is dependent on some packages, in addition to ` react `
17- and ` react-dom ` , that needs to be installed for it to work. Make sure the
17+ and ` react-dom ` , that need to be installed for it to work. Make sure the
1818following packages are installed:
1919
2020``` shell
@@ -30,7 +30,7 @@ the following packages are installed:
3030yarn add formik
3131```
3232
33- ### Typescript (only if using typescript)
33+ ### Typescript
3434
3535Install additional typings:
3636
@@ -62,7 +62,7 @@ styled components.
6262Make sure this file is included in your ` tsconfig.json ` files, e.g.
6363` "include": ["src/styled-components.d.ts", "./src/index.ts"] ` .
6464
65- ### Electron (only if using electron)
65+ ### Electron
6666
6767If you are using Practical react components with an Electron app you might have
6868to add the following lines in the root of you ` package.json ` file.
@@ -115,115 +115,4 @@ export const App: React.FC = () => {
115115```
116116
117117For more information on what components are available and how to use them
118- please visit the [ documentation] ( https://github.com/AxisCommunications/practical-react-components ) .
119-
120- ## Components
121-
122- The React components are kept in one folder per component, containing an
123- ` index.tsx ` and ` index.mdx ` file. The former contains the actual component
124- implementation, while the latter documents and showcases the component, where
125- you can see and interact with the component.
126-
127- To create a new component:
128-
129- - create a folder with the component name
130- - add an ` index.tsx ` file which exports the component and any other
131- related components and/or utilities (types, hooks, etc...). Do _ not_
132- create any default exports
133-
134- ## Icons
135-
136- To add new icons to the library, put the SVG-file into the ` packages/icons/src `
137- folder and execute ` yarn build:icons ` . The command re-generates ` tsx ` files for
138- all SVGs in the ` packages/icons/src/__generated__ ` together with a barrel-file
139- to export them all. The name of the generated icon is Pascal-cased and
140- post-fixed with ` Icon ` . Note that some ` fill ` and ` stroke ` colors might have to
141- be removed or replaced in the original SVG with the value ` currentColor ` in
142- order for the theming to work properly.
143-
144- ### How to optimize svg
145-
146- 1 . Make sure that the svg file has only ** one** path between ` <svg> ` tag and that its viewBox is ` 24px ` box.
147-
148- An example:
149-
150- ```
151- <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
152- <path d="M17 13h-4v4a1 1 0 01-2 0v-4H7a1 1 0 010-2h4V7a1 1 0 012 0v4h4a1 1 0 010 2z" />
153- </svg>
154- ```
155-
156- 2 . If it satisfies ** 1** , go to ** 10** .
157- If not, you should optimize the file with all following steps.
158- 3 . Remove extra tag or unnecessary styles/attributes in [ SVGOMG - SVGO's Missing GUI] ( https://jakearchibald.github.io/svgomg/ ) .
159- 4 . Open the file in [ Inkscape] ( https://inkscape.org/ ) .
160- 5 . Ungroup the paths if they are grouped.
161- 6 . Remove extra path and rect.
162- 7 . Change stroke to path. (Select the element + F2)
163- 8 . Select all paths and combine all paths. (Combine or Union)
164- 9 . Export it as optimized svg.
165- 10 . Copy the code and paste it on input in [ Playground - SVGR] ( https://react-svgr.com/playground/ ) .
166- 11 . Copy the ` <path> ` on the output and replace with the original ` <path> ` .
167- 12 . Run ` yarn build:icons ` and check the icon on docs.
168-
169- ## Performance - best practices
170-
171- ### General memoization
172-
173- [ Link to React Docs] ( https://reactjs.org/docs/react-api.html#reactmemo )
174-
175- _ If your function component renders the same result given the same props, you
176- can wrap it in a call to React.memo for a performance boost in some cases by
177- memoizing the result. This means that React will skip rendering the component,
178- and reuse the last rendered result._
179-
180- ** Caveat: Mounting the component in the DOM takes longer, thus this method is
181- not always an good idea. Use where the component might re-render alot due
182- changes in parent, etc.**
183-
184- ### Styled-components - What to know
185-
186- 1 . ` Styled-components ` are heavy, they take quite some time to mount.
187- 2 . When performance is slow due to large number of components & DOM elements,
188- create custom, light and fast, sub components adapted for their intended
189- context of use. (i.e not having unused logic/code in it)
190- 3 . The best component is the non-existing. Can the contents be mounted inside
191- another already existing component?
192-
193- ### CSS
194-
195- [ CSS/JS - Performance 101] ( https://www.viget.com/articles/animation-performance-101-browser-under-the-hood/ )
196-
197- CSS is fast, animating anything but ` opacity ` & ` transform ` is slow.
198-
199- Replacing ` .svg ` with pure CSS is faster.
200-
201- ## Release
202-
203- Instructions on how to do a new release for the main branch.
204-
205- 1 . Make sure you have permissions to push to main
206- 2 . Get latest main
207- ``` shell
208- git checkout main
209- git pull --ff-only upstream main
210- ```
211- 3 . Get all tags
212- ``` shell
213- git fetch --all --tags
214- ```
215- 4 . Create a new version commit
216- ``` shell
217- yarn release [increment]
218- ```
219- where ` increment ` is a semver specification of the increment you want
220- for the release (` prerelease ` is used if nothing is specified).
221- 5 . Check the commit of the newly generated tag and make sure only the changes
222- between latest tag and this one are included in the CHANGELOG.md file.
223- 6 . Push new version to main
224- ``` shell
225- git push upstream main < new_tag>
226- ```
227- 7 . Copy changes from CHANGELOG.md file, add them for your tag on ** tags**
228- page and make sure that changes are displayed on the ** releases** page.
229- 8 . Done
118+ please visit the [ documentation] ( https://axiscommunications.github.io/practical-react-components ) .
0 commit comments