Skip to content

Commit

Permalink
feat(Controls): Add optional isWideView prop
Browse files Browse the repository at this point in the history
  • Loading branch information
3y3 committed Nov 21, 2023
1 parent 4dcbdb3 commit 94c9198
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/components/Control/Control.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export interface IconProps {
export interface ControlProps {
onClick?: () => void;
setRef?: (ref: HTMLButtonElement) => void;
isWideView?: boolean;
isVerticalView?: boolean;
tooltipText: string;
isTooltipHidden?: boolean;
Expand All @@ -42,6 +43,7 @@ const Control = forwardRef((props: ControlProps, ref) => {
className,
tooltipText,
isTooltipHidden,
isWideView,
isVerticalView,
size = ControlSizes.M,
icon,
Expand Down Expand Up @@ -91,6 +93,7 @@ const Control = forwardRef((props: ControlProps, ref) => {
<Button.Icon>
<Icon width={iconSize} height={iconSize} />
</Button.Icon>
{isWideView ? tooltipText : null}
</Button>
{controlRef.current && (
<Popup
Expand Down
4 changes: 4 additions & 0 deletions src/components/Controls/ControlsLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {PopperPosition} from '../../hooks';
import {ControlSizes} from '../../models';

type ControlsLayoutProps = {
isWideView?: boolean;
isVerticalView?: boolean;
controlClassName?: string;
controlSize?: ControlSizes;
Expand All @@ -14,6 +15,7 @@ type ControlsLayoutProps = {

export const ControlsLayoutContext = createContext<ControlsLayoutProps>({
controlClassName: '',
isWideView: false,
isVerticalView: false,
controlSize: ControlSizes.M,
popupPosition: PopperPosition.BOTTOM_END,
Expand All @@ -22,6 +24,7 @@ export const ControlsLayoutContext = createContext<ControlsLayoutProps>({
const b = block('dc-controls');

export const ControlsLayout: React.FC<PropsWithChildren<ControlsLayoutProps>> = ({
isWideView,
isVerticalView,
controlClassName,
controlSize,
Expand All @@ -32,6 +35,7 @@ export const ControlsLayout: React.FC<PropsWithChildren<ControlsLayoutProps>> =
<ControlsLayoutContext.Provider
value={{
controlClassName: controlClassName || b('control'),
isWideView: isWideView,
isVerticalView: isVerticalView,
controlSize: controlSize,
popupPosition: popupPosition,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ interface SettingControlItem {

const SettingsControl = (props: ControlProps) => {
const {t} = useTranslation('controls');
const {controlClassName, controlSize, isVerticalView, popupPosition} =
const {controlClassName, controlSize, isVerticalView, isWideView, popupPosition} =
useContext(ControlsLayoutContext);
const {
textSize,
Expand Down Expand Up @@ -207,6 +207,7 @@ const SettingsControl = (props: ControlProps) => {
ref={controlRef}
size={controlSize}
onClick={showPopup}
isWideView={isWideView}
isVerticalView={isVerticalView}
tooltipText={t('settings-text')}
popupPosition={popupPosition}
Expand Down

0 comments on commit 94c9198

Please sign in to comment.