-
Notifications
You must be signed in to change notification settings - Fork 53
fix(Accordian Indicator): Updating themeing #939
Changes from all commits
bfee520
69c97d0
a78624e
9211da6
8033e7c
1040baa
274f70e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -157,6 +157,7 @@ class Accordion extends AutoControlledComponent<ReactProps<AccordionProps>, any> | |
_.each(panels, (panel, index) => { | ||
const { content, title } = panel | ||
const active = this.isIndexActive(index) | ||
const indented = title.hasOwnProperty('icon') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this is a very specific detail and does not look like functionality that is generally applicable for any Accordion; can you achieve this on the theme side ( |
||
|
||
children.push( | ||
AccordionTitle.create(title, { | ||
|
@@ -167,7 +168,10 @@ class Accordion extends AutoControlledComponent<ReactProps<AccordionProps>, any> | |
) | ||
children.push( | ||
AccordionContent.create(content, { | ||
defaultProps: { active }, | ||
defaultProps: { | ||
active, | ||
indented, | ||
}, | ||
render: renderPanelContent, | ||
}), | ||
) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,6 +20,9 @@ export interface AccordionContentProps | |
/** Whether or not the content is visible. */ | ||
active?: boolean | ||
|
||
/** Whether or not content should be indented */ | ||
indented?: boolean | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you please:
We need a strong argument with examples (preferably from the larger web community) that a prop is describing a component before we can accept it as a valid prop There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So I definitely don't like the feeling of having this prop. It is an artifact of the way Accordion renders the Title and Content of each panel separately within the Accordion. The purpose of Indented is to react to the presence of the Icon (that is a question in itself) and indent the accordion content accordingly. |
||
|
||
/** | ||
* Called on click. | ||
* | ||
|
@@ -43,6 +46,7 @@ class AccordionContent extends UIComponent<ReactProps<AccordionContentProps>, an | |
...commonPropTypes.createCommon(), | ||
active: PropTypes.bool, | ||
onClick: PropTypes.func, | ||
indented: PropTypes.bool, | ||
} | ||
|
||
renderComponent({ ElementType, classes, unhandledProps }) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,7 @@ import { | |
rtlTextContainer, | ||
} from '../../lib' | ||
import { ReactProps, ComponentEventHandler, ShorthandValue } from '../../types' | ||
import Icon from '../Icon/Icon' | ||
import Indicator from '../Indicator/Indicator' | ||
import Layout from '../Layout/Layout' | ||
|
||
|
@@ -37,6 +38,9 @@ export interface AccordionTitleProps | |
|
||
/** Shorthand for the active indicator. */ | ||
indicator?: ShorthandValue | ||
|
||
/** Shorthand for the icon. */ | ||
icon?: ShorthandValue | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @kuzhelov do we have any agreement on the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should not introduce a new slot there, There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The Icon is intended to be separate form the indicator. But maybe Adding Icon in general is not right. Maybe making Accordion usable for the control messages was the wrong direction? |
||
} | ||
|
||
/** | ||
|
@@ -55,24 +59,31 @@ class AccordionTitle extends UIComponent<ReactProps<AccordionTitleProps>, any> { | |
index: PropTypes.oneOfType([PropTypes.string, PropTypes.number]), | ||
onClick: PropTypes.func, | ||
indicator: customPropTypes.itemShorthand, | ||
icon: customPropTypes.itemShorthand, | ||
} | ||
|
||
handleClick = e => { | ||
_.invoke(this.props, 'onClick', e, this.props) | ||
} | ||
|
||
renderComponent({ ElementType, classes, unhandledProps, styles }) { | ||
const { children, content, indicator, active } = this.props | ||
const { children, content, icon, indicator, active } = this.props | ||
const indicatorWithDefaults = indicator === undefined ? {} : indicator | ||
const indicatorIcon = icon === undefined ? {} : icon | ||
|
||
const contentElement = ( | ||
<Layout | ||
start={Indicator.create(indicatorWithDefaults, { | ||
defaultProps: { | ||
direction: active ? 'bottom' : 'end', | ||
styles: styles.indicator, | ||
}, | ||
})} | ||
start={ | ||
<Layout | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. please do not use |
||
start={Indicator.create(indicatorWithDefaults, { | ||
defaultProps: { | ||
direction: active ? 'bottom' : 'end', | ||
styles: styles.indicator, | ||
}, | ||
})} | ||
main={indicatorIcon ? Icon.create(indicatorIcon) : null} | ||
/> | ||
} | ||
main={rtlTextContainer.createFor({ element: content })} | ||
/> | ||
) | ||
|
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please do not change example styles to match specific theme;
I'd suggest reverting these changes in this file and create a prototype (use #931 as a reference on how to create one)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about creating a new example under Usages? If it's an example, then screenshot tests will capture any regressions - I don't think prototypes have that same benefit
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I also don't think it's a good practice.
The point of the Examples section is to provide simple and generic code snippets to show clients how to use our components. It is not intended to show them a very particular set of customizations to achieve a very particular flavor for that component.
They don't but these screenshots tests are not meant to capture regressions for styles inserted in the examples themselves, but for the whole theme (so for styles that are introduced in the top level theme object for the theme that is currently displayed in the docs site). Hope this makes sense.