{-# 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.AmplifyUiBuilder.Types.FormStyle
-- 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.AmplifyUiBuilder.Types.FormStyle where

import Amazonka.AmplifyUiBuilder.Types.FormStyleConfig
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

-- | Describes the configuration for the form\'s style.
--
-- /See:/ 'newFormStyle' smart constructor.
data FormStyle = FormStyle'
  { -- | The spacing for the horizontal gap.
    FormStyle -> Maybe FormStyleConfig
horizontalGap :: Prelude.Maybe FormStyleConfig,
    -- | The size of the outer padding for the form.
    FormStyle -> Maybe FormStyleConfig
outerPadding :: Prelude.Maybe FormStyleConfig,
    -- | The spacing for the vertical gap.
    FormStyle -> Maybe FormStyleConfig
verticalGap :: Prelude.Maybe FormStyleConfig
  }
  deriving (FormStyle -> FormStyle -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FormStyle -> FormStyle -> Bool
$c/= :: FormStyle -> FormStyle -> Bool
== :: FormStyle -> FormStyle -> Bool
$c== :: FormStyle -> FormStyle -> Bool
Prelude.Eq, ReadPrec [FormStyle]
ReadPrec FormStyle
Int -> ReadS FormStyle
ReadS [FormStyle]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FormStyle]
$creadListPrec :: ReadPrec [FormStyle]
readPrec :: ReadPrec FormStyle
$creadPrec :: ReadPrec FormStyle
readList :: ReadS [FormStyle]
$creadList :: ReadS [FormStyle]
readsPrec :: Int -> ReadS FormStyle
$creadsPrec :: Int -> ReadS FormStyle
Prelude.Read, Int -> FormStyle -> ShowS
[FormStyle] -> ShowS
FormStyle -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FormStyle] -> ShowS
$cshowList :: [FormStyle] -> ShowS
show :: FormStyle -> String
$cshow :: FormStyle -> String
showsPrec :: Int -> FormStyle -> ShowS
$cshowsPrec :: Int -> FormStyle -> ShowS
Prelude.Show, forall x. Rep FormStyle x -> FormStyle
forall x. FormStyle -> Rep FormStyle x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep FormStyle x -> FormStyle
$cfrom :: forall x. FormStyle -> Rep FormStyle x
Prelude.Generic)

-- |
-- Create a value of 'FormStyle' 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:
--
-- 'horizontalGap', 'formStyle_horizontalGap' - The spacing for the horizontal gap.
--
-- 'outerPadding', 'formStyle_outerPadding' - The size of the outer padding for the form.
--
-- 'verticalGap', 'formStyle_verticalGap' - The spacing for the vertical gap.
newFormStyle ::
  FormStyle
newFormStyle :: FormStyle
newFormStyle =
  FormStyle'
    { $sel:horizontalGap:FormStyle' :: Maybe FormStyleConfig
horizontalGap = forall a. Maybe a
Prelude.Nothing,
      $sel:outerPadding:FormStyle' :: Maybe FormStyleConfig
outerPadding = forall a. Maybe a
Prelude.Nothing,
      $sel:verticalGap:FormStyle' :: Maybe FormStyleConfig
verticalGap = forall a. Maybe a
Prelude.Nothing
    }

-- | The spacing for the horizontal gap.
formStyle_horizontalGap :: Lens.Lens' FormStyle (Prelude.Maybe FormStyleConfig)
formStyle_horizontalGap :: Lens' FormStyle (Maybe FormStyleConfig)
formStyle_horizontalGap = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FormStyle' {Maybe FormStyleConfig
horizontalGap :: Maybe FormStyleConfig
$sel:horizontalGap:FormStyle' :: FormStyle -> Maybe FormStyleConfig
horizontalGap} -> Maybe FormStyleConfig
horizontalGap) (\s :: FormStyle
s@FormStyle' {} Maybe FormStyleConfig
a -> FormStyle
s {$sel:horizontalGap:FormStyle' :: Maybe FormStyleConfig
horizontalGap = Maybe FormStyleConfig
a} :: FormStyle)

