-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
eb41fd3
commit b1fbef8
Showing
15 changed files
with
221 additions
and
4 deletions.
There are no files selected for viewing
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
20 changes: 20 additions & 0 deletions
20
packages/common/src/store/ui/upload-confirmation-modal/sagas.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,20 @@ | ||
import { takeEvery } from 'redux-saga/effects' | ||
import { put } from 'typed-redux-saga' | ||
|
||
import { setVisibility } from '../modals/parentSlice' | ||
|
||
import { open, OpenPayload, requestOpen } from './slice' | ||
|
||
function* handleRequestOpen(action: OpenPayload) { | ||
const { payload } = action | ||
yield* put(open(payload)) | ||
yield* put(setVisibility({ modal: 'UploadConfirmation', visible: true })) | ||
} | ||
|
||
function* watchHandleRequestOpen() { | ||
yield takeEvery(requestOpen, handleRequestOpen) | ||
} | ||
|
||
export default function sagas() { | ||
return [watchHandleRequestOpen] | ||
} |
7 changes: 7 additions & 0 deletions
7
packages/common/src/store/ui/upload-confirmation-modal/selectors.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,7 @@ | ||
import { CommonState } from 'store/commonStore' | ||
|
||
export const getHasPublicTracks = (state: CommonState) => | ||
state.ui.uploadConfirmationModal.hasPublicTracks | ||
|
||
export const getConfirmCallback = (state: CommonState) => | ||
state.ui.uploadConfirmationModal.confirmCallback |
30 changes: 30 additions & 0 deletions
30
packages/common/src/store/ui/upload-confirmation-modal/slice.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,30 @@ | ||
import { createSlice, PayloadAction } from '@reduxjs/toolkit' | ||
|
||
import { UploadConfirmationState } from './types' | ||
|
||
export type OpenPayload = PayloadAction<{ | ||
hasPublicTracks: boolean | ||
confirmCallback: () => void | ||
}> | ||
|
||
const initialState: UploadConfirmationState = { | ||
hasPublicTracks: true, | ||
confirmCallback: () => {} | ||
} | ||
|
||
const slice = createSlice({ | ||
name: 'applications/ui/uploadConfirmation', | ||
initialState, | ||
reducers: { | ||
requestOpen: (_state, _action: OpenPayload) => {}, | ||
open: (state, action: OpenPayload) => { | ||
const { confirmCallback, hasPublicTracks } = action.payload | ||
state.hasPublicTracks = hasPublicTracks | ||
state.confirmCallback = confirmCallback | ||
} | ||
} | ||
}) | ||
|
||
export const { open, requestOpen } = slice.actions | ||
export const actions = slice.actions | ||
export default slice.reducer |
8 changes: 8 additions & 0 deletions
8
packages/common/src/store/ui/upload-confirmation-modal/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,8 @@ | ||
export type UploadConfirmationState = { | ||
hasPublicTracks: boolean | ||
confirmCallback: () => void | ||
} | ||
|
||
export type UploadConfirmationModalState = { | ||
isOpen: boolean | ||
} & UploadConfirmationState |
17 changes: 17 additions & 0 deletions
17
packages/web/src/components/upload-confirmation-modal/UploadConfirmationModal.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,17 @@ | ||
.titleIcon path { | ||
fill: var(--neutral-light-2); | ||
} | ||
|
||
.modalText { | ||
text-align: center; | ||
} | ||
|
||
.modalButton { | ||
font-size: var(--font-l) !important; | ||
font-weight: var(--font-bold) !important; | ||
} | ||
|
||
.modalFooter { | ||
column-gap: var(--unit-2); | ||
padding: 0 var(--unit-6) var(--unit-6); | ||
} |
90 changes: 90 additions & 0 deletions
90
packages/web/src/components/upload-confirmation-modal/UploadConfirmationModal.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,90 @@ | ||
import { useCallback } from 'react' | ||
|
||
import { uploadConfirmationModalUISelectors } from '@audius/common' | ||
import { | ||
Button, | ||
ButtonType, | ||
IconUpload, | ||
Modal, | ||
ModalContent, | ||
ModalContentText, | ||
ModalFooter, | ||
ModalHeader, | ||
ModalTitle | ||
} from '@audius/stems' | ||
|
||
import { useModalState } from 'common/hooks/useModalState' | ||
import { useSelector } from 'common/hooks/useSelector' | ||
import { Text } from 'components/typography' | ||
|
||
import styles from './UploadConfirmationModal.module.css' | ||
|
||
const { getConfirmCallback, getHasPublicTracks } = | ||
uploadConfirmationModalUISelectors | ||
|
||
const messages = { | ||
title: 'Confirm Upload', | ||
publicDescription: | ||
'Ready to begin uploading? Your followers will be notified once your upload is complete.', | ||
hiddenDescription: 'Ready to begin uploading?', | ||
cancel: 'Go Back', | ||
upload: 'Upload' | ||
} | ||
|
||
export const UploadConfirmationModal = () => { | ||
const confirmCallback = useSelector(getConfirmCallback) | ||
const hasPublicTracks = useSelector(getHasPublicTracks) | ||
const [isOpen, setIsOpen] = useModalState('UploadConfirmation') | ||
|
||
const onClose = useCallback(() => { | ||
setIsOpen(false) | ||
}, [setIsOpen]) | ||
|
||
const handleConfirm = useCallback(() => { | ||
confirmCallback() | ||
onClose() | ||
}, [confirmCallback, onClose]) | ||
|
||
return ( | ||
<Modal isOpen={isOpen} onClose={onClose} size='small'> | ||
<ModalHeader> | ||
<ModalTitle | ||
icon={<IconUpload className={styles.titleIcon} />} | ||
title={ | ||
<Text | ||
variant='label' | ||
size='xLarge' | ||
strength='strong' | ||
color='neutralLight2' | ||
> | ||
{messages.title} | ||
</Text> | ||
} | ||
/> | ||
</ModalHeader> | ||
<ModalContent> | ||
<ModalContentText className={styles.modalText}> | ||
{hasPublicTracks | ||
? messages.publicDescription | ||
: messages.hiddenDescription} | ||
</ModalContentText> | ||
</ModalContent> | ||
<ModalFooter className={styles.modalFooter}> | ||
<Button | ||
textClassName={styles.modalButton} | ||
fullWidth | ||
text={messages.cancel} | ||
type={ButtonType.COMMON} | ||
onClick={onClose} | ||
/> | ||
<Button | ||
textClassName={styles.modalButton} | ||
fullWidth | ||
text={messages.upload} | ||
type={ButtonType.PRIMARY} | ||
onClick={handleConfirm} | ||
/> | ||
</ModalFooter> | ||
</Modal> | ||
) | ||
} |
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 @@ | ||
export { UploadConfirmationModal } from './UploadConfirmationModal' |
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