summaryrefslogtreecommitdiffhomepage
path: root/gui/src/renderer/components/SettingsHeader.tsx
blob: 47e1f47f7b081324a8a03bc459dcab6e62bea0b6 (plain)
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import * as React from 'react';
import styled from 'styled-components';

import { colors } from '../../config.json';
import { hugeText, measurements, tinyText } from './common-styles';

export const Container = styled.div({
  flex: 0,
  paddingTop: '2px',
  paddingLeft: measurements.viewMargin,
  paddingRight: measurements.viewMargin,
  paddingBottom: measurements.rowVerticalMargin,
});

export const ContentWrapper = styled.div({
  '&&:not(:first-child)': {
    paddingTop: '8px',
  },
});

export const HeaderTitle = styled.span(hugeText, {
  wordWrap: 'break-word',
  hyphens: 'auto',
});
export const HeaderSubTitle = styled.span(tinyText, {
  color: colors.white60,
});

interface ISettingsHeaderProps {
  children?: React.ReactNode;
  className?: string;
}

function SettingsHeader(props: ISettingsHeaderProps, forwardRef: React.Ref<HTMLDivElement>) {
  return (
    <Container ref={forwardRef} className={props.className}>
      {React.Children.map(props.children, (child) => {
        return React.isValidElement(child) ? <ContentWrapper>{child}</ContentWrapper> : undefined;
      })}
    </Container>
  );
}

export default React.forwardRef(SettingsHeader);