Skip to content

Commit

Permalink
Merge pull request #777 from vrk-kpa/fix/expandergroup-button-names
Browse files Browse the repository at this point in the history
[Fix] ExpanderGroup conditional props
  • Loading branch information
Riippi authored Sep 26, 2023
2 parents 4106e34 + 305f5fc commit 594fb4c
Showing 1 changed file with 22 additions and 10 deletions.
32 changes: 22 additions & 10 deletions src/core/Expander/ExpanderGroup/ExpanderGroup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,16 @@ const baseClassName = 'fi-expander-group';
const openClassName = `${baseClassName}--open`;
const expandersContainerClassName = `${baseClassName}_expanders`;
const openAllButtonClassName = `${baseClassName}_all-button`;
export interface ExpanderGroupProps extends MarginProps {

interface PartialExpanderGroupProps extends MarginProps {
/** Expanders (and optionally other ReactNodes) */
children: ReactNode;
/** 'Open all' button text */
openAllText: string;
/** 'Close all' button text */
closeAllText: string;
/** 'Open all' button text for screen readers, hides `OpenAllText` for screen readers if provided */
ariaOpenAllText?: string;
/** 'Close all' button text for screen readers, hides `CloseAllText` for screen readers if provided */
ariaCloseAllText?: string;
/** CSS class for custom styles */
className?: string;
/**
* Shows Open/Close all button
* @default true
*/
showToggleAllButton?: boolean;
/** Props passed to the Open/Close all button */
toggleAllButtonProps?: Omit<
HtmlButtonProps,
Expand All @@ -47,6 +39,26 @@ export interface ExpanderGroupProps extends MarginProps {
forwardedRef?: React.Ref<HTMLButtonElement>;
}

type ToggleAllProps =
| {
openAllText?: string;
closeAllText?: string;
showToggleAllButton?: false | never;
}
| {
/** 'Open all' button text. Required when `showToggleAllButton` is true. */
openAllText: string;
/** 'Close all' button text. Required when `showToggleAllButton` is true. */
closeAllText: string;
/**
* Shows Open/Close all button
* @default true
*/
showToggleAllButton: true;
};

export type ExpanderGroupProps = PartialExpanderGroupProps & ToggleAllProps;

interface ExpanderOpenStates {
[key: string]: boolean;
}
Expand Down

0 comments on commit 594fb4c

Please sign in to comment.