Skip to content

Commit

Permalink
feat(slot): rtl 支持配置隐藏 #14
Browse files Browse the repository at this point in the history
  • Loading branch information
Aruelius authored Jul 10, 2023
1 parent 351f7a0 commit 2912fd8
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/slots/RtlSwitch/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { useContext, type FC } from 'react';
import { css } from '@emotion/react';
import type { SiteContextProps } from '../SiteContext';
import SiteContext from '../SiteContext';
import useAdditionalThemeConfig from '../../hooks/useAdditionalThemeConfig';
import SwitchBtn from '../Header/SwitchBtn';
import LTRIcon from '../../icons/LTRIcon';
import RTLIcon from '../../icons/RTLIcon';
Expand All @@ -17,6 +18,9 @@ const useStyle = () => {
const RtlSwitch: FC = () => {
const { direction, updateSiteConfig } = useContext<SiteContextProps>(SiteContext);
const { dataDirectionIcon } = useStyle();
const { rtl } = useAdditionalThemeConfig();

if (!rtl) return null;

const onDirectionChange = () => {
updateSiteConfig({ direction: direction !== 'rtl' ? 'rtl' : 'ltr' });
Expand Down

0 comments on commit 2912fd8

Please sign in to comment.