refactor: add title for status page and update UI style for it.

This commit is contained in:
moonrailgun 2024-04-14 16:43:38 +08:00
parent 8a3c93fff7
commit d3ce409002
5 changed files with 368 additions and 336 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,9 +1,10 @@
import { Button, Divider, Form, Input, Switch, Typography } from 'antd'; import { Switch, Divider, Form, Input, Typography } from 'antd';
import React from 'react'; import React from 'react';
import { MinusCircleOutlined, PlusOutlined } from '@ant-design/icons';
import { MonitorPicker } from '../MonitorPicker'; import { MonitorPicker } from '../MonitorPicker';
import { urlSlugValidator } from '../../../utils/validator'; import { urlSlugValidator } from '../../../utils/validator';
import { useTranslation } from '@i18next-toolkit/react'; import { useTranslation } from '@i18next-toolkit/react';
import { Button } from '@/components/ui/button';
import { LuMinusCircle, LuPlus } from 'react-icons/lu';
const { Text } = Typography; const { Text } = Typography;
@ -96,7 +97,7 @@ export const MonitorStatusPageEditForm: React.FC<MonitorStatusPageEditFormProps>
</Form.Item> </Form.Item>
<div className="item-center flex"> <div className="item-center flex">
<div className="flex-1"> <div className="flex flex-1 items-center">
<Form.Item <Form.Item
name={[field.name, 'showCurrent']} name={[field.name, 'showCurrent']}
valuePropName="checked" valuePropName="checked"
@ -110,8 +111,8 @@ export const MonitorStatusPageEditForm: React.FC<MonitorStatusPageEditFormProps>
</span> </span>
</div> </div>
<MinusCircleOutlined <LuMinusCircle
className="mt-1.5 text-lg" className="mt-1.5 cursor-pointer text-lg"
onClick={() => remove(field.name)} onClick={() => remove(field.name)}
/> />
</div> </div>
@ -121,10 +122,10 @@ export const MonitorStatusPageEditForm: React.FC<MonitorStatusPageEditFormProps>
</div> </div>
<Button <Button
type="dashed" variant="dashed"
onClick={() => add()} onClick={() => add()}
style={{ width: '60%' }} style={{ width: '60%' }}
icon={<PlusOutlined />} Icon={LuPlus}
> >
{t('Add Monitor')} {t('Add Monitor')}
</Button> </Button>
@ -137,12 +138,12 @@ export const MonitorStatusPageEditForm: React.FC<MonitorStatusPageEditFormProps>
</Form.List> </Form.List>
<div className="flex gap-4"> <div className="flex gap-4">
<Button type="primary" htmlType="submit" loading={props.isLoading}> <Button type="submit" loading={props.isLoading}>
{props.saveButtonLabel ?? t('Save')} {props.saveButtonLabel ?? t('Save')}
</Button> </Button>
{props.onCancel && ( {props.onCancel && (
<Button htmlType="button" onClick={props.onCancel}> <Button variant="outline" type="button" onClick={props.onCancel}>
{t('Cancel')} {t('Cancel')}
</Button> </Button>
)} )}

View File

