import type { AnchorHTMLAttributes, ButtonHTMLAttributes, ReactNode } from 'react';
import { Languages, Moon, Sun } from '../icons';
import type { Theme } from '../prefs';
import { href, onLinkClick } from '../router';
const BASE = import.meta.env.BASE_URL;
/** 左上角的 Midway 标识,点击回到教程首页。 */
export function Logo({ label }: { label: string }) {
return (
Midway
{label}
);
}
type IconButtonProps =
| ({ as?: 'button'; title: string; children: ReactNode } & ButtonHTMLAttributes)
| ({ as: 'a'; title: string; children: ReactNode } & AnchorHTMLAttributes);
/** 只有图标的按钮,`title` 同时作为无障碍标签。 */
export function IconButton(props: IconButtonProps) {
if (props.as === 'a') {
const { as: _as, title, children, ...rest } = props;
return (
{children}
);
}
const { as: _as, title, children, ...rest } = props;
return (
);
}
export function ThemeButton(props: { theme: Theme; title: string; onClick: () => void }) {
return (
{props.theme === 'dark' ? : }
);
}
export function LocaleButton(props: { label: string; onClick: () => void }) {
return (
);
}