File size: 872 Bytes
1c8e50c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import React from 'react';

const PageSection = ({ title, description, action, children }) => (
  <section className="card" aria-labelledby={title ? `${title.replace(/\s+/g, '-').toLowerCase()}-heading` : undefined}>
    {(title || description || action) && (
      <header className="section-heading-group" style={{ marginBottom: '1.5rem', display: 'grid', gap: '0.75rem' }}>
        <div>
          {title && (
            <h2
              id={`${title.replace(/\s+/g, '-').toLowerCase()}-heading`}
              className="section-heading"
              style={{ marginBottom: description ? '0.5rem' : 0 }}
            >
              {title}
            </h2>
          )}
          {description && <p className="section-subheading">{description}</p>}
        </div>
        {action}
      </header>
    )}
    {children}
  </section>
);

export default PageSection;