Skip to content

Commit e6fdc9a

Browse files
committed
updates to add prop and remove util class
1 parent a0e636c commit e6fdc9a

File tree

2 files changed

+6
-21
lines changed

2 files changed

+6
-21
lines changed

packages/react-core/src/components/Accordion/Accordion.tsx

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { css } from '@patternfly/react-styles';
22
import styles from '@patternfly/react-styles/css/components/Accordion/accordion';
3-
import { hasGlassTheme } from '../../helpers/util';
43
import { AccordionContext } from './AccordionContext';
54

65
export interface AccordionProps extends React.HTMLProps<HTMLDListElement> {
@@ -16,11 +15,9 @@ export interface AccordionProps extends React.HTMLProps<HTMLDListElement> {
1615
asDefinitionList?: boolean;
1716
/** Flag to indicate the accordion had a border */
1817
isBordered?: boolean;
19-
/**
20-
* Flag to indicate if the accordion uses plain styling. Only applicable when the PatternFly glass
21-
* theme is active (e.g. `pf-v6-theme-glass` on the document root); when the glass theme is not
22-
* active, this prop has no effect.
23-
*/
18+
/** Flag to prevent the accordion from automatically applying plain styling when glass theme is enabled. */
19+
isNoPlainOnGlass?: boolean;
20+
/** Flag to add plain styling to the accordion. */
2421
isPlain?: boolean;
2522
/** Display size variant. */
2623
displaySize?: 'default' | 'lg';
@@ -35,6 +32,7 @@ export const Accordion: React.FunctionComponent<AccordionProps> = ({
3532
headingLevel = 'h3',
3633
asDefinitionList = true,
3734
isBordered = false,
35+
isNoPlainOnGlass = false,
3836
isPlain = false,
3937
displaySize = 'default',
4038
togglePosition = 'end',
@@ -46,7 +44,8 @@ export const Accordion: React.FunctionComponent<AccordionProps> = ({
4644
className={css(
4745
styles.accordion,
4846
isBordered && styles.modifiers.bordered,
49-
!isPlain && hasGlassTheme() && styles.modifiers.noPlain,
47+
isNoPlainOnGlass && styles.modifiers.noPlain,
48+
isPlain && styles.modifiers.plain,
5049
togglePosition === 'start' && styles.modifiers.toggleStart,
5150
displaySize === 'lg' && styles.modifiers.displayLg,
5251
className

packages/react-core/src/helpers/util.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -395,20 +395,6 @@ export const toCamel = (s: string) => s.replace(/([-_][a-z])/gi, camelize);
395395
*/
396396
export const canUseDOM = !!(typeof window !== 'undefined' && window.document && window.document.createElement);
397397

398-
/**
399-
* Checks if the PatternFly glass theme is applied at the document root.
400-
* Used by components that adapt styling for glass theme (e.g. Accordion).
401-
*
402-
* @returns {boolean} - True if the glass theme class is present on the html element
403-
*/
404-
export const hasGlassTheme = (): boolean => {
405-
if (typeof document === 'undefined') {
406-
return false;
407-
}
408-
const classList = document.documentElement?.classList;
409-
return classList ? classList.contains('pf-v6-theme-glass') : false;
410-
};
411-
412398
/**
413399
* Calculate the width of the text
414400
* Example:

0 commit comments

Comments
 (0)