<summary class="Summary Summary--icon icon _arrow _after" style="">
<h1 class=" " style="">
What does Sprout Do?
</h1>
</summary>
<summary
{{#if open}}open{{/if}}
class="Summary {{modifier}}"
style="{{style}}"
>
{{#if children}}
{{> @children }}
{{else}}
{{{text}}}
{{/if}}
</summary>
{
"style": null,
"text": null,
"children": [
{
"component": "heading",
"context": {
"level": 1,
"text": "What does Sprout Do?"
}
}
],
"modifier": "Summary--icon icon _arrow _after"
}
import React from 'react';
import PropTypes from 'prop-types';
import cx from 'classnames';
import {render} from '../../../helpers/render';
const Summary = props => {
if (props.children) {
return (
<summary
id={props.id}
className={cx(['Summary Summary--link', props.modifier])}
style={props.style}
>
{render(props.children)}
</summary>
);
} else if (props.text) {
return (
<summary id={props.id} className={cx(['Summary', props.modifier])} style={props.style}>
{props.text}
</summary>
);
}
};
Summary.propTypes = {
id: PropTypes.string,
modifier: PropTypes.string,
text: PropTypes.string,
style: PropTypes.string,
children: PropTypes.element
};
export default Summary;
.Summary {
cursor: pointer;
}
.Summary::-webkit-details-marker {
display: none;
}
//basically just turns it green
.Summary--link {
padding: 0;
margin: Space(400) 0;
color: theme-color(link, dark);
outline: none;
}
.Summary--link:focus > *,
.Summary--link:hover > * {
text-decoration: underline;
}
.Summary--icon {
position: relative;
display: block;
padding-right: Space(600);
}
.Summary--icon::after {
position: absolute;
top: 0;
right: 0;
padding: .125em;
transform: rotate(90deg);
}
section[expanded] .Summary--icon::after,
.Details[open] .Summary--icon::after {
transform: rotate(-90deg);
}
The Summary is used as a child of the Details
component.
Summary is used as the control for the Details component. When the Details component is closed only things in the Summary element are visisble.
Details
component, as a container. For example:<details class="Details">
<summary class="Summary">
<h3>What's up with peanuts on airplanes?</h3>
</summary>
<p>They are expensive and you know you don't deserve them</p>
</details>
If you don’t like the default focus ring on the Summary, that’s totally cool. There is a Summary
variant called the Summary--link
, that you can use instead that pulls in most styling from the buttons. Just please, don’t remove the focus state all together.