{-# 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.FontSize
-- 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.FontSize 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.RelativeFontSize

-- | The option that determines the text display size.
--
-- /See:/ 'newFontSize' smart constructor.
data FontSize = FontSize'
  { -- | The lexical name for the text size, proportional to its surrounding
    -- context.
    FontSize -> Maybe RelativeFontSize
relative :: Prelude.Maybe RelativeFontSize
  }
  deriving (FontSize -> FontSize -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: FontSize -> FontSize -> Bool
$c/= :: FontSize -> FontSize -> Bool
== :: FontSize -> FontSize -> Bool
$c== :: FontSize -> FontSize -> Bool
Prelude.Eq, ReadPrec [FontSize]
ReadPrec FontSize
Int -> ReadS FontSize
ReadS [FontSize]
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [FontSize]
$creadListPrec :: ReadPrec [FontSize]
readPrec :: ReadPrec FontSize
$creadPrec :: ReadPrec FontSize
readList :: ReadS [FontSize]
$creadList :: ReadS [FontSize]
readsPrec :: Int -> ReadS FontSize
$creadsPrec :: Int -> ReadS FontSize
Prelude.Read, Int -> FontSize -> ShowS
[FontSize] -> ShowS
FontSize -> String
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [FontSize] -> ShowS
$cshowList :: [FontSize] -> ShowS
show :: FontSize -> String
$cshow :: FontSize -> String
showsPrec :: Int -> FontSize -> ShowS
$cshowsPrec :: Int -> FontSize -> ShowS
Prelude.Show, forall x. Rep FontSize x -> FontSize
forall x. FontSize -> Rep FontSize x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep FontSize x -> FontSize
$cfrom :: forall x. FontSize -> Rep FontSize x
Prelude.Generic)

-- |
-- Create a value of 'FontSize' 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:
--
-- 'relative', 'fontSize_relative' - The lexical name for the text size, proportional to its surrounding
-- context.
newFontSize ::
  FontSize
newFontSize :: FontSize
newFontSize = FontSize' {$sel:relative:FontSize' :: Maybe RelativeFontSize
relative = forall a. Maybe a
Prelude.Nothing}

-- | The lexical name for the text size, proportional to its surrounding
-- context.
fontSize_relative :: Lens.Lens' FontSize (Prelude.Maybe RelativeFontSize)
fontSize_relative :: Lens' FontSize (Maybe RelativeFontSize)
fontSize_relative = forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\FontSize' {Maybe RelativeFontSize
relative :: Maybe RelativeFontSize
$sel:relative:FontSize' :: FontSize -> Maybe RelativeFontSize
relative} -> Maybe RelativeFontSize
relative) (\s :: FontSize
s@FontSize' {} Maybe RelativeFontSize
a -> FontSize
s {$sel:relative:FontSize' :: Maybe RelativeFontSize
relative = Maybe RelativeFontSize
a} :: FontSize)

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

instance Prelude.Hashable FontSize where
  hashWithSalt :: Int -> FontSize -> Int
hashWithSalt Int
_salt FontSize' {Maybe RelativeFontSize
relative :: Maybe RelativeFontSize
$sel:relative:FontSize' :: FontSize -> Maybe RelativeFontSize
..} =
    Int
_salt forall a. Hashable a => Int -> a -> Int
`Prelude.hashWithSalt` Maybe RelativeFontSize
relative

instance Prelude.NFData FontSize where
  rnf :: FontSize -> ()
rnf FontSize' {Maybe RelativeFontSize
relative :: Maybe RelativeFontSize
$sel:relative:FontSize' :: FontSize -> Maybe RelativeFontSize
..} = forall a. NFData a => a -> ()
Prelude.rnf Maybe RelativeFontSize
relative

instance Data.ToJSON FontSize where
  toJSON :: FontSize -> Value
toJSON FontSize' {Maybe RelativeFontSize
relative :: Maybe RelativeFontSize
$sel:relative:FontSize' :: FontSize -> Maybe RelativeFontSize
..} =
    [Pair] -> Value
Data.object
      ( forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [(Key
"Relative" 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 RelativeFontSize
relative]
      )