style: example code title

This commit is contained in:
jialin
2025-11-20 12:46:06 +08:00
parent de882dc62e
commit 9b63c1a515
3 changed files with 17 additions and 1 deletions
+13 -1
View File
@@ -12,6 +12,7 @@ interface ThemeType {
interface SegmentLineProps extends SegmentedProps {
height?: number;
theme?: 'dark' | 'light';
showTitle?: boolean;
}
const darkTheme: ThemeType = {
@@ -30,7 +31,10 @@ const lightTheme: ThemeType = {
fontWeight: 500
};
const SegmentedQwrapper = styled.div<{ $height: number; $theme: ThemeType }>`
const SegmentedQwrapper = styled.div<{
$height: number;
$theme: ThemeType;
}>`
.ant-segmented.segment-line {
padding: 0;
background-color: transparent;
@@ -76,6 +80,7 @@ const SegmentedQwrapper = styled.div<{ $height: number; $theme: ThemeType }>`
opacity: 1;
}
}
.ant-segmented-item-selected {
background-color: transparent;
box-shadow: none;
@@ -86,6 +91,11 @@ const SegmentedQwrapper = styled.div<{ $height: number; $theme: ThemeType }>`
}
}
}
&.with-title .ant-segmented.segment-line {
.ant-segmented-item.ant-segmented-item-selected::after {
display: none;
}
}
`;
const SegmentLine: React.FC<SegmentLineProps> = (props) => {
@@ -95,11 +105,13 @@ const SegmentLine: React.FC<SegmentLineProps> = (props) => {
options = [],
className = 'segment-line',
theme = 'dark',
showTitle = false,
...rest
} = props;
return (
<SegmentedQwrapper
className={showTitle ? 'with-title' : ''}
$height={height}
$theme={theme === 'dark' ? darkTheme : lightTheme}
>
@@ -11,6 +11,7 @@ interface ViewerProps {
options?: Global.BaseOption<string>[];
defaultValue?: string;
headerHeight?: number;
showTitle?: boolean;
height?: number;
lang?: string;
onChange?: (value: string | number) => void;
@@ -33,6 +34,7 @@ const CommandViewer: React.FC<ViewerProps> = (props) => {
options = [],
headerHeight = 40,
height = 380,
showTitle = false,
lang,
onChange
} = props || {};
@@ -54,6 +56,7 @@ const CommandViewer: React.FC<ViewerProps> = (props) => {
value={value}
size="small"
options={options}
showTitle={showTitle}
onChange={handlOnChange}
></SegmentLine>
@@ -123,6 +123,7 @@ const useGenericProxy = () => {
const GenericProxyCommandCode = (
<CommandViewer
showTitle={true}
code={modalStatus.codeValue}
copyText={modalStatus.codeValue}
options={langOptions}