FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

fix(accordion): adds prop to heading level of parent component by jenny-s51 · Pull Request #2273 · patternfly/patternfly-react · GitHub

fix(accordion): adds prop to heading level of parent component - #2273

Closed
jenny-s51 wants to merge 12 commits into
patternfly:masterfrom
jenny-s51:iss1881_copy
Closed

fix(accordion): adds prop to heading level of parent component#2273
jenny-s51 wants to merge 12 commits into
patternfly:masterfrom
jenny-s51:iss1881_copy

Conversation

jenny-s51 commented Jun 14, 2019
edited
Loading

Copy link
Copy Markdown
Contributor

What: closes #1881

import { AngleRightIcon } from '@patternfly/react-icons';
import styles from '@patternfly/react-styles/css/components/Accordion/accordion';
import { AccordionContext } from './Accordion';
import { ApplicationLauncherPosition } from '../ApplicationLauncher/applicationLauncherConstants';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

this should not be here

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Ah, the price of auto-import-on-tab-completion.

<button
id={id}
className={css(styles.accordionToggle, isExpanded && styles.modifiers.expanded, className)}
{...props}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

would you mind making {...props} the last attribute

);
export const AccordionContext = React.createContext({ headingLevel: 'h3' });

export const HeadingLevelTypes = {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Why is this needed? I think we can just pass headingLevel through into context

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Do you mean I should just set AccordionContext = React.createContext(); ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I think this const is good to have for the consumer (it'll be the same as enums we export elsewhere, when this is ported over to the typescript version) but Joachim is saying that on line 18 we don't need const HeadingLevel = HeadingLevelTypes[headingLevel];, we can just pass lowercase-h headingLevel into the provider. The HeadingLevelTypes object doesn't really do anything for us internally, it's just for the consumer

Copy link
Copy Markdown
Collaborator

PatternFly-React preview: https://2273-pr-patternfly-react-patternfly.surge.sh

codecov-io commented Jun 17, 2019
edited
Loading

Copy link
Copy Markdown

Codecov Report

❗ No coverage uploaded for pull request base (master@e7ef49d). Click here to learn what that means.
The diff coverage is 100%.

@@            Coverage Diff            @@
##             master    #2273   +/-   ##
=========================================
  Coverage          ?   80.63%           
=========================================
  Files             ?      666           
  Lines             ?     8431           
  Branches          ?      711           
=========================================
  Hits              ?     6798           
  Misses            ?     1280           
  Partials          ?      353
Flag Coverage Δ
#patternfly3 85.23% <ø> (?)
#patternfly4 76.22% <100%> (?)
#patternflymisc 95.79% <ø> (?)
Impacted Files Coverage Δ
...t-core/src/components/Accordion/AccordionToggle.js 100% <100%> (ø)
...4/react-core/src/components/Accordion/Accordion.js 100% <100%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e7ef49d...c5aced0. Read the comment docs.

jenny-s51 and others added 2 commits June 17, 2019 14:28
…nfly#2147)

* Convert context selector to typescript

* Fix linting and build error

* Add demo and integration tests

* Add typescript badge to docs

* Made event argument optional
jenny-s51 requested a review from jschuler June 17, 2019 18:30

mturley left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Looking really good! I think we probably also want to add a snapshot test to https://github.com/patternfly/patternfly-react/blob/master/packages/patternfly-4/react-core/src/components/Accordion/Accordion.test.tsx that renders an accordion with a non-default headingLevel prop, just to assert that it actually renders the alternate heading tag in the snapshot.

h6 = 'h6'
}

// declare global {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

We can fully remove this now.


export const AccordionContext = React.createContext('h3');

export enum HeadingLevel {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Judging by our discussion in Slack, since the user already has TitleLevel we don't need this enum after all.

}: AccordionProps) => (
<dl className={css(styles.accordion, className)} aria-label={ariaLabel} {...props}>
{children}
<AccordionContext.Provider value={ headingLevel }>{children}</AccordionContext.Provider>

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I guess we still have eslint turned off, but I think when it's eventually turned back on it'll complain about the spacing here, I think you want to remove the spaces around headingLevel here (value={headingLevel})

jenny-s51 Jun 17, 2019
edited
Loading

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Thank you! I resolved the changes you mentioned above in this commit here

import * as React from 'react';
import { css } from '@patternfly/react-styles';
import styles from '@patternfly/react-styles/css/components/Accordion/accordion';
import {TitleLevel} from '../Title';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

You don't need to import this here, it's not being used in the component itself.

</button>
</h3>
<AccordionContext.Consumer>
{(TitleLevel: any) => (

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

Sorry to be confusing here, but I think this is actually better off staying as HeadingLevel like it was before, since that's the name of the prop that is passed into Accordion, and it'll be more clear where this came from. TitleLevel is just the object a consumer can use to get predefined values for what they should pass into the headingLevel prop. I don't think you need any reference to TitleLevel at all in these components, you could use it maybe just in a unit test (e.g.<Accordion headingLevel={TitleLevel.h2}> ...)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

But even for the unit test, since you'd have to import it from over in the Title folder, I don't think you necessarily need to use TitleLevel in this PR at all.

>
<TimesIcon
color="currentColor"
noVerticalAlign={false}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

I'm not sure why these unrelated snapshots are updating, @jschuler @redallen do you know what the deal is here?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

react-icons was recently updated to include this prop, pull down latest from master and rerun yarn install

TheRealJon and others added 8 commits June 17, 2019 16:38
…by default. (patternfly#2270)

Pie chart tooltips display the x value of each slice as a tooltip label by default. Because we are
doing our own calculations on the data and manually setting the x-value, this can lead to tooltips
displaying array index values. Also, fix a bug where ChartDonutThreshold accessors were being used
for child ChartDonutUtilization data prop.

jenny-s51 commented Jun 18, 2019
edited
Loading

Copy link
Copy Markdown
Contributor Author

final PR is #2290

jenny-s51 deleted the iss1881_copy branch July 3, 2019 19:12
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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.

Accordion - prop for heading level

7 participants


Back | FazBrowse Home | New Git URL