import React, { ReactNode } from 'react';
import { Switch, Divider, InputNumber } from '@arco-design/web-react';
import { useStore } from '@/store';
import useLocale from '../../utils/useLocale';
import styles from './style/block.module.less';
export interface BlockProps {
title?: ReactNode;
options?: { name: string; value: string; type?: 'switch' | 'number' }[];
children?: ReactNode;
}
export default function Block(props: BlockProps) {
const { title, options, children } = props;
const locale = useLocale();
const { settings, updateSetting } = useStore();
return (
{title}
{options &&
options.map((option) => {
const type = option.type || 'switch';
return (
{locale[option.name]}
{type === 'switch' && (
{
const newSetting = {
...settings,
[option.value]: checked
};
updateSetting(newSetting);
// set color week
if (checked && option.value === 'colorWeek') {
document.body.style.filter = 'invert(80%)';
}
if (!checked && option.value === 'colorWeek') {
document.body.style.filter = 'none';
}
}}
/>
)}
{type === 'number' && (
{
const newSetting = {
...settings,
[option.value]: value
};
updateSetting(newSetting);
}}
/>
)}
);
})}
{children}
);
}