Consistent naming on label controls

- Edit Labels: Edit all of a user's labels
- Set Labels: Set the labels assigned to a link
This commit is contained in:
Jackson Harper
2022-04-13 10:51:56 -07:00
parent fe56c4a689
commit 4e4dae89d7
5 changed files with 22 additions and 25 deletions

View File

@ -7,7 +7,7 @@ import { Dropdown } from "../../elements/DropdownElements"
import { Box, SpanBox } from "../../elements/LayoutPrimitives"
import { TooltipWrapped } from "../../elements/Tooltip"
import { styled, theme } from "../../tokens/stitches.config"
import { EditLabelsControl } from "./EditLabelsControl"
import { SetLabelsControl } from "./SetLabelsControl"
import { ReaderSettingsControl } from "./ReaderSettingsControl"
export type ArticleActionsMenuLayout = 'horizontal' | 'vertical'
@ -101,7 +101,7 @@ export function ArticleActionsMenu(props: ArticleActionsMenuProps): JSX.Element
</TooltipWrapped>
}
>
<EditLabelsControl
<SetLabelsControl
article={props.article}
articleActionHandler={props.articleActionHandler}
/>
@ -109,7 +109,7 @@ export function ArticleActionsMenu(props: ArticleActionsMenuProps): JSX.Element
</SpanBox>
<Button style='articleActionIcon'
onClick={() => props.articleActionHandler('editLabels')}
onClick={() => props.articleActionHandler('setLabels')}
css={{
'display': 'none',
'@smDown': {

View File

@ -9,7 +9,6 @@ import { Label } from '../../../lib/networking/fragments/labelFragment'
import { useGetLabelsQuery } from '../../../lib/networking/queries/useGetLabelsQuery'
import { ArticleAttributes } from '../../../lib/networking/queries/useGetArticleQuery'
import { Check, Circle, PencilSimple, Plus } from 'phosphor-react'
import { isTouchScreenDevice } from '../../../lib/deviceType'
import { setLabelsMutation } from '../../../lib/networking/mutations/setLabelsMutation'
import { createLabelMutation } from '../../../lib/networking/mutations/createLabelMutation'
@ -17,7 +16,7 @@ import { showErrorToast, showSuccessToast } from '../../../lib/toastHelpers'
import { randomLabelColorHex } from '../../../utils/settings-page/labels/labelColorObjects'
import { useRouter } from 'next/router'
type EditLabelsControlProps = {
type SetLabelsControlProps = {
article: ArticleAttributes
articleActionHandler: (action: string, arg?: unknown) => void
}
@ -147,11 +146,11 @@ function LabelListItem(props: LabelListItemProps): JSX.Element {
)
}
type EditLabelsButtonFooterProps = {
type FooterProps = {
focused: boolean
}
function EditLabelsButtonFooter(props: EditLabelsButtonFooterProps): JSX.Element {
function Footer(props: FooterProps): JSX.Element {
const ref = useRef<HTMLDivElement>(null)
useEffect(() => {
@ -184,7 +183,7 @@ function EditLabelsButtonFooter(props: EditLabelsButtonFooterProps): JSX.Element
)
}
export function EditLabelsControl(props: EditLabelsControlProps): JSX.Element {
export function SetLabelsControl(props: SetLabelsControlProps): JSX.Element {
const router = useRouter()
const [filterText, setFilterText] = useState('')
const { labels, revalidate } = useGetLabelsQuery()
@ -340,7 +339,7 @@ export function EditLabelsControl(props: EditLabelsControlProps): JSX.Element {
</Button>
)}
<EditLabelsButtonFooter focused={focusedIndex === (filteredLabels.length + 1)} />
<Footer focused={focusedIndex === (filteredLabels.length + 1)} />
</VStack>
)
}

View File

@ -1,8 +1,7 @@
import { X } from 'phosphor-react'
import { ArticleAttributes } from '../../../lib/networking/queries/useGetArticleQuery'
import { Button } from '../../elements/Button'
import { CrossIcon } from '../../elements/images/CrossIcon'
import { Box, HStack, VStack } from '../../elements/LayoutPrimitives'
import { HStack, VStack } from '../../elements/LayoutPrimitives'
import {
ModalRoot,
ModalOverlay,
@ -10,15 +9,15 @@ import {
} from '../../elements/ModalPrimitives'
import { StyledText } from '../../elements/StyledText'
import { theme } from '../../tokens/stitches.config'
import { EditLabelsControl } from './EditLabelsControl'
import { SetLabelsControl } from './SetLabelsControl'
type EditLabelsModalProps = {
type SetLabelsModalProps = {
article: ArticleAttributes
onOpenChange: (open: boolean) => void
articleActionHandler: (action: string, arg?: unknown) => void
}
export function EditLabelsModal(props: EditLabelsModalProps): JSX.Element {
export function SetLabelsModal(props: SetLabelsModalProps): JSX.Element {
return (
<ModalRoot defaultOpen onOpenChange={props.onOpenChange}>
<ModalOverlay />
@ -49,7 +48,7 @@ export function EditLabelsModal(props: EditLabelsModalProps): JSX.Element {
/>
</Button>
</HStack>
<EditLabelsControl {...props} />
<SetLabelsControl {...props} />
</VStack>
</ModalContent>
</ModalRoot>

View File

@ -209,7 +209,7 @@ type ArticleKeyboardAction =
| 'decrementFontSize'
| 'incrementMarginWidth'
| 'decrementMarginWidth'
| 'editLabels'
| 'setLabels'
export function articleKeyboardCommands(
router: NextRouter | undefined,
@ -256,7 +256,7 @@ export function articleKeyboardCommands(
shortcutKeys: ['l'],
actionDescription: 'Edit labels',
shortcutKeyDescription: 'l',
callback: () => actionHandler('editLabels'),
callback: () => actionHandler('setLabels'),
},
]
}

View File

@ -27,8 +27,7 @@ import { setLinkArchivedMutation } from '../../../lib/networking/mutations/setLi
import { Label } from '../../../lib/networking/fragments/labelFragment'
import { useSWRConfig } from 'swr'
import { showErrorToast, showSuccessToast } from '../../../lib/toastHelpers'
import { EditLabelsControl } from '../../../components/templates/article/EditLabelsControl'
import { EditLabelsModal } from '../../../components/templates/article/EditLabelsModal'
import { SetLabelsModal } from '../../../components/templates/article/SetLabelsModal'
import { DisplaySettingsModal } from '../../../components/templates/article/DisplaySettingsModal'
@ -49,7 +48,7 @@ export default function Home(): JSX.Element {
const [fontSize, setFontSize] = useState(preferencesData?.fontSize ?? 20)
const [marginWidth, setMarginWidth] = useState(preferencesData?.margin ?? 360)
const [lineHeight, setLineHeight] = useState(preferencesData?.lineHeight ?? 150)
const [showEditLabelsModal, setShowEditLabelsModal] = useState(false)
const [showSetLabelsModal, setShowSetLabelsModal] = useState(false)
const [showEditDisplaySettingsModal, setShowEditDisplaySettingsModal] = useState(false)
const { articleData } = useGetArticleQuery({
@ -140,8 +139,8 @@ export default function Home(): JSX.Element {
setShowEditDisplaySettingsModal(true)
break
}
case 'editLabels': {
setShowEditLabelsModal(true)
case 'setLabels': {
setShowSetLabelsModal(true)
break
}
case 'resetReaderSettings': {
@ -243,11 +242,11 @@ export default function Home(): JSX.Element {
</VStack>
)}
{showEditLabelsModal && (
<EditLabelsModal
{showSetLabelsModal && (
<SetLabelsModal
article={article}
articleActionHandler={actionHandler}
onOpenChange={() => setShowEditLabelsModal(false)}
onOpenChange={() => setShowSetLabelsModal(false)}
/>
)}