mirror of
https://github.com/NetEase/tango.git
synced 2026-08-29 02:01:34 +08:00
docs: add site alert
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
import React, { useState } from 'react';
|
||||
|
||||
export interface AlertProps {
|
||||
type?: 'primary' | 'secondary' | 'success' | 'danger' | 'warning' | 'info';
|
||||
closeable?: boolean;
|
||||
children: React.ReactNode;
|
||||
}
|
||||
|
||||
export function Alert({ type = 'primary', closeable, children }: AlertProps) {
|
||||
const [visible, setVisible] = useState(true);
|
||||
if (!visible) {
|
||||
return <div className="alert" role="alert" />;
|
||||
}
|
||||
return (
|
||||
<div className={`alert alert--${type}`} role="alert">
|
||||
{closeable && (
|
||||
<button
|
||||
aria-label="Close"
|
||||
className="clean-btn close"
|
||||
type="button"
|
||||
onClick={() => setVisible(false)}
|
||||
>
|
||||
<span aria-hidden="true">×</span>
|
||||
</button>
|
||||
)}
|
||||
{children}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
@@ -6,12 +6,16 @@ import Layout from '@theme/Layout';
|
||||
import HomepageFeatures from '@site/src/components/HomepageFeatures';
|
||||
|
||||
import styles from './index.module.css';
|
||||
import { Alert } from '../components/alert';
|
||||
|
||||
function HomepageHeader() {
|
||||
const { siteConfig } = useDocusaurusContext();
|
||||
return (
|
||||
<header className={clsx('hero', styles.heroBanner)}>
|
||||
<div className="container">
|
||||
<div className="margin-bottom--lg">
|
||||
<Alert type="info">🏗 站点正在建设中,即将发布,敬请期待!</Alert>
|
||||
</div>
|
||||
<h1 className="hero__title">{siteConfig.title}</h1>
|
||||
<p className="hero__subtitle">{siteConfig.tagline}</p>
|
||||
<div className={styles.buttons}>
|
||||
|
||||
Reference in New Issue
Block a user