Skip to content
This repository has been archived by the owner on Oct 4, 2023. It is now read-only.

[C-2676] Rough release date modal #3610

Merged
merged 20 commits into from
Jun 20, 2023
Merged
Show file tree
Hide file tree
Changes from 17 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2,646 changes: 1,412 additions & 1,234 deletions packages/web/package-lock.json

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions packages/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
"@sentry/integrations": "6.16.1",
"@solana/spl-token": "0.1.8",
"@solana/web3.js": "1.53.0",
"@types/react-dates": "21.8.3",
"@types/react-twitter-auth": "0.0.4",
"@walletconnect/web3-provider": "1.4.1",
"amplitude-js": "8.10.0",
Expand Down Expand Up @@ -217,6 +218,7 @@
"@types/numeral": "^2.0.2",
"@types/react": "18.0.26",
"@types/react-beautiful-dnd": "13.1.3",
"@types/react-dates": "^21.8.3",
"@types/react-dom": "18.0.10",
"@types/react-helmet": "6.1.6",
"@types/react-infinite-scroller": "1.2.1",
Expand Down
1 change: 1 addition & 0 deletions packages/web/src/assets/styles/type.css
Original file line number Diff line number Diff line change
Expand Up @@ -160,5 +160,6 @@
--font-medium: 500;
--font-demi-bold: 600;
--font-bold: 700;
--font-extra-bold: 800;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

figured we would need this at some point haha. did you have to add another font file for this or did it just work?

--font-heavy: 900;
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,15 @@ import { useCallback } from 'react'
import { ExtendedTrackMetadata, Nullable } from '@audius/common'
import { Button, ButtonType, IconArrow } from '@audius/stems'
import { Formik } from 'formik'
import moment from 'moment'
import * as Yup from 'yup'

import PreviewButton from 'components/upload/PreviewButton'

import TrackMetadataFields from '../fields/TrackMetadataFields'

import styles from './EditPageNew.module.css'
import { TrackModalArray } from './TrackModalArray'
import { TrackForUpload } from './types'

