This document provides detailed instructions on the structure and usage of assets and the store folder in the InfraBoard project, along with a step-by-step guide for creating and using custom .tsx icon components.
aws/: Contains.tsxicon components related to AWS services:compute/: Icons for AWS compute services.network/: Icons for AWS networking services.- (Other subdirectories for additional AWS categories)
gcp/: Contains.tsxicon components related to GCP services:compute/: Icons for GCP compute services.network/: Icons for GCP networking services.- (Other subdirectories for additional GCP categories)
- Copy the SVG code.
- Open the SVGR Playground.
- Paste the SVG code into the playground. It will generate a React component.
- Save the generated code into a new
.tsxfile within the appropriate directory insrc/assets/. - Follow proper naming conventions for the file.
- Import the newly created
.tsxfile intosrc/assets/index.ts. - Add the new component to the relevant icon object.
- Import the desired icon object:
import { AWSIcons } from '@/assets/aws';
- Destructure the required icon from the object:
const { YourIconComponentName } = AWSIcons;
- Use the component in your application:
<YourIconComponentName className="" />
aws/: Contains data files related to AWS services, categorized into:compute/network/applications/others/- (Additional categories as required)
gcp/: Contains data files related to GCP services, categorized into:compute/ai/applications/others/- (Additional categories as required)
Each subdirectory contains objects that may include React icons or custom .tsx icon components. These objects are imported into store/aws/index.ts and store/gcp/index.ts for centralized access.
leftSidebarData: Responsible for rendering the tabs in the left sidebar. Tabs can be easily added or removed by modifying this file.
graph TD
A[src/] --> B[assets/]
B --> B1[aws/]
B --> B2[gcp/]
B1 --> B1A[compute/]
B1 --> B1B[network/]
B1 --> B1C[...]
B2 --> B2A[compute/]
B2 --> B2B[network/]
B2 --> B2C[...]
A --> C[store/]
C --> C1[aws/]
C --> C2[gcp/]
C1 --> C1A[compute/]
C1 --> C1B[network/]
C1 --> C1C[applications/]
C1 --> C1D[others/]
C2 --> C2A[compute/]
C2 --> C2B[ai/]
C2 --> C2C[applications/]
C2 --> C2D[others/]
C --> C3[leftSidebarData]
- Maintain a clear and consistent naming convention for all files and components.
- Regularly update the
index.tsfiles for centralized imports and better modularity. - Use the
leftSidebarDatafile for managing the tabs dynamically in the left sidebar. =======
A comprehensive guide for working with templates and assets in the InfraBoard project.
mindmap
root((Templates))
Assets
AWS Icons
GCP Icons
Custom Icons
Store
AWS Services
GCP Services
Templates
Components
Icons
Layouts
Modules
flowchart LR
A[SVG File] --> B[SVGR Conversion]
B --> C[TSX Component]
C --> D[Import to Index]
D --> E[Use in Project]
-
Convert SVG to TSX:
- Copy the SVG code
- Visit SVGR Playground
- Paste SVG code and get React component
- Create icon file using proper naming conventions
-
Component Integration:
// Example icon component import { IconInterface } from '@/assets/iconInterface' import React from 'react' function CustomIcon({ className }: IconInterface) { return ( <svg className={className}> {/* SVG content */} </svg> ) } export default React.memo(CustomIcon)
-
Index Registration:
// src/assets/index.ts import CustomIcon from './path/to/icon' export const Icons = { CustomIcon, // ... other icons }
aws/
├── compute/
│ ├── ec2Icon.tsx
│ ├── lambdaIcon.tsx
│ └── ...
├── network/
│ ├── vpcIcon.tsx
│ └── ...
└── index.ts
gcp/
├── compute/
│ ├── vmIcon.tsx
│ └── ...
├── network/
│ └── ...
└── index.ts
graph TD
A[Store] --> B[AWS]
A --> C[GCP]
B --> D[Compute]
B --> E[Network]
B --> F[Applications]
C --> G[Compute]
C --> H[AI]
C --> I[Applications]
store/aws/: AWS service definitionscompute/network/applications/others/
store/gcp/: GCP service definitionscompute/ai/applications/others/
import { AWSIcons } from '@/assets/aws'
const { EC2Icon } = AWSIcons
function Component() {
return <EC2Icon className="w-6 h-6" />
}// Example sidebar configuration
const leftSidebarData = {
compute: {
title: 'Compute',
items: [
{
name: 'EC2',
icon: EC2Icon,
// ... other properties
}
]
}
// ... other categories
}-
Icon Naming:
- Use PascalCase for component names
- Append 'Icon' suffix to icon components
- Group related icons in appropriate directories
-
Component Organization:
Loadinggraph TD A[Components] --> B[Atomic Design] B --> C[Atoms] B --> D[Molecules] B --> E[Organisms] C --> F[Icons] C --> G[Buttons] D --> H[Cards] E --> I[Sections] -
File Structure:
- Keep related files together
- Use index files for exports
- Maintain consistent naming conventions
-
Performance:
- Use React.memo for icon components
- Implement lazy loading where appropriate
- Optimize SVG files before conversion
-
Adding New Icons:
# Create new icon component touch src/assets/aws/compute/newServiceIcon.tsx # Update index file vim src/assets/aws/index.ts
-
Creating Store Entries:
// store/aws/compute/index.ts export const computeServices = { ec2: { name: 'EC2', icon: EC2Icon, description: '...' } // ... other services }
- Icon follows naming convention
- Component is memoized
- SVG is optimized
- TypeScript types are defined
- Component is exported correctly
- Documentation is updated
For more information, refer to our Contributing Guidelines.