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

653 654 collapsible header icon keyword #676

Merged
merged 13 commits into from
Jul 30, 2018

Conversation

afercia
Copy link
Contributor

@afercia afercia commented Jul 30, 2018

Summary

This PR can be summarized in the following changelog entry:

  • Adds a subtitle to the collapsible header component

Relevant technical choices:

  • there was the need to make changes to the Collapsible component, consequently the ContentAnalysis needed some changes too
  • the new sub title is passed via the subTitle prop
  • removes AnalysisCollapsible (this should go in the changelog) and use Collapsible directly: AnalysisCollapsible was duplicating 95% of the code from Collapsible
  • adds new props to control the SVG icons, including their ViewBox: this is necessary because some icons have been coded with a different ViewBox size, thus affecting the way they're rendered
  • makes it possible to control the left and right icons independently
  • refactors ContentAnalysis and uses a renderCollapsible() helper function to simplify code
  • various CSS adjustments

Ideally, the Collapsible header component should be as style-agnostic as possible. For the header itself, it's difficult to style it independently other than passing props. Instead, the content of the collapsible should be styled independently using a specific styled component.

Partially fixes also #671 which will need some adjustments in the plugin. As requested, the left and right paddings should be set on the component itself. This means the StyledSection used in the plugin should be adjusted consequently. Screenshot of the analysis in the plugin (notice the left and right paddings to reset):

screen shot 2018-07-29 at 17 21 39

Test instructions

  • check the standalone app (yarn start and go to localhost:3333) and then go in the "Collapsibles" tab
  • verify all the collapsible examples there work as expected
  • note: in this page I've added a few styles to emulate the WordPress font metrics
  • note about the focus style: difficult because there's the need to override some styles that come from the button; I've made it in a way that there's also a subtile feedback when clicking the collapsible
  • note about the arrow icons on the right: difficult to align them vertically when there's a subtitle, ideally they should be shifted a few pixels to the bottom
  • go in the Content Analysis tab
  • verify everything works correctly
  • the Content Analysis collapsibles already implement some of the CSS adjustments requested in Styling improvements for the Analysis results.  #671

Fixes #653
Fixes #654

Copy link
Contributor

@abotteram abotteram left a comment

Choose a reason for hiding this comment

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

I mainly have some quarrels with a few decisions that have been made, that increase code complexity. Please address these concerns.

const { children: text, prefixIcon, prefixIconColor, suffixIcon, suffixIconColor } = props;

const newProps = omit( props, [ "prefixIcon", "prefixIconColor", "suffixIcon", "suffixIconColor" ] );
const {
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think we want to pass all these props to the button?
I suggest using object destructuring.

const {
    extractedProp1,
    extractedProp2,
    ...buttonProps
} = props;

Copy link
Contributor

Choose a reason for hiding this comment

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

Also, what a godawful amount of props. Consider grouping prefix and suffix props, so you get props.suffix.icon, props.suffix.iconColor, and so on. I think this improved readability overall.


const newProps = omit( props, [ "prefixIcon", "prefixIconColor", "suffixIcon", "suffixIconColor" ] );
const {
children: text,
Copy link
Contributor

Choose a reason for hiding this comment

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

You rename the children prop explicitely to text, but the propTypes of the component suggest it can also be a element or multiple elements.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

No I haven't touched this part, it was already children: text

@@ -22,13 +22,14 @@ $palette_blue_dark: #084a67; // Safe to use with $palette_white – $pa
$palette_green: #77b227; // Safe to use with $palette_black.
$palette_green_light: #7ad03a; // Safe to use with $palette_black.
$palette_green_medium_light: #64a60a; // Safe to use with $palette_black or $palette_white bold > 18.5px.
$palette_green_medium: #008a00; // Safe to use with $palette_white and $palette_black.
$palette_green_medium: #008a00; // Safe to use with $palette_white and $palette_black. Also used for the smiley score icon.
Copy link
Contributor

Choose a reason for hiding this comment

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

Shouldn't we update the color_ok instead?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

color_good, color_ok: yes we can update them but worth noting they're used also in other places, for example in the content analysis and for the progress bar. If we want to update there too, that's fine I guess.

const StyledIconsButton = styled( IconsButton )`
width: 100%;
background-color: ${ colors.$color_white };
padding: 15px;
padding: ${ props => props.headingPadding };
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we should refrain from creating specific props for styling, can't we use a styled-components way to make sure the StyledIconsButton has the correct padding for the components that need different paddings.

prefixIconColor,
suffixIcon,
suffixIconColor,
prefixIconViewBox,
Copy link
Contributor

Choose a reason for hiding this comment

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

This shouldn't exist, can't we update the SVG icon to have a 1720x1720 viewbox as well? All these iconViewbox props are really cluttering the code. If it's not possible to change the viewbox of the icon, we should update the viewBox of the icons that require a different view box in the SvgIcon component.

@afercia
Copy link
Contributor Author

afercia commented Jul 30, 2018

Addressed the main CR points except the color names, which I'd prefer to keep as they're for now. We can revisit when we're sure these colors should be updated globally.

@afercia
Copy link
Contributor Author

afercia commented Jul 30, 2018

Note: as soon as this is merged, we should move #671 to the queue to adjust styling in the meta box.

prefixIconCollapsed: PropTypes.string,
prefixIconColor: PropTypes.string,
prefixIconSize: PropTypes.string,
prefixIcon: PropTypes.shape( {
Copy link
Contributor

Choose a reason for hiding this comment

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

Perhaps declare the shape seperately, and reuse this declaration wherever it's used?

Done in snippetEditorFields's descriptionLengthProgress, for instance.

Not important enough that it has to be addressed now though.

@boblinthorst
Copy link
Contributor

CR: ok 👍

@abotteram
Copy link
Contributor

Acceptance 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create a collapsible header with icon Create a collapsible header with keyword and icon
3 participants