From 94c91982292bf20b5ae4cdb2acf590a21320ac2b Mon Sep 17 00:00:00 2001
From: 3y3 <3y3@ya.ru>
Date: Tue, 21 Nov 2023 15:03:28 +0300
Subject: [PATCH] feat(Controls): Add optional isWideView prop
---
src/components/Control/Control.tsx | 3 +++
src/components/Controls/ControlsLayout.tsx | 4 ++++
.../single-controls/SettingsControl/SettingsControl.tsx | 3 ++-
3 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/src/components/Control/Control.tsx b/src/components/Control/Control.tsx
index aa779526..16c1786f 100644
--- a/src/components/Control/Control.tsx
+++ b/src/components/Control/Control.tsx
@@ -18,6 +18,7 @@ export interface IconProps {
export interface ControlProps {
onClick?: () => void;
setRef?: (ref: HTMLButtonElement) => void;
+ isWideView?: boolean;
isVerticalView?: boolean;
tooltipText: string;
isTooltipHidden?: boolean;
@@ -42,6 +43,7 @@ const Control = forwardRef((props: ControlProps, ref) => {
className,
tooltipText,
isTooltipHidden,
+ isWideView,
isVerticalView,
size = ControlSizes.M,
icon,
@@ -91,6 +93,7 @@ const Control = forwardRef((props: ControlProps, ref) => {
+ {isWideView ? tooltipText : null}
{controlRef.current && (
({
controlClassName: '',
+ isWideView: false,
isVerticalView: false,
controlSize: ControlSizes.M,
popupPosition: PopperPosition.BOTTOM_END,
@@ -22,6 +24,7 @@ export const ControlsLayoutContext = createContext({
const b = block('dc-controls');
export const ControlsLayout: React.FC> = ({
+ isWideView,
isVerticalView,
controlClassName,
controlSize,
@@ -32,6 +35,7 @@ export const ControlsLayout: React.FC> =
{
const {t} = useTranslation('controls');
- const {controlClassName, controlSize, isVerticalView, popupPosition} =
+ const {controlClassName, controlSize, isVerticalView, isWideView, popupPosition} =
useContext(ControlsLayoutContext);
const {
textSize,
@@ -207,6 +207,7 @@ const SettingsControl = (props: ControlProps) => {
ref={controlRef}
size={controlSize}
onClick={showPopup}
+ isWideView={isWideView}
isVerticalView={isVerticalView}
tooltipText={t('settings-text')}
popupPosition={popupPosition}