Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[EuiAccordion] Split up rendering into sub-components & other cleanups #7161

Merged
merged 12 commits into from
Sep 8, 2023
Merged
28 changes: 13 additions & 15 deletions src/components/accordion/accordion.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,26 @@ import React, { Component, HTMLAttributes, ReactNode } from 'react';
import classNames from 'classnames';
import { tabbable, FocusableElement } from 'tabbable';

import { CommonProps } from '../common';

import { EuiLoadingSpinner } from '../loading';
import { EuiResizeObserver } from '../observer/resize_observer';
import { EuiText } from '../text';
import { EuiI18n } from '../i18n';
import { logicalCSS } from '../../global_styling';
import {
htmlIdGenerator,
withEuiTheme,
WithEuiThemeProps,
} from '../../services';
import { CommonProps } from '../common';
import { EuiLoadingSpinner } from '../loading';
import { EuiResizeObserver } from '../observer/resize_observer';
import { EuiText } from '../text';
import { EuiI18n } from '../i18n';
import type { EuiButtonIconProps } from '../button';

import { EuiAccordionTrigger } from './accordion_trigger';
import {
euiAccordionStyles,
euiAccordionChildrenStyles,
euiAccordionChildWrapperStyles,
euiAccordionSpinnerStyles,
} from './accordion.styles';
import { logicalCSS } from '../../global_styling';

export const PADDING_SIZES = ['none', 'xs', 's', 'm', 'l', 'xl'] as const;
export type EuiAccordionPaddingSize = (typeof PADDING_SIZES)[number];
Expand Down Expand Up @@ -261,33 +261,31 @@ export class EuiAccordionClass extends Component<
render() {
const {
children,
buttonContent,
className,
id,
element: Element = 'div',
buttonElement,
buttonProps,
buttonClassName,
buttonContentClassName,
buttonContent,
arrowDisplay,
arrowProps,
Comment on lines +165 to +171
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should document the standard of "how to order imports" as a rough guideline in our How We Work wiki

Copy link
Member Author

@cee-chen cee-chen Sep 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a super interesting (and potentially controversial 😅) topic of discussion actually. Personally, I work with the mental model of "group related props together", and it makes sense to me in my brain, but I've worked with devs in the past where that just doesn't make any sense to them and they strongly strictly prefer ordering EVERYTHING (imports, props, all object keys, etc.) alphabetically, and lint for it.

I'm going to be honest, I'm... not a huge fan of alphabetical sorting (there's just too many one-offs where related props end up far apart from each other, and it kinda relies on verbose or strict naming conventions). But yeah this is basically a topic where opinions can get a little heated and it can lead to a frustrating amount of bikeshedding, so all-in-all I've kinda just gone with the laissez-faire approach of "I'll clean it up if it's in my PR and I'm already here", as opposed to pushing for stricter linting around it.

It's definitely an interesting topic to discuss as a team (if it doesn't turn out into a spaces vs tabs holy war lol) so I'll put it on our next sync to quickly chat about if we're down for it!

extraAction,
paddingSize,
borders,
initialIsOpen,
arrowDisplay,
forceState,
isLoading,
isLoadingMessage,
isDisabled,
buttonProps,
buttonElement,
arrowProps,
theme,
...rest
} = this.props;

const classes = classNames(
'euiAccordion',
{
'euiAccordion-isOpen': this.isOpen,
},
{ 'euiAccordion-isOpen': this.isOpen },
className
);

Expand Down