question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Make heading configurable in AccodionTitleItem

See original GitHub issue

Would be nice to have the <h3> configurable in https://github.com/daviferreira/react-sanfona/blob/master/src/AccordionItemTitle/index.jsx#L16. It does not necessary suit the rest of the markup semantic in the application.

Thanks for your nice module! 😃

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

10reactions
psimyncommented, Jul 25, 2016

Just had a quick run at this, the change allows AccordionTitle title prop to be a string or a component. It keeps the default onClick so the Accordion still works, this means if you want other elements on there (e.g. the close/arrow icons above) you need to stop the event from propagating.

Here’s an example of using it:

<Accordion
  allowMultiple={true}
  activeItems={2}
>
  {[1, 2, 3, 4, 5].map((item) => {
    const title = (
      <h2>
        <span>Item { item }</span>
        <span style={{float: 'right'}} onClick={(evt) => {
          alert('click')
          evt.stopPropagation() // don't trigger AccordionItemTitle onClick
        }}>x</span>
      </h2>
    )

    return (
      <AccordionItem title={title} key={item}>
        <div>
          {`Item ${ item } content`}
        </div>
      </AccordionItem>
    );
  })}
</Accordion>

I’ll try to clean up the onClick stuff a bit with this as well

1reaction
psimyncommented, Jun 7, 2016

Awesome, thanks. I’ll try to have a pass at this tonight, will depend on some other PRs though. Custom button or something in the title (I am assuming that is ‘delete’?) is an interesting idea.

In the meantime, if just for the arrows you could use some CSS

.react-sanfona-item-title {
  position: relative;
}

.react-sanfona-item-title:after {
  position: absolute;
  content: url(chevron.svg); /* can use icon font here if you'd rather */
  right: 1em;
}

.react-sanfona-item-expanded .react-sanfona-item-title:after {
  transform: rotate(180deg);
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Add a heading - Microsoft Support
Headings make text stand out and help people scan your document. The simplest way to add headings is with heading styles. Using heading...
Read more >
Improve accessibility with heading styles - Microsoft Support
Learn how to use styles for headings to make your documents easier to navigate. To add a heading style. Type the text you...
Read more >
Make HeadingBlockParser configurable · Issue #297 - GitHub
I've got a use case where I would like to use Markdig to parse user entered markdown into HTML, but only a limited...
Read more >
Creating a script expression to style headings - IBM
You can create heading styles on template elements, which corresponds the values for data ... In the Style name field, click the configuration...
Read more >
How do I separate the header in a configurable list after I ...
1. ) The heading on the checkbox and radio sections is built into the columns I created, and I need the headings ABOVE...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found