tachybase_todo/packages/plugins/@nocobase/plugin-calendar/src/client/calendar/Title.tsx
Dunqing e112a644ea
feat(plugin-calendar): add calendar plugin (#3109)
* feat: init calendar plugin

* feat: move files to plugin

* feat: handle CalendarBlockInitializer in plugin

* feat: add todo

* feat: move collection template to plugin and fix i18n

* chore: update deps

* feat: export genStyleHook

* feat: handle i18n

* chore: remove react-i18next

* docs: update info

* test: move e2e test

* test: move to client

* chore: update version

* fix: merge revert

* fix: merge revert

* fix: missing SchemaSettings.xxx

* test: fix e2e failed

* test: update

* test: fix case failed

* fix: data blocks

* fix: remove provider

* fix: missing CalendarV2

* fix: missing CalendarActionInitializers

* fix: version

* fix: error

* fix: calender block form action should support print

---------

Co-authored-by: chenos <chenlinxh@gmail.com>
Co-authored-by: katherinehhh <katherine_15995@163.com>
2023-12-23 15:16:41 +08:00

30 lines
894 B
TypeScript

import { observer } from '@formily/react';
import { Button } from 'antd';
import React, { useContext, useMemo } from 'react';
import { CalendarToolbarContext } from './context';
import { getLunarDay } from './utils';
import { useDesignable } from '@nocobase/client';
export const Title = observer(
() => {
const { DesignableBar } = useDesignable();
const { date, view, label, showLunar } = useContext(CalendarToolbarContext);
const lunarElement = useMemo(() => {
if (!showLunar || view !== 'day') {
return;
}
return <span>{getLunarDay(date)}</span>;
}, [view, date, showLunar]);
return (
<Button.Group style={{ fontSize: '1.75em', fontWeight: 300 }}>
<span>{label}</span>
<span style={{ marginLeft: '4px' }}>{lunarElement}</span>
<DesignableBar />
</Button.Group>
);
},
{ displayName: 'Title' },
);