-
Notifications
You must be signed in to change notification settings - Fork 42
[C-2676] Rough release date modal #3610
Changes from 17 commits
943eef1
f323d26
243ee95
4baec24
c8090c3
6b82532
9743d55
8502d24
e6bf82b
1519f54
261eb5d
75e13de
a68e8b7
eb86778
a3daed5
bebd5ce
494fb5e
1fe988b
36918b0
206f408
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -160,5 +160,6 @@ | |
--font-medium: 500; | ||
--font-demi-bold: 600; | ||
--font-bold: 700; | ||
--font-extra-bold: 800; | ||
--font-heavy: 900; | ||
} |
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'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 */ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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}> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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}> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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; | ||
} |
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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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> | ||
) | ||
} |
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.
figured we would need this at some point haha. did you have to add another font file for this or did it just work?