Goals
- Move generic components that are used in multiple pages out of page-specific folders
- Improve the generic component names - so that it reflects what it does instead of where/how it is being used to encourage reuse and reduce confusion
- Remove duplicate component names to improve auto-import in the code editor and reduce confusion
<HomepageTopNav/>
- Rename To:
<MainNavigation/>
- Current Path:
components/product-pages/common/Topnav
- Proposed Path:
components/navigation/MainNavigation
Also, move the contents of folder components/product-pages/common/nav
to components/navigation
The name HomepageTopNav
gives the impression that it is only meant for the home page and is positioned at the top, but it is used on a lot of pages and it appears at the bottom on mobile.
<HomepageSection/>
- Rename To:
<DecoratedSection/>
- Current Path:
components/product-pages/homepage/HomepageSection
- Proposed Path:
components/sections/DecoratedSection
The name HomepageSection
is misleading - it is used on a lot of pages other than the home page. DecoratedSection
gives a better idea of what it does - It creates a section and adds decorations like aurora effects and SVG patterns around its children.
<NewsletterSection/>
- Current Path:
components/homepage/sections/NewsletterSection
- Proposed Path:
components/sections/NewsletterSection
<SDKSection/>
- Rename To:
<SDKShowcaseSection/>
- Current Path:
components/homepage/sections/SDKSection
- Proposed Path:
components/sections/sdk-showcase/SDKShowcaseSection
This also involves moving <CodeSelector/>
from components/product-pages/homepage/CodeSelector
to components/sections/sdk-showcase/CodeSelector
tw-compnents
Heading
, Badge
, Button
, Checkbox
, Drawer
, FormLabel
, FormHelperText
, FormErrorMessage
, Link
, MenuGroup
, MenuItem
, Text
Rename them to
TW_Heading
, TW_Badge
, TW_Button
, TW_Checkbox
, TW_Drawer
, TW_FormLabel
, TW_FormHelperText
, TW_FormErrorMessage
, TW_Link
, TW_MenuGroup
, TW_MenuItem
, TW_Text
Why?
These components have the same name as ChakraUI components and because of this - the code editor’s auto-import feature ends up importing the wrong components. (VSCode auto imports from ChakraUI)
It also creates confusion about what exact component is being used and requires looking at the import path.
To avoid issues like this, There should not be two components with the same name. Adding a Namespace prefix in the component name fixes the issue while maintaining its previous meaning
Also, Delete the tw-components/index.ts
and import tw-components from the file component is defined in. This provides a better DX as Jumping to Component Definition (command-clicking on the component name in VSCode) will jump to the actual file where the component is defined instead of jumping to tw-components/index.ts
. This will also reduce the likelihood of tree-shaking issues in the future as we saw with AddressCopyButton
There are a lot more components like this that also requires refactoring and restructuring which we can cover in the next rounds.
refactor