Skip to content

Commit 64ca12a

Browse files
authored
fix: fixed styles for transperant and toggler oneof (#60)
1 parent b7a584d commit 64ca12a

File tree

5 files changed

+44
-10
lines changed

5 files changed

+44
-10
lines changed

src/lib/kit/components/Inputs/OneOf/OneOf.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ const OneOfComponent: React.FC<OneOfProps> = (props) => {
4444
flat: props.withoutIndent,
4545
})}
4646
>
47-
<div>{toggler}</div>
47+
{toggler}
4848
{specProperties[oneOfValue] ? (
4949
<GroupIndent>
5050
<Controller

src/lib/kit/components/Layouts/Transparent/Transparent.scss

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414

1515
&_without-max-width {
1616
max-width: unset;
17+
18+
& > .df-error-wrapper {
19+
width: unset;
20+
}
1721
}
1822

1923
&__remove-button {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export * from './useOneOf';
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
@import '../../styles/variables.scss';
2+
3+
.#{$ns}use-oneof {
4+
&__toggler {
5+
&_radio {
6+
& > .df-row {
7+
width: unset;
8+
max-width: unset;
9+
}
10+
}
11+
}
12+
}
Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,12 @@ import React from 'react';
33
import {RadioButton, Select} from '@gravity-ui/uikit';
44
import _ from 'lodash';
55

6-
import {ObjectIndependentInputProps} from '../../core';
6+
import {ObjectIndependentInputProps} from '../../../core';
7+
import {block} from '../../utils';
8+
9+
import './useOneOf.scss';
10+
11+
const b = block('use-oneof');
712

813
const MAX_TAB_TITLE_LENGTH = 20;
914

@@ -63,13 +68,17 @@ export const useOneOf = ({props, onTogglerChange}: UseOneOfParams) => {
6368
[spec.description, spec.viewSpec.order, specProperties],
6469
);
6570

66-
const togglerInput = React.useMemo(() => {
67-
if (
71+
const selectToggler = React.useMemo(
72+
() =>
6873
spec.viewSpec.oneOfParams?.toggler !== 'radio' &&
6974
(spec.viewSpec.oneOfParams?.toggler === 'select' ||
7075
options.length > 3 ||
71-
_.some(options, ({title}) => title.length > MAX_TAB_TITLE_LENGTH))
72-
) {
76+
_.some(options, ({title}) => title.length > MAX_TAB_TITLE_LENGTH)),
77+
[options, spec.viewSpec.oneOfParams?.toggler],
78+
);
79+
80+
const togglerInput = React.useMemo(() => {
81+
if (selectToggler) {
7382
return (
7483
<Select
7584
width="max"
@@ -97,15 +106,23 @@ export const useOneOf = ({props, onTogglerChange}: UseOneOfParams) => {
97106
))}
98107
</RadioButton>
99108
);
100-
}, [options, oneOfValue, onOneOfChange, name, spec.viewSpec.oneOfParams?.toggler]);
109+
}, [selectToggler, oneOfValue, spec.viewSpec.disabled, name, options, onOneOfChange]);
101110

102111
const toggler = React.useMemo(() => {
103112
if (Layout) {
104-
return <Layout {...props}>{togglerInput}</Layout>;
113+
return (
114+
<div
115+
className={b('toggler', {
116+
radio: !selectToggler,
117+
})}
118+
>
119+
<Layout {...props}>{togglerInput}</Layout>
120+
</div>
121+
);
105122
}
106123

107-
return togglerInput;
108-
}, [Layout, togglerInput, props]);
124+
return <div>{togglerInput}</div>;
125+
}, [Layout, togglerInput, selectToggler, props]);
109126

110127
return {oneOfValue, specProperties, toggler, togglerInput};
111128
};

0 commit comments

Comments
 (0)