Commit d7e12ae
Changed files (7)
src
components
i18n
src/components/widgets/Button.astro
@@ -1,8 +1,10 @@
---
import type { HTMLAttributes } from 'astro/types';
-type Props = HTMLAttributes<'button'> | HTMLAttributes<'a'>;
-let { class: className, ...rest } = Astro.props;
+type Props = (HTMLAttributes<'button'> | HTMLAttributes<'a'>) & {
+ useDefaultClass?: boolean;
+};
+let { class: className, useDefaultClass, ...rest } = Astro.props;
function isAnchor(props: Props): props is HTMLAttributes<'a'> {
return 'href' in props;
@@ -11,6 +13,6 @@ function isAnchor(props: Props): props is HTMLAttributes<'a'> {
const Tag = isAnchor(rest) ? 'a' : 'button';
---
-<Tag class:list={['btn', className]} {...rest as object}>
+<Tag class:list={[(useDefaultClass ?? true) && 'btn', className]} {...rest as object}>
<slot />
</Tag>
src/components/widgets/DarkModeButton.astro
@@ -7,13 +7,15 @@ import Button from './Button.astro';
interface Props extends Omit<HTMLAttributes<'button'>, 'onclick'> {
showText?: boolean;
+ useDefaultBtnClass?: boolean;
}
-const { class: className, showText, ...rest } = Astro.props;
+const { class: className, showText, useDefaultBtnClass, ...rest } = Astro.props;
---
<Button
class:list={['darkmode-btn swap swap-rotate', className]}
+ useDefaultClass={useDefaultBtnClass}
{...rest}
data-text-light={i18n(I18nKey.lightMode)}
data-text-dark={i18n(I18nKey.darkMode)}
src/i18n/langs/en.ts
@@ -8,6 +8,7 @@ export const en: Translation = {
[Key.search]: 'Search',
[Key.links]: 'Links',
[Key.time]: 'Time',
+ [Key.menu]: 'Menu',
[Key.tags]: 'Tags',
[Key.categories]: 'Categories',
src/i18n/langs/zh_CN.ts
@@ -8,6 +8,7 @@ export const zh_CN: Translation = {
[Key.search]: '搜索',
[Key.links]: '友链',
[Key.time]: '时间',
+ [Key.menu]: '菜单',
[Key.tags]: '标签',
[Key.categories]: '分类',
src/i18n/langs/zh_TW.ts
@@ -8,6 +8,7 @@ export const zh_TW: Translation = {
[Key.search]: '搜尋',
[Key.links]: '連結',
[Key.time]: '時間',
+ [Key.menu]: '選單',
[Key.tags]: '標籤',
[Key.categories]: '分類',
src/i18n/I18nKey.ts
@@ -5,6 +5,7 @@ enum I18nKey {
search = 'search',
links = 'links',
time = 'time',
+ menu = 'menu',
tags = 'tags',
categories = 'categories',