type EditPageProps = {
Expand All @@ -18,12 +20,12 @@ type EditPageProps = {
onContinue: () => void
}
export type FormValues = ExtendedTrackMetadata & {
releaseDate: moment.Moment
licenseType: {
allowAttribution: Nullable<boolean>
commercialUse: Nullable<boolean>
derivativeWorks: Nullable<boolean>
}
trackArtwork?: string
}

const EditTrackSchema = Yup.object().shape({
Expand All @@ -48,6 +50,7 @@ export const EditPageNew = (props: EditPageProps) => {
const initialValues: FormValues = {
...tracks[0].metadata,
artwork: null,
releaseDate: moment().startOf('day'),
licenseType: {
allowAttribution: null,
commercialUse: null,
Expand All @@ -73,6 +76,7 @@ export const EditPageNew = (props: EditPageProps) => {
<>
<div className={styles.editForm}>
<TrackMetadataFields playing={false} type='track' />
<TrackModalArray />
<PreviewButton playing={false} onClick={() => {}} />
</div>
<div className={styles.continue}>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/* Form display component */
.displayTile {
display: flex;
flex-direction: column;
align-items: flex-start;
padding: var(--unit-4) var(--unit-6);
gap: var(--unit-4);

border: 1px solid var(--neutral-light-8);
border-radius: 8px;
}

.header {
display: flex;
width: 100%;
justify-content: space-between;
align-items: center;
}

.title {
font-family: var(--font-family);
font-style: normal;
font-weight: var(--font-extra-bold);
font-size: var(--font-l);
line-height: 20px;
}

.caret {
color: var(--neutral-light-4);
height: 14px;
width: 14px;
}

.description {
font-weight: var(--font-medium);
}

.valueDisplay {
display: flex;
flex-direction: row;
align-items: center;
padding: 8px;
gap: 4px;
background: var(--neutral-light-8);
border: 1px solid var(--neutral-light-7);
border-radius: 2px;

font-family: 'Avenir Next LT Pro';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this different from the --font-family css var value?

font-weight: var(--font-demi-bold);
font-size: var(--font-m);
line-height: 20px;
text-transform: uppercase;
}

.calendarIcon {
height: 14px;
width: 14px;
}

/* Modal styles */
.modalHeader {
display: flex;
flex-direction: row;
align-items: center;
width: 100%;
justify-content: space-around;
}

.modalTitle {
font-weight: var(--font-heavy);
font-size: var(--font-xl);
line-height: 25px;

text-align: center;
text-transform: uppercase;

color: var(--neutral-light-2);

}

/* TODO: figure out how to do this as .modal .title */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you still need to do this?

.modalHeading {
margin-bottom: var(--unit-2);
}

.titleIcon {
height: 18px;
width: 18px;
}

.datePicker {
margin-top: var(--unit-4);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
import { useState } from 'react'

import {
Button,
ButtonType,
IconCalendar,
IconCaretRight,
Modal,
ModalContent,
ModalFooter,
ModalHeader,
ModalTitle
} from '@audius/stems'
import cn from 'classnames'
import { useField } from 'formik'

import { DatePickerField } from '../fields/DatePickerField'

import styles from './ReleaseDateModalField.module.css'

const messages = {
title: 'Release Date',
description:
'Release date affects sorting on your profile and is visible in track details.',
done: 'Done'
}

const FIELD_NAME = 'releaseDate'

export const ReleaseDateModalField = () => {
const [{ value }] = useField<moment.Moment>(FIELD_NAME)
const [isModalOpen, setIsModalOpen] = useState(false)
const open = () => setIsModalOpen(true)
const close = () => setIsModalOpen(false)

const modal = (
<div className={styles.modal}>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this outer div needed? I might have missed the styles for this being set

<Modal onClose={close} isOpen={isModalOpen}>
<ModalHeader>
<div className={styles.modalHeader}>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: are we able to add this class name to the ModalHeader instead of adding another div?

<ModalTitle
className={styles.modalTitle}
title={messages.title}
icon={<IconCalendar className={styles.titleIcon} />}
/>
</div>
</ModalHeader>
<ModalContent>
<h3 className={cn(styles.title, styles.modalHeading)}>
{messages.title}
</h3>
<p className={styles.description}>{messages.description}</p>
<div className={styles.datePicker}>
<DatePickerField name={FIELD_NAME} label={'Release Date'} />
</div>
</ModalContent>
<ModalFooter>
<Button
type={ButtonType.PRIMARY}
text={messages.done}
onClick={close}
/>
</ModalFooter>
</Modal>
</div>
)

return (
<>
<div className={styles.displayTile} onClick={open}>
<div className={styles.header}>
<div className={styles.title}>{messages.title}</div>
<IconCaretRight className={styles.caret} />
</div>
<div className={styles.description}>{messages.description}</div>
<div className={styles.valueDisplay}>
<IconCalendar className={styles.calendarIcon} />
{value.calendar().split(' at')[0]}
</div>
</div>
{modal}
</>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { ReleaseDateModalField } from './ReleaseDateModalField'

export const TrackModalArray = () => {
return (
<>
<ReleaseDateModalField />
</>
)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
.datePickerField {
height: 500px;
}

/* TODO: figure out how to apply styling to global class names in these rules */
.datePicker {
:global {
.singleDatePicker {
/* background-color: var(--neutral-light-10);
*/
background-color: red;
}
}
}

.datePicker .SingleDatePickerInput {
background-color: var(--neutral-light-10);

}

.iconCalendar {
height: 20px;
width: 20px;
}
48 changes: 48 additions & 0 deletions packages/web/src/pages/upload-page/fields/DatePickerField.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import 'react-dates/initialize'
import 'react-dates/lib/css/_datepicker.css'

import { useState } from 'react'

import cn from 'classnames'
import { useField } from 'formik'
import moment from 'moment'
import { SingleDatePicker, isInclusivelyBeforeDay } from 'react-dates'

import { ReactComponent as IconCalendar } from 'assets/img/iconCalendar.svg'

import styles from './DatePickerField.module.css'

type DatePickerFieldProps = {
name: string
label: string
style?: string
}

export const DatePickerField = (props: DatePickerFieldProps) => {
const { name, label, style } = props
const [field, , helpers] = useField(name)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah does it complain if you do the underscore thing? this hurts my eyes, but may be what we agreed to do

const [isFocused, setIsFocused] = useState(false)

return (
<div className={styles.datePickerField}>
<div className={styles.label}>{label}</div>
<div className={cn(styles.datePicker, style)}>
<SingleDatePicker
id={field.name}
placeholder={moment().format('MM/DD/YYYY')}
// Restrict date picker to days before today.
// @ts-ignore mismatched moment versions; shouldn't be a problem
isOutsideRange={(day) => !isInclusivelyBeforeDay(day, moment())}
date={field.value}
onDateChange={helpers.setValue}
focused={isFocused}
onFocusChange={({ focused }) => setIsFocused(focused)}
numberOfMonths={1}
hideKeyboardShortcutsPanel
customInputIcon={<IconCalendar className={styles.iconCalendar} />}
small
/>
</div>
</div>
)
}