fix(core): disable border thickness setting when no border is selected (#8152)

close AF-1351
This commit is contained in:
JimmFly
2024-09-09 03:25:03 +00:00
parent 6b266e3a1b
commit a7ecfea3b5
4 changed files with 25 additions and 1 deletions
@@ -3,7 +3,13 @@ import { createVar, style } from '@vanilla-extract/css';
export const thumbSize = createVar(); export const thumbSize = createVar();
export const root = style({}); export const root = style({
selectors: {
'&[data-disabled]': {
opacity: 0.5,
},
},
});
export const trackStyle = style({ export const trackStyle = style({
width: '100%', width: '100%',
@@ -13,6 +19,11 @@ export const trackStyle = style({
alignItems: 'center', alignItems: 'center',
padding: '12px 0', padding: '12px 0',
cursor: 'pointer', cursor: 'pointer',
selectors: {
'&[data-disabled]': {
cursor: 'not-allowed',
},
},
}); });
export const fakeTrackStyle = style({ export const fakeTrackStyle = style({
width: `calc(100% - ${thumbSize})`, width: `calc(100% - ${thumbSize})`,
@@ -42,6 +53,11 @@ export const thumbStyle = style({
top: '50%', top: '50%',
transform: 'translate(-50%, -50%)', transform: 'translate(-50%, -50%)',
cursor: 'pointer', cursor: 'pointer',
selectors: {
'&[data-disabled]': {
cursor: 'not-allowed',
},
},
}); });
export const nodeStyle = style({ export const nodeStyle = style({
@@ -58,5 +74,8 @@ export const nodeStyle = style({
'&[data-active="true"]': { '&[data-active="true"]': {
backgroundColor: cssVarV2('icon/primary'), backgroundColor: cssVarV2('icon/primary'),
}, },
'&[data-disabled="true"]': {
cursor: 'not-allowed',
},
}, },
}); });
@@ -71,6 +71,7 @@ export const Slider = ({
thumbStyle, thumbStyle,
noteStyle, noteStyle,
thumbSize = 14, thumbSize = 14,
disabled,
...props ...props
}: SliderProps) => { }: SliderProps) => {
const sliderRef = useRef<HTMLDivElement>(null); const sliderRef = useRef<HTMLDivElement>(null);
@@ -93,6 +94,7 @@ export const Slider = ({
style={rootStyle} style={rootStyle}
className={styles.root} className={styles.root}
{...props} {...props}
disabled={disabled}
> >
<Sliders.Track className={styles.trackStyle} ref={sliderRef}> <Sliders.Track className={styles.trackStyle} ref={sliderRef}>
<div className={styles.fakeTrackStyle} style={trackStyle}> <div className={styles.fakeTrackStyle} style={trackStyle}>
@@ -108,6 +110,7 @@ export const Slider = ({
key={index} key={index}
className={styles.nodeStyle} className={styles.nodeStyle}
data-active={value && value[0] >= nodeValue} data-active={value && value[0] >= nodeValue}
data-disabled={disabled}
style={{ style={{
left: calcStepMarkOffset( left: calcStepMarkOffset(
index, index,
@@ -256,6 +256,7 @@ export const NoteSettings = () => {
max={12} max={12}
step={2} step={2}
nodes={[2, 4, 6, 8, 10, 12]} nodes={[2, 4, 6, 8, 10, 12]}
disabled={borderStyle === StrokeStyle.None}
/> />
</SettingRow> </SettingRow>
</> </>
@@ -494,6 +494,7 @@ export const ShapeSettings = () => {
max={12} max={12}
step={2} step={2}
nodes={[2, 4, 6, 8, 10, 12]} nodes={[2, 4, 6, 8, 10, 12]}
disabled={borderStyle === StrokeStyle.None}
/> />
</SettingRow> </SettingRow>
<SettingRow <SettingRow