-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
119 additions
and
7 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
src/utils/components/ExpandSectionWithSwitch/ExpandSectionWithSwitch.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
.expand-section-with-switch { | ||
&__contents { | ||
padding-left: var(--pf-global--spacer--lg); | ||
} | ||
|
||
&__help-text-popover { | ||
.pf-c-popover__content { | ||
width: 400px; | ||
} | ||
} | ||
|
||
// Firefox | ||
@-moz-document url-prefix() { | ||
&__help-icon, | ||
.pf-c-switch { | ||
vertical-align: -moz-middle-with-baseline !important; | ||
} | ||
} | ||
|
||
// Chrome | ||
@media screen and (-webkit-min-device-pixel-ratio: 0) and (min-resolution: 0.001dpcm) { | ||
&__help-icon, | ||
.pf-c-switch { | ||
vertical-align: -webkit-baseline-middle !important; | ||
} | ||
} | ||
|
||
&__help-icon { | ||
color: var(--pf-global--Color--100); | ||
margin-left: calc(-1 * var(--pf-global--spacer--sm)); | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
src/utils/components/ExpandSectionWithSwitch/ExpandSectionWithSwitch.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
import React, { FC, FormEvent, ReactNode } from 'react'; | ||
|
||
import HelpTextIcon from '@kubevirt-utils/components/HelpTextIcon/HelpTextIcon'; | ||
import { PopoverPosition, Split, SplitItem, Switch } from '@patternfly/react-core'; | ||
|
||
import ExpandSection from '../../../views/clusteroverview/SettingsTab/ExpandSection/ExpandSection'; | ||
|
||
import './ExpandSectionWithSwitch.scss'; | ||
|
||
type ExpandSectionWithSwitchProps = { | ||
children: ReactNode; | ||
helpTextIconContent?: ReactNode; | ||
isDisabled?: boolean; | ||
switchIsOn: boolean; | ||
toggleContent?: ReactNode; | ||
toggleText?: string; | ||
turnOnSwitch: (checked: boolean, event: FormEvent<HTMLInputElement>) => void; | ||
}; | ||
|
||
const ExpandSectionWithSwitch: FC<ExpandSectionWithSwitchProps> = ({ | ||
children, | ||
helpTextIconContent, | ||
isDisabled, | ||
switchIsOn, | ||
toggleContent, | ||
toggleText, | ||
turnOnSwitch, | ||
}) => { | ||
return ( | ||
<Split className="expand-section-with-switch"> | ||
<SplitItem> | ||
<ExpandSection | ||
isDisabled={isDisabled} | ||
isIndented | ||
toggleContent={toggleContent} | ||
toggleText={toggleText} | ||
> | ||
<div className="expand-section-with-switch__contents">{children}</div> | ||
</ExpandSection> | ||
</SplitItem> | ||
{helpTextIconContent && ( | ||
<SplitItem isFilled> | ||
<HelpTextIcon | ||
bodyContent={helpTextIconContent} | ||
className="expand-section-with-switch__help-text-popover" | ||
helpIconClassName="expand-section-with-switch__help-icon" | ||
position={PopoverPosition.right} | ||
/> | ||
</SplitItem> | ||
)} | ||
<SplitItem> | ||
<Switch isChecked={switchIsOn} isDisabled={isDisabled} onChange={turnOnSwitch} /> | ||
</SplitItem> | ||
</Split> | ||
); | ||
}; | ||
|
||
export default ExpandSectionWithSwitch; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
src/views/clusteroverview/SettingsTab/ExpandSection/ExpandSection.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
.expand-section__disabled .pf-c-expandable-section__toggle-icon { | ||
color: var(--pf-global--disabled-color--100) !important; | ||
} |
20 changes: 17 additions & 3 deletions
20
src/views/clusteroverview/SettingsTab/ExpandSection/ExpandSection.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters