Skip to content

Commit 9433bb6

Browse files
committed
feat: add support for variants in segmented control
1 parent 4648320 commit 9433bb6

File tree

5 files changed

+14
-6
lines changed

5 files changed

+14
-6
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@devtron-labs/devtron-fe-common-lib",
3-
"version": "1.2.5-beta-1",
3+
"version": "1.2.5-beta-3",
44
"description": "Supporting common component library",
55
"type": "module",
66
"main": "dist/index.js",

src/Common/SegmentedControl/SegmentedControl.component.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
import { OptionType } from '@Common/Types'
1818
import StyledRadioGroup from '../RadioGroup/RadioGroup'
19-
import { SegmentedControlProps } from './types'
19+
import { SegmentedControlProps, SegmentedControlVariant } from './types'
2020

2121
const SegmentedControl = ({
2222
tabs,
@@ -25,9 +25,10 @@ const SegmentedControl = ({
2525
tooltips,
2626
disabled = false,
2727
rootClassName = '',
28+
variant = SegmentedControlVariant.WHITE_ON_GRAY,
2829
}: SegmentedControlProps) => (
2930
<StyledRadioGroup
30-
className={`gui-yaml-switch-window-bg ${rootClassName}`}
31+
className={`${variant} ${rootClassName}`}
3132
onChange={onChange}
3233
initialTab={initialTab}
3334
name="segmented-control"

src/Common/SegmentedControl/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
export type { SegmentedControlProps } from './types'
1+
export { type SegmentedControlProps, SegmentedControlVariant } from './types'
22
export { default as SegmentedControl } from './SegmentedControl.component'

src/Common/SegmentedControl/types.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,18 @@
1616

1717
import { OptionType } from '@Common/Types'
1818

19+
export enum SegmentedControlVariant {
20+
// NOTE: values are css class names
21+
GRAY_ON_WHITE = 'gui-yaml-switch',
22+
WHITE_ON_GRAY = 'gui-yaml-switch-window-bg',
23+
}
24+
1925
export interface SegmentedControlProps {
2026
tabs: OptionType[]
2127
initialTab: string
2228
onChange: (e: React.ChangeEvent<HTMLInputElement>) => void
2329
tooltips?: string[]
2430
disabled?: boolean
2531
rootClassName?: string
32+
variant?: SegmentedControlVariant
2633
}

0 commit comments

Comments
 (0)