{-# 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.ThemeValue
-- 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.ThemeValue where

import {-# SOURCE #-} Amazonka.AmplifyUiBuilder.Types.ThemeValues
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 of a theme\'s properties.
--
-- /See:/ 'newThemeValue' smart constructor.
data ThemeValue = ThemeValue'
  { -- | A list of key-value pairs that define the theme\'s properties.
    ThemeValue -> Maybe [ThemeValues]
children :: Prelude.Maybe [ThemeValues],
    -- | The value of a theme property.
    ThemeValue -> Maybe Text
value :: Prelude.Maybe Prelude.Text
  }
  deriving (ThemeValue -> ThemeValue -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: ThemeValue -> ThemeValue -> Bool
$c/= :: ThemeValue -> ThemeValue -> Bool
== :: ThemeValue -> ThemeValue -> Bool
$c== :: ThemeValue -> ThemeValue -> Bool
Prelude.Eq, ReadPrec [ThemeValue]
ReadPrec ThemeValue
Int -> ReadS ThemeValue
ReadS [ThemeValue]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [ThemeValue]
$creadListPrec :: ReadPrec [ThemeValue]
readPrec :: ReadPrec ThemeValue
$creadPrec :: ReadPrec ThemeValue
readList :: ReadS [ThemeValue]
$creadList :: ReadS [ThemeValue]
readsPrec :: Int -> ReadS ThemeValue
$creadsPrec :: Int -> ReadS ThemeValue
Prelude.Read, Int -> ThemeValue -> ShowS
[ThemeValue] -> ShowS
ThemeValue -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [ThemeValue] -> ShowS
$cshowList :: [ThemeValue] -> ShowS
show :: ThemeValue -> String
$cshow :: ThemeValue -> String
showsPrec :: Int -> ThemeValue -> ShowS
$cshowsPrec :: Int -> ThemeValue -> ShowS
Prelude.Show, forall x. Rep ThemeValue x -> ThemeValue
forall x. ThemeValue -> Rep ThemeValue x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep ThemeValue x -> ThemeValue
$cfrom :: forall x. ThemeValue -> Rep ThemeValue x
Prelude.Generic)

-- |
-- Create a value of 'ThemeValue' 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:
--
-- 'children', 'themeValue_children' - A list of key-value pairs that define the theme\'s properties.
--
-- 'value', 'themeValue_value' - The value of a theme property.
newThemeValue ::
  ThemeValue
newThemeValue :: ThemeValue
newThemeValue =
  ThemeValue'
    { $sel:children:ThemeValue' :: Maybe [ThemeValues]
children = forall a. Maybe a
Prelude.Nothing,
      $sel:value:ThemeValue' :: Maybe Text
value = forall a. Maybe a
Prelude.Nothing
    }

-- | A list of key-value pairs that define the theme\'s properties.
themeValue_children :: Lens.Lens' ThemeValue (Prelude.Maybe [ThemeValues])
themeValue_children :: Lens' ThemeValue (Maybe [ThemeValues])
themeValue_children = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ThemeValue' {Maybe [ThemeValues]
children :: Maybe [ThemeValues]
$sel:children:ThemeValue' :: ThemeValue -> Maybe [ThemeValues]
children} -> Maybe [ThemeValues]
children) (\s :: ThemeValue
s@ThemeValue' {} Maybe [ThemeValues]
a -> ThemeValue
s {$sel:children:ThemeValue' :: Maybe [ThemeValues]
children = Maybe [ThemeValues]
a} :: ThemeValue) forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | The value of a theme property.
themeValue_value :: Lens.Lens' ThemeValue (Prelude.Maybe Prelude.Text)
themeValue_value :: Lens' ThemeValue (Maybe Text)
themeValue_value = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\ThemeValue' {Maybe Text
value :: Maybe Text
$sel:value:ThemeValue' :: ThemeValue -> Maybe Text
value} -> Maybe Text
value) (\s :: ThemeValue
s@ThemeValue' {} Maybe Text
a -> ThemeValue
s {$sel:value:ThemeValue' :: Maybe Text
value = Maybe Text
a} :: ThemeValue)

instance Data.FromJSON ThemeValue where
  parseJSON :: Value -> Parser ThemeValue
parseJSON =
    forall a. String -> (Object -> Parser a) -> Value -> Parser a
Data.withObject
      String
"ThemeValue"
      ( \Object
x ->
          Maybe [ThemeValues] -> Maybe Text -> ThemeValue
ThemeValue'
            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
"children" forall a. Parser (Maybe a) -> a -> Parser a
Data..!= forall a. Monoid a => a
Prelude.mempty)
            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 ThemeValue where
  hashWithSalt :: Int -> ThemeValue -> Int
hashWithSalt Int
_salt ThemeValue' {Maybe [ThemeValues]
Maybe Text
value :: Maybe Text
children :: Maybe [ThemeValues]
$sel:value:ThemeValue' :: ThemeValue -> Maybe Text
$sel:children:ThemeValue' :: ThemeValue -> Maybe [ThemeValues]
..} =
    Int
_salt
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe [ThemeValues]
children
      forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe Text
value

instance Prelude.NFData ThemeValue where
  rnf :: ThemeValue -> ()
rnf ThemeValue' {Maybe [ThemeValues]
Maybe Text
value :: Maybe Text
children :: Maybe [ThemeValues]
$sel:value:ThemeValue' :: ThemeValue -> Maybe Text
$sel:children:ThemeValue' :: ThemeValue -> Maybe [ThemeValues]
..} =
    forall a. NFData a => a -> ()
Prelude.rnf Maybe [ThemeValues]
children
      seq :: forall a b. a -> b -> b
`Prelude.seq` forall a. NFData a => a -> ()
Prelude.rnf Maybe Text
value

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