diff --git a/web/calendar/thread-picker.css b/web/calendar/thread-picker.css index f22c87518..470affafe 100644 --- a/web/calendar/thread-picker.css +++ b/web/calendar/thread-picker.css @@ -1,72 +1,45 @@ div.container { position: absolute; left: 4px; bottom: 20px; box-shadow: 0 8px 16px 0 rgba(0, 0, 0, 0.3); z-index: 1; font-weight: 600; background-color: white; border-radius: 3px; white-space: nowrap; line-height: normal; font-size: 12px; cursor: pointer; outline: none; } span.thread { color: black; display: inline-block; overflow: hidden; text-overflow: ellipsis; width: 110px; } div.container > div.option { border-bottom: 1px solid #d3d3d3; padding: 1px 10px 1px 25px; position: relative; } div.container > div.option:hover { background-color: #f2f2f2; } div.container > div:last-child { border-bottom: none; } div.colorPreview { width: 12px; height: 12px; left: 6px; position: absolute; top: 4px; border: 1px solid lightgray; border-radius: 2px; } div.threadName { padding-top: 1px; } -div.pagerContainer { - text-align: center; - height: 15px; - margin-top: -2px; - cursor: default; - background-color: #eaeaea; - position: relative; - border-radius: 0 0 3px 3px; -} -div.pager { - position: relative; - top: -2px; -} -span.pagerStatus { - text-transform: uppercase; - color: #777777; - font-size: 9px; -} -svg.pagerIcon { - fill: #777777; - vertical-align: middle; - width: 13px; - height: 13px; -} -a.pagerButton > svg.pagerIcon { - fill: #2a5db0; -} diff --git a/web/calendar/thread-picker.react.js b/web/calendar/thread-picker.react.js index f5c960caf..016239784 100644 --- a/web/calendar/thread-picker.react.js +++ b/web/calendar/thread-picker.react.js @@ -1,195 +1,119 @@ // @flow import invariant from 'invariant'; import * as React from 'react'; import { onScreenEntryEditableThreadInfos } from 'lib/selectors/thread-selectors'; import type { ThreadInfo } from 'lib/types/thread-types'; import { useSelector } from '../redux/redux-utils'; import { htmlTargetFromEvent } from '../vector-utils'; -import { LeftPager, RightPager } from '../vectors.react'; import css from './thread-picker.css'; type OptionProps = { +threadInfo: ThreadInfo, +createNewEntry: (threadID: string) => void, }; function ThreadPickerOption(props: OptionProps) { const { threadInfo, createNewEntry } = props; const onClick = React.useCallback(() => createNewEntry(threadInfo.id), [ threadInfo.id, createNewEntry, ]); const colorStyle = { backgroundColor: `#${props.threadInfo.color}` }; return (
{props.threadInfo.uiName}
); } type BaseProps = { +createNewEntry: (threadID: string) => void, +closePicker: () => void, }; type Props = { ...BaseProps, +onScreenThreadInfos: $ReadOnlyArray, }; -type State = { - +currentPage: number, -}; - -class ThreadPicker extends React.PureComponent { - static pageSize = 5; +class ThreadPicker extends React.PureComponent { pickerDiv: ?HTMLDivElement; constructor(props: Props) { super(props); - this.state = { - currentPage: 0, - }; invariant( props.onScreenThreadInfos.length > 0, "ThreadPicker can't be open when onScreenThreadInfos is empty", ); } componentDidMount() { invariant(this.pickerDiv, 'pickerDiv ref unset'); this.pickerDiv.focus(); } render() { const length = this.props.onScreenThreadInfos.length; invariant( length > 0, "ThreadPicker can't be open when onScreenThreadInfos is empty", ); - const firstIndex = ThreadPicker.pageSize * this.state.currentPage; - const secondIndex = Math.min( - ThreadPicker.pageSize * (this.state.currentPage + 1), - length, - ); - - let pager = null; - if (length > ThreadPicker.pageSize) { - let leftPager = ; - if (this.state.currentPage > 0) { - leftPager = ( - - {leftPager} - - ); - } - let rightPager = ; - if (ThreadPicker.pageSize * (this.state.currentPage + 1) < length) { - rightPager = ( - - {rightPager} - - ); - } - pager = ( -
-
- {leftPager} - - {`${firstIndex + 1}–${secondIndex} of ${length}`} - - {rightPager} -
-
- ); - } - const options = this.props.onScreenThreadInfos - .slice(firstIndex, secondIndex) - .map(threadInfo => ( - - )); + const options = this.props.onScreenThreadInfos.map(threadInfo => ( + + )); return (
{options} - {pager}
); } pickerDivRef = (pickerDiv: ?HTMLDivElement) => { this.pickerDiv = pickerDiv; }; onPickerKeyDown = (event: SyntheticKeyboardEvent) => { if (event.keyCode === 27) { // Esc this.props.closePicker(); } }; onMouseDown = (event: SyntheticEvent) => { const target = htmlTargetFromEvent(event); invariant(this.pickerDiv, 'pickerDiv ref not set'); if (this.pickerDiv.contains(target)) { // This prevents onBlur from firing event.preventDefault(); } }; - - onBackPagerClick = (event: SyntheticEvent) => { - event.preventDefault(); - this.setState(prevState => { - invariant(prevState.currentPage > 0, "can't go back from 0"); - return { currentPage: prevState.currentPage - 1 }; - }); - }; - - onNextPagerClick = (event: SyntheticEvent) => { - event.preventDefault(); - this.setState((prevState, props) => { - invariant( - ThreadPicker.pageSize * (prevState.currentPage + 1) < - props.onScreenThreadInfos.length, - 'page is too high', - ); - return { currentPage: prevState.currentPage + 1 }; - }); - }; } const ConnectedThreadPicker: React.ComponentType = React.memo( function ConnectedThreadPicker(props) { const onScreenThreadInfos = useSelector(onScreenEntryEditableThreadInfos); return ( ); }, ); export default ConnectedThreadPicker; diff --git a/web/vectors.react.js b/web/vectors.react.js index fcbff2437..2ac011a02 100644 --- a/web/vectors.react.js +++ b/web/vectors.react.js @@ -1,124 +1,98 @@ // @flow import * as React from 'react'; type SVGProps = { className?: string, viewBox: string, preserveAspectRatio?: string, children?: React.Node, }; function SVG(props: SVGProps): React.Node { return ( ); } -export function LeftPager(props: { className?: string }): React.Node { - return ( - - - - ); -} - -export function RightPager(props: { className?: string }): React.Node { - return ( - - - - ); -} - export function UpCaret(props: { className?: string }): React.Node { return ( ); } export function DownCaret(props: { className?: string }): React.Node { return ( ); } export function DeleteVector(props: { className?: string }): React.Node { return ( ); } export function AddVector(props: { className?: string }): React.Node { return ( ); } export function HistoryVector(props: { className?: string }): React.Node { return ( ); } export function MagnifyingGlass(props: { className?: string }): React.Node { return ( ); }