-- | The size of the outer padding for the form.
formStyle_outerPadding :: Lens.Lens' FormStyle (Prelude.Maybe FormStyleConfig)
formStyle_outerPadding :: Lens' FormStyle (Maybe FormStyleConfig)
formStyle_outerPadding = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FormStyle' {Maybe FormStyleConfig
outerPadding :: Maybe FormStyleConfig
$sel:outerPadding:FormStyle' :: FormStyle -> Maybe FormStyleConfig
outerPadding} -> Maybe FormStyleConfig
outerPadding) (\s :: FormStyle
s@FormStyle' {} Maybe FormStyleConfig
a -> FormStyle
s {$sel:outerPadding:FormStyle' :: Maybe FormStyleConfig
outerPadding = Maybe FormStyleConfig
a} :: FormStyle)

-- | The spacing for the vertical gap.
formStyle_verticalGap :: Lens.Lens' FormStyle (Prelude.Maybe FormStyleConfig)
formStyle_verticalGap :: Lens' FormStyle (Maybe FormStyleConfig)
formStyle_verticalGap = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FormStyle' {Maybe FormStyleConfig
verticalGap :: Maybe FormStyleConfig
$sel:verticalGap:FormStyle' :: FormStyle -> Maybe FormStyleConfig
verticalGap} -> Maybe FormStyleConfig
verticalGap) (\s :: FormStyle
s@FormStyle' {} Maybe FormStyleConfig
a -> FormStyle
s {$sel:verticalGap:FormStyle' :: Maybe FormStyleConfig
verticalGap = Maybe FormStyleConfig
a} :: FormStyle)

instance Data.FromJSON FormStyle where
  parseJSON :: Value -> Parser FormStyle
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"FormStyle"
      ( \Object
x ->
          Maybe FormStyleConfig
-> Maybe FormStyleConfig -> Maybe FormStyleConfig -> FormStyle
FormStyle'
            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
"horizontalGap")
            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
"outerPadding")
            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
"verticalGap")
      )

instance Prelude.Hashable FormStyle where
  hashWithSalt :: Int -> FormStyle -> Int
hashWithSalt Int
_salt FormStyle' {Maybe FormStyleConfig
verticalGap :: Maybe FormStyleConfig
outerPadding :: Maybe FormStyleConfig
horizontalGap :: Maybe FormStyleConfig
$sel:verticalGap:FormStyle' :: FormStyle -> Maybe FormStyleConfig
$sel:outerPadding:FormStyle' :: FormStyle -> Maybe FormStyleConfig
$sel:horizontalGap:FormStyle' :: FormStyle -> Maybe FormStyleConfig
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe FormStyleConfig
horizontalGap
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe FormStyleConfig
outerPadding
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe FormStyleConfig
verticalGap

instance Prelude.NFData FormStyle where
  rnf :: FormStyle -> ()
rnf FormStyle' {Maybe FormStyleConfig
verticalGap :: Maybe FormStyleConfig
outerPadding :: Maybe FormStyleConfig
horizontalGap :: Maybe FormStyleConfig
$sel:verticalGap:FormStyle' :: FormStyle -> Maybe FormStyleConfig
$sel:outerPadding:FormStyle' :: FormStyle -> Maybe FormStyleConfig
$sel:horizontalGap:FormStyle' :: FormStyle -> Maybe FormStyleConfig
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe FormStyleConfig
horizontalGap
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe FormStyleConfig
outerPadding
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe FormStyleConfig
verticalGap

instance Data.ToJSON FormStyle where
  toJSON :: FormStyle -> Value
toJSON FormStyle' {Maybe FormStyleConfig
verticalGap :: Maybe FormStyleConfig
outerPadding :: Maybe FormStyleConfig
horizontalGap :: Maybe FormStyleConfig
$sel:verticalGap:FormStyle' :: FormStyle -> Maybe FormStyleConfig
$sel:outerPadding:FormStyle' :: FormStyle -> Maybe FormStyleConfig
$sel:horizontalGap:FormStyle' :: FormStyle -> Maybe FormStyleConfig
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Key
"horizontalGap" 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 FormStyleConfig
horizontalGap,
            (Key
"outerPadding" 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 FormStyleConfig
outerPadding,
            (Key
"verticalGap" 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 FormStyleConfig
verticalGap
          ]
      )