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

-- | Describes the configuration settings for the form\'s style properties.
--
-- /See:/ 'newFormStyleConfig' smart constructor.
data FormStyleConfig = FormStyleConfig'
  { -- | A reference to a design token to use to bind the form\'s style
    -- properties to an existing theme.
    FormStyleConfig -> Maybe Text
tokenReference :: Prelude.Maybe Prelude.Text,
    -- | The value of the style setting.
    FormStyleConfig -> Maybe Text
value :: Prelude.Maybe Prelude.Text
  }
  deriving (FormStyleConfig -> FormStyleConfig -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FormStyleConfig -> FormStyleConfig -> Bool
$c/= :: FormStyleConfig -> FormStyleConfig -> Bool
== :: FormStyleConfig -> FormStyleConfig -> Bool
$c== :: FormStyleConfig -> FormStyleConfig -> Bool
Prelude.Eq, ReadPrec [FormStyleConfig]
ReadPrec FormStyleConfig
Int -> ReadS FormStyleConfig
ReadS [FormStyleConfig]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FormStyleConfig]
$creadListPrec :: ReadPrec [FormStyleConfig]
readPrec :: ReadPrec FormStyleConfig
$creadPrec :: ReadPrec FormStyleConfig
readList :: ReadS [FormStyleConfig]
$creadList :: ReadS [FormStyleConfig]
readsPrec :: Int -> ReadS FormStyleConfig
$creadsPrec :: Int -> ReadS FormStyleConfig
Prelude.Read, Int -> FormStyleConfig -> ShowS
[FormStyleConfig] -> ShowS
FormStyleConfig -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FormStyleConfig] -> ShowS
$cshowList :: [FormStyleConfig] -> ShowS
show :: FormStyleConfig -> String
$cshow :: FormStyleConfig -> String
showsPrec :: Int -> FormStyleConfig -> ShowS
$cshowsPrec :: Int -> FormStyleConfig -> ShowS
Prelude.Show, forall x. Rep FormStyleConfig x -> FormStyleConfig
forall x. FormStyleConfig -> Rep FormStyleConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep FormStyleConfig x -> FormStyleConfig
$cfrom :: forall x. FormStyleConfig -> Rep FormStyleConfig x
Prelude.Generic)

-- |
-- Create a value of 'FormStyleConfig' 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:
--
-- 'tokenReference', 'formStyleConfig_tokenReference' - A reference to a design token to use to bind the form\'s style
-- properties to an existing theme.
--
-- 'value', 'formStyleConfig_value' - The value of the style setting.
newFormStyleConfig ::
  FormStyleConfig
newFormStyleConfig :: FormStyleConfig
newFormStyleConfig =
  FormStyleConfig'
    { $sel:tokenReference:FormStyleConfig' :: Maybe Text
tokenReference = forall a. Maybe a
Prelude.Nothing,
      $sel:value:FormStyleConfig' :: Maybe Text
value = forall a. Maybe a
Prelude.Nothing
    }

-- | A reference to a design token to use to bind the form\'s style
-- properties to an existing theme.
formStyleConfig_tokenReference :: Lens.Lens' FormStyleConfig (Prelude.Maybe Prelude.Text)
formStyleConfig_tokenReference :: Lens' FormStyleConfig (Maybe Text)
formStyleConfig_tokenReference = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FormStyleConfig' {Maybe Text
tokenReference :: Maybe Text
$sel:tokenReference:FormStyleConfig' :: FormStyleConfig -> Maybe Text
tokenReference} -> Maybe Text
tokenReference) (\s :: FormStyleConfig
s@FormStyleConfig' {} Maybe Text
a -> FormStyleConfig
s {$sel:tokenReference:FormStyleConfig' :: Maybe Text
tokenReference = Maybe Text
a} :: FormStyleConfig)

-- | The value of the style setting.
formStyleConfig_value :: Lens.Lens' FormStyleConfig (Prelude.Maybe Prelude.Text)
formStyleConfig_value :: Lens' FormStyleConfig (Maybe Text)
formStyleConfig_value = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FormStyleConfig' {Maybe Text
value :: Maybe Text
$sel:value:FormStyleConfig' :: FormStyleConfig -> Maybe Text
value} -> Maybe Text
value) (\s :: FormStyleConfig
s@FormStyleConfig' {} Maybe Text
a -> FormStyleConfig
s {$sel:value:FormStyleConfig' :: Maybe Text
value = Maybe Text
a} :: FormStyleConfig)

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

instance Prelude.Hashable FormStyleConfig where
  hashWithSalt :: Int -> FormStyleConfig -> Int
hashWithSalt Int
_salt FormStyleConfig' {Maybe Text
value :: Maybe Text
tokenReference :: Maybe Text
$sel:value:FormStyleConfig' :: FormStyleConfig -> Maybe Text
$sel:tokenReference:FormStyleConfig' :: FormStyleConfig -> Maybe Text
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
tokenReference
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
value

instance Prelude.NFData FormStyleConfig where
  rnf :: FormStyleConfig -> ()
rnf FormStyleConfig' {Maybe Text
value :: Maybe Text
tokenReference :: Maybe Text
$sel:value:FormStyleConfig' :: FormStyleConfig -> Maybe Text
$sel:tokenReference:FormStyleConfig' :: FormStyleConfig -> Maybe Text
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
tokenReference
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
value

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