mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-30 00:29:46 +08:00
fix(mobile): add missing mobile date selector and remove focus style from date picker in mobile (#9215)
Close [BS-2169](https://linear.app/affine-design/issue/BS-2169/新的-menu-不支持移动端) ### What changes - add missing date-selector for mobile - remove focus style of date picker for mobile 
This commit is contained in:
@@ -46,18 +46,18 @@ export const focusInteractive = style([
|
|||||||
basicInteractive,
|
basicInteractive,
|
||||||
{
|
{
|
||||||
selectors: {
|
selectors: {
|
||||||
'&::before': {
|
':not([data-mobile="true"]) &::before': {
|
||||||
opacity: 0,
|
opacity: 0,
|
||||||
boxShadow: `0 0 0 2px ${cssVar('brandColor')}`,
|
boxShadow: `0 0 0 2px ${cssVar('brandColor')}`,
|
||||||
},
|
},
|
||||||
'&::after': {
|
':not([data-mobile="true"]) &::after': {
|
||||||
border: '1px solid transparent',
|
border: '1px solid transparent',
|
||||||
},
|
},
|
||||||
|
|
||||||
'&:focus-visible::before': {
|
':not([data-mobile="true"]) &:focus-visible::before': {
|
||||||
opacity: 0.5,
|
opacity: 0.5,
|
||||||
},
|
},
|
||||||
'&:focus-visible::after': {
|
':not([data-mobile="true"]) &:focus-visible::after': {
|
||||||
borderColor: cssVar('brandColor'),
|
borderColor: cssVar('brandColor'),
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import type { WORKSPACE_DIALOG_SCHEMA } from '@affine/core/modules/dialogs/const
|
|||||||
import { useLiveData, useService } from '@toeverything/infra';
|
import { useLiveData, useService } from '@toeverything/infra';
|
||||||
|
|
||||||
import { CollectionSelectorDialog } from './selectors/collection-selector';
|
import { CollectionSelectorDialog } from './selectors/collection-selector';
|
||||||
|
import { DateSelectorDialog } from './selectors/date-selector';
|
||||||
import { DocSelectorDialog } from './selectors/doc-selector';
|
import { DocSelectorDialog } from './selectors/doc-selector';
|
||||||
import { TagSelectorDialog } from './selectors/tag-selector';
|
import { TagSelectorDialog } from './selectors/tag-selector';
|
||||||
import { SettingDialog } from './setting';
|
import { SettingDialog } from './setting';
|
||||||
@@ -32,6 +33,7 @@ const WORKSPACE_DIALOGS = {
|
|||||||
'tag-selector': TagSelectorDialog,
|
'tag-selector': TagSelectorDialog,
|
||||||
'doc-selector': DocSelectorDialog,
|
'doc-selector': DocSelectorDialog,
|
||||||
'collection-selector': CollectionSelectorDialog,
|
'collection-selector': CollectionSelectorDialog,
|
||||||
|
'date-selector': DateSelectorDialog,
|
||||||
} satisfies {
|
} satisfies {
|
||||||
[key in keyof WORKSPACE_DIALOG_SCHEMA]?: React.FC<
|
[key in keyof WORKSPACE_DIALOG_SCHEMA]?: React.FC<
|
||||||
DialogComponentProps<WORKSPACE_DIALOG_SCHEMA[key]>
|
DialogComponentProps<WORKSPACE_DIALOG_SCHEMA[key]>
|
||||||
|
|||||||
@@ -0,0 +1,60 @@
|
|||||||
|
import { DatePicker, Menu } from '@affine/component';
|
||||||
|
import type { DialogComponentProps } from '@affine/core/modules/dialogs';
|
||||||
|
import type { WORKSPACE_DIALOG_SCHEMA } from '@affine/core/modules/dialogs/constant';
|
||||||
|
import { useI18n } from '@affine/i18n';
|
||||||
|
import { useCallback, useState } from 'react';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A global date selector popover for mobile, mainly used in blocksuite editor
|
||||||
|
*/
|
||||||
|
export const DateSelectorDialog = ({
|
||||||
|
close,
|
||||||
|
onSelect,
|
||||||
|
}: DialogComponentProps<WORKSPACE_DIALOG_SCHEMA['date-selector']>) => {
|
||||||
|
const [selectedDate, setSelectedDate] = useState<string>();
|
||||||
|
|
||||||
|
const t = useI18n();
|
||||||
|
|
||||||
|
const onClose = useCallback(
|
||||||
|
(open: boolean) => {
|
||||||
|
if (!open) {
|
||||||
|
close();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
[close]
|
||||||
|
);
|
||||||
|
|
||||||
|
const handleSelect = useCallback(
|
||||||
|
(date?: string) => {
|
||||||
|
setSelectedDate(date);
|
||||||
|
onSelect?.(date);
|
||||||
|
},
|
||||||
|
[onSelect]
|
||||||
|
);
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Menu
|
||||||
|
rootOptions={{
|
||||||
|
modal: true,
|
||||||
|
open: true,
|
||||||
|
onOpenChange: onClose,
|
||||||
|
}}
|
||||||
|
contentOptions={{
|
||||||
|
style: {
|
||||||
|
padding: '15px 20px',
|
||||||
|
},
|
||||||
|
}}
|
||||||
|
items={
|
||||||
|
<DatePicker
|
||||||
|
weekDays={t['com.affine.calendar-date-picker.week-days']()}
|
||||||
|
monthNames={t['com.affine.calendar-date-picker.month-names']()}
|
||||||
|
todayLabel={t['com.affine.calendar-date-picker.today']()}
|
||||||
|
value={selectedDate}
|
||||||
|
onChange={handleSelect}
|
||||||
|
/>
|
||||||
|
}
|
||||||
|
>
|
||||||
|
<div />
|
||||||
|
</Menu>
|
||||||
|
);
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user