-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Worlds Storage component (#2928)
* fix: Add classnames dep * fix: (WIP) Add worlds storage component * fix: Format * fix: Add translations and cast from BigInt to Number * fix: Add component tests * fix: Only show 2 decimals * feat: use numbers instead of strings * fix: Import * fix: Use progress bar from decentraland ui
- Loading branch information
Showing
11 changed files
with
111 additions
and
2 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
...components/WorldListPage_WorldsForEnsOwnersFeature/WorldsStorage/WorldsStorage.module.css
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
.worldsStorage { | ||
background-color: var(--dark-two); | ||
border-radius: 10px; | ||
padding: 22px; | ||
} | ||
|
||
.spaceContainer { | ||
display: flex; | ||
justify-content: space-between; | ||
margin-bottom: 1rem; | ||
} | ||
|
||
.currentMbs { | ||
font-size: 1.5rem; | ||
} | ||
|
||
.bar { | ||
margin-bottom: 1rem !important; | ||
background-color: #a09ba8 !important; | ||
} | ||
|
||
.bar:global(.ui.progress .bar) { | ||
background-color: #ff2d55; | ||
} | ||
|
||
.viewDetails { | ||
text-align: right; | ||
cursor: pointer; | ||
text-decoration: underline; | ||
} |
18 changes: 18 additions & 0 deletions
18
src/components/WorldListPage_WorldsForEnsOwnersFeature/WorldsStorage/WorldsStorage.spec.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { render, screen } from '@testing-library/react' | ||
import WorldsStorage, { CURRENT_MBS_TEST_ID, PROGRESS_TEST_ID } from './WorldsStorage' | ||
|
||
describe('when rendering the worlds storage component', () => { | ||
describe('when the provided current bytes is 50550000 and the max bytes is 100000000', () => { | ||
beforeEach(() => { | ||
render(<WorldsStorage currentBytes={50550000} maxBytes={100000000} />) | ||
}) | ||
|
||
it('should render 50.55/100.00mb', () => { | ||
expect(screen.getByTestId(CURRENT_MBS_TEST_ID).textContent).toEqual('50.55 / 100.00 mb') | ||
}) | ||
|
||
it('should render the storage front bar with 50%', () => { | ||
expect(screen.getByTestId(PROGRESS_TEST_ID).children[0].getAttribute('style')).toEqual('width: 50%;') | ||
}) | ||
}) | ||
}) |
29 changes: 29 additions & 0 deletions
29
src/components/WorldListPage_WorldsForEnsOwnersFeature/WorldsStorage/WorldsStorage.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import React from 'react' | ||
import { Progress } from 'decentraland-ui' | ||
import { t } from 'decentraland-dapps/dist/modules/translation/utils' | ||
import { Props } from './WorldsStorage.types' | ||
import styles from './WorldsStorage.module.css' | ||
|
||
export const CURRENT_MBS_TEST_ID = 'worlds-storage-current-mbs' | ||
export const PROGRESS_TEST_ID = 'worlds-storage-bar-front' | ||
|
||
const WorldsStorage = ({ maxBytes, currentBytes }: Props) => { | ||
const maxMbs = maxBytes / 1000000 | ||
const currentMbs = currentBytes / 1000000 | ||
const usedPercentage = (currentMbs * 100) / maxMbs | ||
|
||
return ( | ||
<div className={styles.worldsStorage}> | ||
<div className={styles.spaceContainer}> | ||
<span>{t('worlds_list_page.worlds_storage.space_used')}</span> | ||
<div data-testid={CURRENT_MBS_TEST_ID}> | ||
<span className={styles.currentMbs}>{currentMbs.toFixed(2)}</span> / {maxMbs.toFixed(2)} mb | ||
</div> | ||
</div> | ||
<Progress data-testid={PROGRESS_TEST_ID} percent={Math.trunc(usedPercentage)} className={styles.bar} size="small" /> | ||
<div className={styles.viewDetails}>{t('worlds_list_page.worlds_storage.view_details')}</div> | ||
</div> | ||
) | ||
} | ||
|
||
export default React.memo(WorldsStorage) |
4 changes: 4 additions & 0 deletions
4
src/components/WorldListPage_WorldsForEnsOwnersFeature/WorldsStorage/WorldsStorage.types.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export type Props = { | ||
maxBytes: number | ||
currentBytes: number | ||
} |
2 changes: 2 additions & 0 deletions
2
src/components/WorldListPage_WorldsForEnsOwnersFeature/WorldsStorage/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import WorldStorage from './WorldsStorage' | ||
export default WorldStorage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
b46045a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
builder – ./
builder-decentraland1.vercel.app
builder-git-master-decentraland1.vercel.app