Skip to content

Commit 313bfb2

Browse files
committed
Refactor Mintbase: Update tab labels in Mintbase Mini
1 parent 8d4502f commit 313bfb2

File tree

2 files changed

+123
-45
lines changed

2 files changed

+123
-45
lines changed

apps/Mintbase/widget/Mintbase/App/ContractProfilePage/Mint/Index.jsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ const MintAmount = styled.div`
7474
color: #fff;
7575
}
7676
.max {
77+
color: inherit;
7778
opacity: 0.7;
7879
}
7980
}
@@ -272,7 +273,7 @@ const Mint = ({ isDarkModeOn, contractId, connectedDao }) => {
272273
const [splits, setSplits] = useState([]);
273274
const [img, setImg] = useState(null);
274275
const owner = context.accountId;
275-
276+
276277
const uploadFile = (files) => {
277278
const file = files[0];
278279
setLoadingUpload(true);
@@ -414,7 +415,12 @@ const Mint = ({ isDarkModeOn, contractId, connectedDao }) => {
414415
</div>
415416
<MintAmount>
416417
<div className="amount-input">
417-
<p className={isDarkModeOn ? "dark" : ""}>
418+
<p
419+
className={isDarkModeOn ? "dark" : ""}
420+
style={{
421+
color: isDarkModeOn ? "#fff" : "",
422+
}}
423+
>
418424
Amount to mint <p className="max">(max 50)</p>
419425
<span className="red-text">*</span>
420426
</p>

apps/Mintbase/widget/Mintbase/Mini/README.md

Lines changed: 115 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -2,30 +2,63 @@
22

33
## Overview
44

5-
A stipped down version of MintBOS without theming, flexible styling classes, no nav or footer - an easy way for users who want to leverage tools like DAO functionalities and nft minters to build on top of what has been done by MintBOS team.
5+
MintBOS Mini is a customizable, single-file stipped down version of MintBOS without theming, flexible styling classes, no nav or footer - an easy way for users who want to leverage tools like DAO functionalities and nft minters to build on top of what has been done by MintBOS team.
66
This guide will help you understand how to add, remove, or modify tabs to create your own preferred version of MintBOS Mini.
77

8+
# Comprehensive MintBOS Mini Developer Documentation
9+
10+
## Overview
11+
12+
MintBOS Mini is a customizable, single-file React-based application that provides various functionalities for interacting with the Mintbase ecosystem. This guide will help you understand how to fork, customize, and extend the application to create your own preferred version of MintBOS Mini.
13+
814
## Table of Contents
915

10-
1. [Application Structure](#application-structure)
11-
2. [Customizing Tabs](#customizing-tabs)
12-
3. [Adding a New Tab](#adding-a-new-tab)
13-
4. [Removing a Tab](#removing-a-tab)
14-
5. [Modifying Existing Tabs](#modifying-existing-tabs)
15-
6. [Best Practices](#best-practices)
16+
1. [File Structure](#file-structure)
17+
2. [Forking and Configuration](#forking-and-configuration)
18+
3. [Application Components](#application-components)
19+
4. [Customizing Tabs](#customizing-tabs)
20+
5. [Adding a New Tab](#adding-a-new-tab)
21+
6. [Removing a Tab](#removing-a-tab)
22+
7. [Modifying Existing Tabs](#modifying-existing-tabs)
23+
8. [Creating Custom Tab Ribbons](#creating-custom-tab-ribbons)
24+
9. [Important Details and Customization Points](#important-details-and-customization-points)
25+
10. [Best Practices](#best-practices)
26+
27+
## File Structure
28+
29+
MintBOS Mini is designed as a single file for easy forking and customization. The file contains all necessary components, styling, and logic for the application.
30+
31+
## Forking and Configuration
32+
33+
To create your own version of MintBOS Mini:
34+
35+
1. Fork the file from its original location.
36+
2. Update the `config_account` variable:
37+
```javascript
38+
// Original
39+
${config_account} = "bos.genadrop.near"
40+
41+
// Your custom version
42+
${config_account} = "your-account.near"
43+
```
44+
3. Customize the components, tabs, and functionality as needed.
1645

17-
## Application Structure
46+
## Application Components
1847

19-
The main component of MintBOS Mini is structured as follows:
48+
The main components of MintBOS Mini include:
2049

21-
- State management for mode, filters, and selected tab
22-
- Styled components for UI elements
23-
- Tab rendering logic
24-
- Content rendering based on selected tab
50+
- `Root`: The main container component
51+
- `Card`: The styled card component for the application content
52+
- `AppContent`: Styled component for specific app sections
53+
- `FormSection`: Styled component for form sections
54+
- `Toggle`: Component for theme toggling
55+
- `PageContent`: Component that renders content based on selected tab
56+
57+
# Comprehensive MintBOS Mini Developer Documentation
2558

2659
## Customizing Tabs
2760

28-
The tabs are defined in the `tabs` object:
61+
The tabs are now defined in a `tabs` object with a more complex structure:
2962

3063
```javascript
3164
const tabs = {
@@ -45,30 +78,41 @@ const tabs = {
4578
};
4679
```
4780
81+
This new structure allows for more flexibility in defining tabs, including the ability to hide tabs based on certain conditions.
82+
83+
### Tab Properties
84+
85+
- `title`: The display text for the tab
86+
- `hidden`: (Optional) A boolean or expression that determines whether the tab should be hidden
87+
4888
## Adding a New Tab
4989
5090
To add a new tab:
5191
52-
1. Add a new label to the `labels` array in `tabs`.
53-
2. Create a new case in the `PageContent` component's switch statement.
54-
3. Implement the content for the new tab.
92+
1. Add a new object to the `labels` array in the `tabs` object.
93+
2. If needed, include a `hidden` property to control the tab's visibility.
94+
3. Create a new case in the `PageContent` component's switch statement.
95+
4. Implement the content for the new tab.
5596
5697
Example:
5798
5899
```javascript
59-
// Step 1: Add new label
60-
const tabProps = {
100+
// Step 1 & 2: Add new tab object
101+
const tabs = {
61102
labels: [
62103
// ... existing tabs
63-
"New Custom Tab",
104+
{
105+
title: "New Custom Tab",
106+
hidden: someCondition, // Optional: control visibility
107+
},
64108
],
65109
};
66110

67-
// Step 2 & 3: Add new case and implement content
111+
// Step 3 & 4: Add new case and implement content
68112
const PageContent = () => {
69113
switch (selectedTab) {
70114
// ... existing cases
71-
case "new-custom-tab":
115+
case "New Custom Tab":
72116
return (
73117
<Widget
74118
src="${config_account}/widget/YourCustomWidget"
@@ -84,42 +128,70 @@ const PageContent = () => {
84128
85129
To remove a tab:
86130
87-
1. Remove the label from the `labels` array in `tabProps`.
131+
1. Remove the corresponding object from the `labels` array in the `tabs` object.
88132
2. Remove the corresponding case from the `PageContent` component's switch statement.
89133
90134
## Modifying Existing Tabs
91135
92136
To modify an existing tab:
93137
94-
1. Locate the case for the tab you want to modify in the `PageContent` component.
95-
2. Update the content or props as needed.
138+
1. Locate the tab object in the `labels` array of the `tabs` object.
139+
2. Update the `title` or add/modify the `hidden` property as needed.
140+
3. If necessary, update the corresponding case in the `PageContent` component.
96141
97-
Example:
142+
Example of modifying a tab's visibility:
98143
99144
```javascript
100-
case "my-owned-nfts":
101-
return (
102-
<Widget
103-
src={`${config_account}/widget/Mintbase.App.Tokens.Owned`}
104-
props={{
105-
isDarkModeOn,
106-
ownerId: accountId,
107-
isConnected,
108-
showFilters: showOwnedFilters,
109-
onCreateStore,
110-
// Add or modify props here
111-
newCustomProp: "value",
112-
}}
113-
/>
114-
);
145+
{
146+
title: "My Activity",
147+
hidden: !context.accountId, // Hide this tab if user is not logged in
148+
}
115149
```
116150
151+
## Handling Conditional Tabs
152+
153+
The new structure allows for conditional rendering of tabs. For example, the "_DAO NFTs" tab is hidden unless there's a connected DAO or the user is logged in:
154+
155+
```javascript
156+
{
157+
title: "_DAO NFTs",
158+
hidden: !connectedDao?.address && !context?.accountId,
159+
}
160+
```
161+
162+
When working with conditional tabs:
163+
164+
1. Ensure that the conditions for `hidden` are properly defined and tested.
165+
2. Update the conditions if the requirements for showing/hiding the tab change.
166+
3. Remember to handle the case in the `PageContent` component, even if the tab is currently hidden (to support future visibility).
167+
168+
## Important Details and Customization Points
169+
170+
1. **Theme Toggling**: The application supports dark and light modes. Customize the `Toggle` component and `switchChangeHandler` function to adjust theming behavior.
171+
172+
2. **Local Storage**: The application uses local storage for persisting data. Customize the `LOCALSTORAGE_KEY` and related functions to manage your app's state.
173+
174+
3. **Styling**: The application uses styled-components. Customize the styled components (`Root`, `Card`, `AppContent`, etc.) to adjust the look and feel of your app.
175+
176+
4. **Widget Integration**: The application uses a Widget system. When adding new tabs or features, create and integrate new Widgets using the `VM.require` syntax:
177+
178+
```javascript
179+
const { YourWidget } = VM.require("${config_account}/widget/Your.Widget.Path");
180+
```
181+
182+
5. **State Management**: The application uses React's `useState` for state management. Consider implementing more robust state management (e.g., Context API or Redux) for more complex applications.
183+
184+
6. **Error Handling**: Implement proper error handling in the `catch` blocks throughout the application to improve user experience and debugging.
185+
186+
7. **Responsive Design**: The application includes some responsive design elements. Ensure that any customizations or new features maintain responsiveness across different device sizes.
187+
117188
## Best Practices
118189
119190
1. Maintain consistency in naming conventions for tab labels and case statements.
120191
2. Ensure that new tabs follow the existing pattern of using Widget components.
121192
3. Test thoroughly after making changes to ensure all functionalities work as expected.
122193
4. Keep the UI responsive by considering mobile views when adding new content.
123194
5. Utilize the `isDarkModeOn` prop for consistent theming across new components.
124-
125-
By following this guide, you can easily customize MintBOS Mini to include the specific functionalities you need for your project.
195+
6. When adding new features, consider their impact on performance and load time.
196+
7. Document any significant changes or additions to help future developers understand your customizations.
197+
8. Regularly update dependencies and check for compatibility with the latest Mintbase ecosystem updates.

0 commit comments

Comments
 (0)