{-# 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.Spacing
-- 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.Spacing 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

-- | The configuration of spacing (often a margin or padding).
--
-- /See:/ 'newSpacing' smart constructor.
data Spacing = Spacing'
  { -- | Define the bottom spacing.
    Spacing -> Maybe Text
bottom :: Prelude.Maybe Prelude.Text,
    -- | Define the left spacing.
    Spacing -> Maybe Text
left :: Prelude.Maybe Prelude.Text,
    -- | Define the right spacing.
    Spacing -> Maybe Text
right :: Prelude.Maybe Prelude.Text,
    -- | Define the top spacing.
    Spacing -> Maybe Text
top :: Prelude.Maybe Prelude.Text
  }
  deriving (Spacing -> Spacing -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Spacing -> Spacing -> Bool
$c/= :: Spacing -> Spacing -> Bool
== :: Spacing -> Spacing -> Bool
$c== :: Spacing -> Spacing -> Bool
Prelude.Eq, ReadPrec [Spacing]
ReadPrec Spacing
Int -> ReadS Spacing
ReadS [Spacing]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Spacing]
$creadListPrec :: ReadPrec [Spacing]
readPrec :: ReadPrec Spacing
$creadPrec :: ReadPrec Spacing
readList :: ReadS [Spacing]
$creadList :: ReadS [Spacing]
readsPrec :: Int -> ReadS Spacing
$creadsPrec :: Int -> ReadS Spacing
Prelude.Read, Int -> Spacing -> ShowS
[Spacing] -> ShowS
Spacing -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Spacing] -> ShowS
$cshowList :: [Spacing] -> ShowS
show :: Spacing -> String
$cshow :: Spacing -> String
showsPrec :: Int -> Spacing -> ShowS
$cshowsPrec :: Int -> Spacing -> ShowS
Prelude.Show, forall x. Rep Spacing x -> Spacing
forall x. Spacing -> Rep Spacing x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep Spacing x -> Spacing
$cfrom :: forall x. Spacing -> Rep Spacing x
Prelude.Generic)

-- |
-- Create a value of 'Spacing' 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:
--
-- 'bottom', 'spacing_bottom' - Define the bottom spacing.
--
-- 'left', 'spacing_left' - Define the left spacing.
--
-- 'right', 'spacing_right' - Define the right spacing.
--
-- 'top', 'spacing_top' - Define the top spacing.
newSpacing ::
  Spacing
newSpacing :: Spacing
newSpacing =
  Spacing'
    { $sel:bottom:Spacing' :: Maybe Text
bottom = forall a. Maybe a
Prelude.Nothing,
      $sel:left:Spacing' :: Maybe Text
left = forall a. Maybe a
Prelude.Nothing,
      $sel:right:Spacing' :: Maybe Text
right = forall a. Maybe a
Prelude.Nothing,
      $sel:top:Spacing' :: Maybe Text
top = forall a. Maybe a
Prelude.Nothing
    }

-- | Define the bottom spacing.
spacing_bottom :: Lens.Lens' Spacing (Prelude.Maybe Prelude.Text)
spacing_bottom :: Lens' Spacing (Maybe Text)
spacing_bottom = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Spacing' {Maybe Text
bottom :: Maybe Text
$sel:bottom:Spacing' :: Spacing -> Maybe Text
bottom} -> Maybe Text
bottom) (\s :: Spacing
s@Spacing' {} Maybe Text
a -> Spacing
s {$sel:bottom:Spacing' :: Maybe Text
bottom = Maybe Text
a} :: Spacing)

-- | Define the left spacing.
spacing_left :: Lens.Lens' Spacing (Prelude.Maybe Prelude.Text)
spacing_left :: Lens' Spacing (Maybe Text)
spacing_left = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Spacing' {Maybe Text
left :: Maybe Text
$sel:left:Spacing' :: Spacing -> Maybe Text
left} -> Maybe Text
left) (\s :: Spacing
s@Spacing' {} Maybe Text
a -> Spacing
s {$sel:left:Spacing' :: Maybe Text
left = Maybe Text
a} :: Spacing)

-- | Define the right spacing.
spacing_right :: Lens.Lens' Spacing (Prelude.Maybe Prelude.Text)
spacing_right :: Lens' Spacing (Maybe Text)
spacing_right = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Spacing' {Maybe Text
right :: Maybe Text
$sel:right:Spacing' :: Spacing -> Maybe Text
right} -> Maybe Text
right) (\s :: Spacing
s@Spacing' {} Maybe Text
a -> Spacing
s {$sel:right:Spacing' :: Maybe Text
right = Maybe Text
a} :: Spacing)

-- | Define the top spacing.
spacing_top :: Lens.Lens' Spacing (Prelude.Maybe Prelude.Text)
spacing_top :: Lens' Spacing (Maybe Text)
spacing_top = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\Spacing' {Maybe Text
top :: Maybe Text
$sel:top:Spacing' :: Spacing -> Maybe Text
top} -> Maybe Text
top) (\s :: Spacing
s@Spacing' {} Maybe Text
a -> Spacing
s {$sel:top:Spacing' :: Maybe Text
top = Maybe Text
a} :: Spacing)

instance Data.FromJSON Spacing where
  parseJSON :: Value -> Parser Spacing
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"Spacing"
      ( \Object
x ->
          Maybe Text -> Maybe Text -> Maybe Text -> Maybe Text -> Spacing
Spacing'
            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
"Bottom")
            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
"Left")
            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
"Right")
            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
"Top")
      )

instance Prelude.Hashable Spacing where
  hashWithSalt :: Int -> Spacing -> Int
hashWithSalt Int
_salt Spacing' {Maybe Text
top :: Maybe Text
right :: Maybe Text
left :: Maybe Text
bottom :: Maybe Text
$sel:top:Spacing' :: Spacing -> Maybe Text
$sel:right:Spacing' :: Spacing -> Maybe Text
$sel:left:Spacing' :: Spacing -> Maybe Text
$sel:bottom:Spacing' :: Spacing -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
bottom
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
left
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
right
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
top

instance Prelude.NFData Spacing where
  rnf :: Spacing -> ()
rnf Spacing' {Maybe Text
top :: Maybe Text
right :: Maybe Text
left :: Maybe Text
bottom :: Maybe Text
$sel:top:Spacing' :: Spacing -> Maybe Text
$sel:right:Spacing' :: Spacing -> Maybe Text
$sel:left:Spacing' :: Spacing -> Maybe Text
$sel:bottom:Spacing' :: Spacing -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
bottom
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
left
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
right
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
top

instance Data.ToJSON Spacing where
  toJSON :: Spacing -> Value
toJSON Spacing' {Maybe Text
top :: Maybe Text
right :: Maybe Text
left :: Maybe Text
bottom :: Maybe Text
$sel:top:Spacing' :: Spacing -> Maybe Text
$sel:right:Spacing' :: Spacing -> Maybe Text
$sel:left:Spacing' :: Spacing -> Maybe Text
$sel:bottom:Spacing' :: Spacing -> Maybe Text
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"Bottom" 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
bottom,
            (Key
"Left" 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
left,
            (Key
"Right" 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
right,
            (Key
"Top" 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
top
          ]
      )