-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
268 additions
and
9 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
...Modals/WorldsForENSOwnersAnnouncementModal/WorldsForENSOwnersAnnouncementModal.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,35 @@ | ||
.title { | ||
font-size: 20px; | ||
font-weight: 700; | ||
text-align: center; | ||
max-width: 400px; | ||
} | ||
|
||
.img { | ||
text-align: center; | ||
margin-bottom: 32px; | ||
} | ||
|
||
.description { | ||
text-align: center; | ||
display: flex; | ||
flex-direction: column; | ||
gap: 32px; | ||
margin: auto; | ||
font-size: 14px; | ||
} | ||
|
||
.description .bold { | ||
font-weight: 700; | ||
} | ||
|
||
.actions { | ||
display: flex; | ||
flex-direction: column; | ||
gap: 14px; | ||
margin-top: 32px !important; | ||
} | ||
|
||
.actions :global(.ui.button) { | ||
margin-left: 0px !important; | ||
} |
49 changes: 49 additions & 0 deletions
49
...onents/Modals/WorldsForENSOwnersAnnouncementModal/WorldsForENSOwnersAnnouncementModal.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,49 @@ | ||
import React, { useCallback } from 'react' | ||
import { Button, ModalActions, ModalContent, ModalNavigation } from 'decentraland-ui' | ||
import Modal from 'decentraland-dapps/dist/containers/Modal' | ||
import { t } from 'decentraland-dapps/dist/modules/translation/utils' | ||
import { Props } from './WorldsForENSOwnersAnnouncementModal.types' | ||
import { persistCanOpenWorldsForENSOwnersAnnouncementModal } from './utils' | ||
import ensImg from './images/ens.svg' | ||
import styles from './WorldsForENSOwnersAnnouncementModal.module.css' | ||
|
||
export const DOCUMENTATION_URL = 'https://docs.decentraland.org/creator/worlds/about/' | ||
|
||
const WorldsForENSOwnersAnnouncementModal: React.FC<Props> = ({ name, onClose }) => { | ||
const handleOnClose = useCallback(() => { | ||
persistCanOpenWorldsForENSOwnersAnnouncementModal(false) | ||
onClose() | ||
}, [onClose]) | ||
|
||
return ( | ||
<Modal name={name} onClose={onClose}> | ||
<ModalNavigation | ||
title={<div className={styles.title}>{t('worlds_for_ens_owners_announcement_modal.title')}</div>} | ||
onClose={handleOnClose} | ||
/> | ||
<ModalContent> | ||
<div className={styles.img}> | ||
<img src={ensImg} alt="ens" /> | ||
</div> | ||
<div className={styles.description}> | ||
<div className={styles.bold}>{t('worlds_for_ens_owners_announcement_modal.description_ens')}</div> | ||
<div> | ||
{t('worlds_for_ens_owners_announcement_modal.description_dcl', { | ||
b: (text: string) => <span className={styles.bold}>{text}</span> | ||
})} | ||
</div> | ||
</div> | ||
</ModalContent> | ||
<ModalActions className={styles.actions}> | ||
<Button primary onClick={handleOnClose}> | ||
{t('worlds_for_ens_owners_announcement_modal.start_building')} | ||
</Button> | ||
<Button as="a" href={DOCUMENTATION_URL} target="_blank" rel="noopener noreferrer"> | ||
{t('worlds_for_ens_owners_announcement_modal.learn_more')} | ||
</Button> | ||
</ModalActions> | ||
</Modal> | ||
) | ||
} | ||
|
||
export default React.memo(WorldsForENSOwnersAnnouncementModal) |
3 changes: 3 additions & 0 deletions
3
...s/Modals/WorldsForENSOwnersAnnouncementModal/WorldsForENSOwnersAnnouncementModal.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,3 @@ | ||
import { ModalProps } from 'decentraland-dapps/dist/providers/ModalProvider/ModalProvider.types' | ||
|
||
export type Props = ModalProps |
31 changes: 31 additions & 0 deletions
31
src/components/Modals/WorldsForENSOwnersAnnouncementModal/images/ens.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions
3
src/components/Modals/WorldsForENSOwnersAnnouncementModal/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,3 @@ | ||
import WorldsForENSOwnersAnnouncementModal from './WorldsForENSOwnersAnnouncementModal' | ||
|
||
export default WorldsForENSOwnersAnnouncementModal |
61 changes: 61 additions & 0 deletions
61
src/components/Modals/WorldsForENSOwnersAnnouncementModal/utils.spec.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,61 @@ | ||
import { getLocalStorage } from 'decentraland-dapps/dist/lib/localStorage' | ||
import { LocalStorage } from 'decentraland-dapps/dist/lib/types' | ||
import { | ||
LOCALSTORAGE_WORLDS_FOR_ENS_OWNERS_ANNOUNCEMENT, | ||
canOpenWorldsForENSOwnersAnnouncementModal, | ||
persistCanOpenWorldsForENSOwnersAnnouncementModal | ||
} from './utils' | ||
|
||
jest.mock('decentraland-dapps/dist/lib/localStorage') | ||
|
||
const mockGetLocalStorage = getLocalStorage as jest.MockedFunction<typeof getLocalStorage> | ||
|
||
let setItem: jest.MockedFunction<LocalStorage['setItem']> | ||
let ls: LocalStorage | ||
|
||
beforeEach(() => { | ||
setItem = jest.fn() | ||
|
||
ls = { | ||
getItem: () => null, | ||
setItem | ||
} as unknown as LocalStorage | ||
|
||
mockGetLocalStorage.mockReturnValueOnce(ls) | ||
}) | ||
|
||
describe('when getting if the worlds for ens owners announcement modal can be opened', () => { | ||
describe('when the local storage returns something else than "1"', () => { | ||
it('should return true', () => { | ||
expect(canOpenWorldsForENSOwnersAnnouncementModal()).toBeTruthy() | ||
}) | ||
}) | ||
|
||
describe('when the local storage returns "1"', () => { | ||
beforeEach(() => { | ||
ls.getItem = () => '1' | ||
}) | ||
|
||
it('should return false', () => { | ||
expect(canOpenWorldsForENSOwnersAnnouncementModal()).toBeFalsy() | ||
}) | ||
}) | ||
}) | ||
|
||
describe('when persisting if the worlds for ens owners announcement modal can be opened', () => { | ||
describe('when the value is true', () => { | ||
it('should call the set item local storage method with undefined', () => { | ||
persistCanOpenWorldsForENSOwnersAnnouncementModal(true) | ||
|
||
expect(setItem).toHaveBeenCalledWith(LOCALSTORAGE_WORLDS_FOR_ENS_OWNERS_ANNOUNCEMENT, undefined) | ||
}) | ||
}) | ||
|
||
describe('when the value is false', () => { | ||
it('should call the set item local storage method with "1"', () => { | ||
persistCanOpenWorldsForENSOwnersAnnouncementModal(false) | ||
|
||
expect(setItem).toHaveBeenCalledWith(LOCALSTORAGE_WORLDS_FOR_ENS_OWNERS_ANNOUNCEMENT, '1') | ||
}) | ||
}) | ||
}) |
13 changes: 13 additions & 0 deletions
13
src/components/Modals/WorldsForENSOwnersAnnouncementModal/utils.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,13 @@ | ||
import { getLocalStorage } from 'decentraland-dapps/dist/lib/localStorage' | ||
|
||
export const LOCALSTORAGE_WORLDS_FOR_ENS_OWNERS_ANNOUNCEMENT = 'builder-worlds-for-ens-owners-announcement' | ||
|
||
export const persistCanOpenWorldsForENSOwnersAnnouncementModal = (canOpen: boolean) => { | ||
const ls = getLocalStorage() | ||
ls.setItem(LOCALSTORAGE_WORLDS_FOR_ENS_OWNERS_ANNOUNCEMENT, canOpen ? undefined : '1') | ||
} | ||
|
||
export const canOpenWorldsForENSOwnersAnnouncementModal = () => { | ||
const ls = getLocalStorage() | ||
return ls.getItem(LOCALSTORAGE_WORLDS_FOR_ENS_OWNERS_ANNOUNCEMENT) !== '1' | ||
} |
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
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
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
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