{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.QuickSight.Types.SectionStyle
-- Copyright   : (c) 2013-2023 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.QuickSight.Types.SectionStyle where

import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import Amazonka.QuickSight.Types.Spacing

-- | The options that style a section.
--
-- /See:/ 'newSectionStyle' smart constructor.
data SectionStyle = SectionStyle'
  { -- | The height of a section.
    --
    -- Heights can only be defined for header and footer sections. The default
    -- height margin is 0.5 inches.
    SectionStyle -> Maybe Text
height :: Prelude.Maybe Prelude.Text,
    -- | The spacing between section content and its top, bottom, left, and right
    -- edges.
    --
    -- There is no padding by default.
    SectionStyle -> Maybe Spacing
padding :: Prelude.Maybe Spacing
  }
  deriving (SectionStyle -> SectionStyle -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: SectionStyle -> SectionStyle -> Bool
$c/= :: SectionStyle -> SectionStyle -> Bool
== :: SectionStyle -> SectionStyle -> Bool
$c== :: SectionStyle -> SectionStyle -> Bool
Prelude.Eq, ReadPrec [SectionStyle]
ReadPrec SectionStyle
Int -> ReadS SectionStyle
ReadS [SectionStyle]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [SectionStyle]
$creadListPrec :: ReadPrec [SectionStyle]
readPrec :: ReadPrec SectionStyle
$creadPrec :: ReadPrec SectionStyle
readList :: ReadS [SectionStyle]
$creadList :: ReadS [SectionStyle]
readsPrec :: Int -> ReadS SectionStyle
$creadsPrec :: Int -> ReadS SectionStyle
Prelude.Read, Int -> SectionStyle -> ShowS
[SectionStyle] -> ShowS
SectionStyle -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [SectionStyle] -> ShowS
$cshowList :: [SectionStyle] -> ShowS
show :: SectionStyle -> String
$cshow :: SectionStyle -> String
showsPrec :: Int -> SectionStyle -> ShowS
$cshowsPrec :: Int -> SectionStyle -> ShowS
Prelude.Show, forall x. Rep SectionStyle x -> SectionStyle
forall x. SectionStyle -> Rep SectionStyle x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep SectionStyle x -> SectionStyle
$cfrom :: forall x. SectionStyle -> Rep SectionStyle x
Prelude.Generic)

-- |
-- Create a value of 'SectionStyle' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'height', 'sectionStyle_height' - The height of a section.
--
-- Heights can only be defined for header and footer sections. The default
-- height margin is 0.5 inches.
--
-- 'padding', 'sectionStyle_padding' - The spacing between section content and its top, bottom, left, and right
-- edges.
--
-- There is no padding by default.
newSectionStyle ::
  SectionStyle
newSectionStyle :: SectionStyle
newSectionStyle =
  SectionStyle'
    { $sel:height:SectionStyle' :: Maybe Text
height = forall a. Maybe a
Prelude.Nothing,
      $sel:padding:SectionStyle' :: Maybe Spacing
padding = forall a. Maybe a
Prelude.Nothing
    }

-- | The height of a section.
--
-- Heights can only be defined for header and footer sections. The default
-- height margin is 0.5 inches.
sectionStyle_height :: Lens.Lens' SectionStyle (Prelude.Maybe Prelude.Text)
sectionStyle_height :: Lens' SectionStyle (Maybe Text)
sectionStyle_height = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SectionStyle' {Maybe Text
height :: Maybe Text
$sel:height:SectionStyle' :: SectionStyle -> Maybe Text
height} -> Maybe Text
height) (\s :: SectionStyle
s@SectionStyle' {} Maybe Text
a -> SectionStyle
s {$sel:height:SectionStyle' :: Maybe Text
height = Maybe Text
a} :: SectionStyle)

-- | The spacing between section content and its top, bottom, left, and right
-- edges.
--
-- There is no padding by default.
sectionStyle_padding :: Lens.Lens' SectionStyle (Prelude.Maybe Spacing)
sectionStyle_padding :: Lens' SectionStyle (Maybe Spacing)
sectionStyle_padding = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\SectionStyle' {Maybe Spacing
padding :: Maybe Spacing
$sel:padding:SectionStyle' :: SectionStyle -> Maybe Spacing
padding} -> Maybe Spacing
padding) (\s :: SectionStyle
s@SectionStyle' {} Maybe Spacing
a -> SectionStyle
s {$sel:padding:SectionStyle' :: Maybe Spacing
padding = Maybe Spacing
a} :: SectionStyle)

instance Data.FromJSON SectionStyle where
  parseJSON :: Value -> Parser SectionStyle
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"SectionStyle"
      ( \Object
x ->
          Maybe Text -> Maybe Spacing -> SectionStyle
SectionStyle'
            forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Height")
            forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x forall a. FromJSON a => Object -> Key -> Parser (Maybe a)
Data..:? Key
"Padding")
      )

instance Prelude.Hashable SectionStyle where
  hashWithSalt :: Int -> SectionStyle -> Int
hashWithSalt Int
_salt SectionStyle' {Maybe Text
Maybe Spacing
padding :: Maybe Spacing
height :: Maybe Text
$sel:padding:SectionStyle' :: SectionStyle -> Maybe Spacing
$sel:height:SectionStyle' :: SectionStyle -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
height
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Spacing
padding

instance Prelude.NFData SectionStyle where
  rnf :: SectionStyle -> ()
rnf SectionStyle' {Maybe Text
Maybe Spacing
padding :: Maybe Spacing
height :: Maybe Text
$sel:padding:SectionStyle' :: SectionStyle -> Maybe Spacing
$sel:height:SectionStyle' :: SectionStyle -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
height
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Spacing
padding

instance Data.ToJSON SectionStyle where
  toJSON :: SectionStyle -> Value
toJSON SectionStyle' {Maybe Text
Maybe Spacing
padding :: Maybe Spacing
height :: Maybe Text
$sel:padding:SectionStyle' :: SectionStyle -> Maybe Spacing
$sel:height:SectionStyle' :: SectionStyle -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Height" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
height,
            (Key
"Padding" forall kv v. (KeyValue kv, ToJSON v) => Key -> v -> kv
Data..=) forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Spacing
padding
          ]
      )