@ -1,4 +1,3 @@
import { Button } from 'antd';
import React, { useState } from 'react'; import React, { useState } from 'react';
import { trpc } from '../../../api/trpc'; import { trpc } from '../../../api/trpc';
import { useAllowEdit } from './useAllowEdit'; import { useAllowEdit } from './useAllowEdit';
@ -12,6 +11,8 @@ import { ColorSchemeSwitcher } from '../../ColorSchemeSwitcher';
import { StatusPageServices } from './Services'; import { StatusPageServices } from './Services';
import { useTranslation } from '@i18next-toolkit/react'; import { useTranslation } from '@i18next-toolkit/react';
import { Link, useNavigate } from '@tanstack/react-router'; import { Link, useNavigate } from '@tanstack/react-router';
import { Helmet } from 'react-helmet';
import { Button } from '@/components/ui/button';
interface MonitorStatusPageProps { interface MonitorStatusPageProps {
slug: string; slug: string;
@ -72,6 +73,13 @@ export const MonitorStatusPage: React.FC<MonitorStatusPageProps> = React.memo(
return ( return (
<div className="flex h-full w-full"> <div className="flex h-full w-full">
<Helmet>
<title>
{info?.title}
{info?.description && ` | ${info?.description}`}
</title>
</Helmet>
{editMode && ( {editMode && (
<div className="w-1/3 overflow-auto border-r border-gray-300 px-4 py-8 dark:border-gray-600"> <div className="w-1/3 overflow-auto border-r border-gray-300 px-4 py-8 dark:border-gray-600">
<MonitorStatusPageEditForm <MonitorStatusPageEditForm
@ -97,13 +105,11 @@ export const MonitorStatusPage: React.FC<MonitorStatusPageProps> = React.memo(
{allowEdit && !editMode && ( {allowEdit && !editMode && (
<div className="mb-4 flex gap-2"> <div className="mb-4 flex gap-2">
<Button type="primary" onClick={() => setEditMode(true)}> <Button onClick={() => setEditMode(true)}>{t('Edit')}</Button>
{t('Edit')}
</Button>
{showBackBtn && ( {showBackBtn && (
<Link to="/"> <Link to="/">
<Button type="default">{t('Back to Admin')}</Button> <Button variant="outline">{t('Back to Admin')}</Button>
</Link> </Link>
)} )}
</div> </div>

View File

@ -21,6 +21,8 @@ const buttonVariants = cva(
'bg-zinc-100 text-zinc-900 shadow-sm hover:bg-zinc-100/80 dark:bg-zinc-800 dark:text-zinc-50 dark:hover:bg-zinc-800/80', 'bg-zinc-100 text-zinc-900 shadow-sm hover:bg-zinc-100/80 dark:bg-zinc-800 dark:text-zinc-50 dark:hover:bg-zinc-800/80',
ghost: ghost:
'hover:bg-zinc-100 hover:text-zinc-900 dark:hover:bg-zinc-800 dark:hover:text-zinc-50', 'hover:bg-zinc-100 hover:text-zinc-900 dark:hover:bg-zinc-800 dark:hover:text-zinc-50',
dashed:
'border border-zinc-200 bg-white shadow-sm border-dashed hover:bg-zinc-100 hover:text-zinc-900 dark:border-zinc-800 dark:bg-zinc-950 dark:hover:bg-zinc-800 dark:hover:text-zinc-50',
link: 'text-zinc-900 underline-offset-4 hover:underline dark:text-zinc-50', link: 'text-zinc-900 underline-offset-4 hover:underline dark:text-zinc-50',
}, },
size: { size: {

View File

@ -71,6 +71,7 @@
"react-dom": "^18.2.0", "react-dom": "^18.2.0",
"react-easy-sort": "^1.5.3", "react-easy-sort": "^1.5.3",
"react-grid-layout": "1.4.2", "react-grid-layout": "1.4.2",
"react-helmet": "^6.1.0",
"react-hook-form": "^7.51.1", "react-hook-form": "^7.51.1",
"react-icons": "^4.12.0", "react-icons": "^4.12.0",
"react-leaflet": "^4.2.1", "react-leaflet": "^4.2.1",
@ -92,9 +93,10 @@
"@types/leaflet": "^1.9.8", "@types/leaflet": "^1.9.8",
"@types/loadable__component": "^5.13.8", "@types/loadable__component": "^5.13.8",
"@types/lodash-es": "^4.17.12", "@types/lodash-es": "^4.17.12",
"@types/react": "^18.2.21", "@types/react": "^18.2.22",
"@types/react-dom": "^18.2.7", "@types/react-dom": "^18.2.7",
"@types/react-grid-layout": "^1.3.5", "@types/react-grid-layout": "^1.3.5",
"@types/react-helmet": "^6.1.11",
"@types/react-resizable": "^3.0.7", "@types/react-resizable": "^3.0.7",
"@types/uuid": "^9.0.7", "@types/uuid": "^9.0.7",
"@vitejs/plugin-react": "^4.0.4", "@vitejs/plugin-react": "^4.0.4",