File size: 1,148 Bytes
b91e262
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
45
46
47
"use client";

import React, { useContext, createContext } from "react";
import { VerticalPadding, VerticalPaddingOptions } from "../VerticalPadding";
import classes from "./index.module.scss";

type BackgroundColorField = "white" | "black";

export const BackgroundColorContext =
  createContext<BackgroundColorField>("white");

export const useBackgroundColor = (): BackgroundColorField =>
  useContext(BackgroundColorContext);

type Props = {
  color?: BackgroundColorField;
  paddingTop?: VerticalPaddingOptions;
  paddingBottom?: VerticalPaddingOptions;
  className?: string;
  children?: React.ReactNode;
  id?: string;
};

export const BackgroundColor: React.FC<Props> = (props) => {
  const {
    id,
    className,
    children,
    paddingTop,
    paddingBottom,
    color = "white",
  } = props;

  return (
    <div
      id={id}
      className={[classes[color], className].filter(Boolean).join(" ")}
    >
      <BackgroundColorContext.Provider value={color}>
        <VerticalPadding top={paddingTop} bottom={paddingBottom}>
          {children}
        </VerticalPadding>
      </BackgroundColorContext.Provider>
    </div>
  );
};