Commit c7f631b9 authored by chenshouchao's avatar chenshouchao

feat: tab切换按钮样式修改

parent de0ea244
...@@ -33,3 +33,11 @@ ...@@ -33,3 +33,11 @@
background-color: #fff; background-color: #fff;
box-shadow: 2px 4px 12px 0px rgba(0, 27, 63, 0.06); box-shadow: 2px 4px 12px 0px rgba(0, 27, 63, 0.06);
} }
.border {
width: 1px;
height: 16px;
background-color: rgba(209, 214, 222, 1);
}
.borderHidden {
visibility: hidden;
}
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
*/ */
// 按钮样式的单选组 // 按钮样式的单选组
import classnames from "classnames"; import classnames from "classnames";
import { useMemo } from "react";
import style from "./index.module.css"; import style from "./index.module.css";
type radioOption = { type radioOption = {
...@@ -27,21 +28,43 @@ const RadioGroupOfButtonStyle = (props: IRadioGroupOfButtonStyleProps) => { ...@@ -27,21 +28,43 @@ const RadioGroupOfButtonStyle = (props: IRadioGroupOfButtonStyleProps) => {
const { radioOptions, value, handleRadio, RadiosBoxStyle, radioStyle } = const { radioOptions, value, handleRadio, RadiosBoxStyle, radioStyle } =
props; props;
const activeIndex: any = useMemo(() => {
let res = 0;
radioOptions.forEach((item, index) => {
if (item.value === value) {
res = index;
}
});
return res;
}, [value, radioOptions]);
return ( return (
<div className={style.RadiosBox} style={RadiosBoxStyle}> <div className={style.RadiosBox} style={RadiosBoxStyle}>
{radioOptions.map((options) => { {radioOptions.map((options, index) => {
return ( return (
<div <>
key={options.value} <div
className={classnames({ key={options.value}
[style.radio]: true, className={classnames({
[style.radioActive]: value === options.value, [style.radio]: true,
})} [style.radioActive]: value === options.value,
onClick={() => handleRadio(options.value)} })}
style={radioStyle} onClick={() => handleRadio(options.value)}
> style={radioStyle}
{options.label} >
</div> {options.label}
</div>
<div
className={classnames({
[style.border]: true,
[style.borderHidden]: !(
index !== radioOptions.length - 1 &&
index !== activeIndex &&
index !== activeIndex - 1
),
})}
></div>
</>
); );
})} })}
</div> </div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment