diff --git a/public/locales/en/component.json b/public/locales/en/component.json index 02c37c4bd986..eb8b0099d881 100644 --- a/public/locales/en/component.json +++ b/public/locales/en/component.json @@ -3,5 +3,9 @@ "title": "Components", "searchPlaceholder": "Search by component name", "color-input_validation-format-error": "Incorrect format", - "maintainers": "Maintainers:" + "maintainers": "Maintainers:", + "theme": "Switch theme", + "rtlOn": "Switch RTL on", + "rtlOff": "Switch RTL off", + "rtlNotSupported": "RTL not supported" } diff --git a/public/locales/ru/component.json b/public/locales/ru/component.json index d78680c31347..dc452bcf66e3 100644 --- a/public/locales/ru/component.json +++ b/public/locales/ru/component.json @@ -2,5 +2,10 @@ "actions_openInFigma": "Открыть в Figma", "title": "Компоненты", "searchPlaceholder": "Поиск по названию", - "color-input_validation-format-error": "Неверный формат" + "color-input_validation-format-error": "Неверный формат", + "maintainers": "Maintainers:", + "theme": "Переключить тему", + "rtlOn": "Включить RTL", + "rtlOff": "Выключить RTL", + "rtlNotSupported": "RTL не поддерживается" } diff --git a/src/components/SandboxBlock/SandboxBlock.tsx b/src/components/SandboxBlock/SandboxBlock.tsx index 8e7b9d4b35b5..4c8b6609d186 100644 --- a/src/components/SandboxBlock/SandboxBlock.tsx +++ b/src/components/SandboxBlock/SandboxBlock.tsx @@ -1,4 +1,9 @@ -import {ChevronsCollapseUpRight, ChevronsExpandUpRight, TextAlignRight} from '@gravity-ui/icons'; +import { + ChevronsCollapseUpRight, + ChevronsExpandUpRight, + TextAlignLeft, + TextAlignRight, +} from '@gravity-ui/icons'; import { Col, Direction, @@ -13,6 +18,7 @@ import { Theme, Tooltip, } from '@gravity-ui/uikit'; +import {useTranslation} from 'next-i18next'; import React from 'react'; import themeIcon from '../../assets/icons/theme.svg'; @@ -29,6 +35,8 @@ const SandboxBlock: React.FC = ({ sandboxConfig, isSupportRTL, }) => { + const {t} = useTranslation('component'); + const [props, setProps] = React.useState({}); const [isIframeLoaded, setIsIframeLoaded] = React.useState(false); @@ -178,6 +186,10 @@ const SandboxBlock: React.FC = ({ } }, [isIframeLoaded, props, iframeTheme, iframeDirection]); + const isRtl = iframeDirection === 'rtl'; + + const rtlIcon = isRtl ? TextAlignRight : TextAlignLeft; + return (
@@ -193,39 +205,44 @@ const SandboxBlock: React.FC = ({
-
{ - setIframeTheme(iframeTheme === 'dark' ? 'light' : 'dark'); - }} - > - -
-
{ - if (isSupportRTL) { - setIframeDirection( - iframeDirection === 'ltr' ? 'rtl' : 'ltr', - ); - } - }} - > - {isSupportRTL && ( - - )} - {!isSupportRTL && ( - - - - )} -
+ +
{ + setIframeTheme(iframeTheme === 'dark' ? 'light' : 'dark'); + }} + > + +
+
+ + {isSupportRTL && ( + +
{ + setIframeDirection(isRtl ? 'ltr' : 'rtl'); + }} + > + +
+
+ )} + {!isSupportRTL && ( + +
+ +
+
+ )}