1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-23 07:19:41 +02:00

feat(switch): add optional switch text [EE-3625] (#7164)

* add optional switch text
This commit is contained in:
Matt Hook 2022-07-04 13:05:04 +12:00 committed by GitHub
parent 7275d23e4b
commit dd4d126934
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 0 deletions

View file

@ -18,6 +18,10 @@ export interface Props {
dataCy?: string;
disabled?: boolean;
featureId?: FeatureId;
switchValues?: {
on: string;
off: string;
};
}
export function SwitchField({
@ -30,6 +34,7 @@ export function SwitchField({
disabled,
onChange,
featureId,
switchValues,
}: Props) {
const toggleName = name ? `toggle_${name}` : '';
@ -55,6 +60,12 @@ export function SwitchField({
featureId={featureId}
dataCy={dataCy}
/>
{switchValues && checked && (
<span className="ml-2">{switchValues.on}</span>
)}
{switchValues && !checked && (
<span className="ml-2">{switchValues.off}</span>
)}
</label>
);
}