website/frontend/src/Pages/Donate.elm

407 lines
10 KiB
Elm
Raw Normal View History

2024-11-28 19:28:24 -06:00
module Pages.Donate exposing (Model, Msg, page)
2024-12-09 19:53:09 -06:00
import Config.Data.Identity as I exposing (..)
2024-12-27 23:24:35 -06:00
import Config.Helpers.Cards.Inner.Helpers exposing (detailBodyMaker, detailFormat, detailFormatEl, detailTitleMaker, listItem, listMaker)
2024-12-27 01:30:21 -06:00
import Config.Helpers.Cards.Outer.Helpers exposing (cardMaker)
import Config.Helpers.Cards.Outer.Types as C
2024-12-15 02:31:26 -06:00
import Config.Helpers.Format
exposing
2024-12-18 20:11:04 -06:00
( headerFontSizeSmall
, paragraphFontSize
2024-12-15 02:31:26 -06:00
, paragraphSpacing
)
2024-12-22 04:36:03 -06:00
import Config.Helpers.Headers.Helpers exposing (..)
import Config.Helpers.Headers.Records exposing (donateHeader)
import Config.Helpers.Headers.Types as R exposing (..)
2024-12-24 03:08:39 -06:00
import Config.Helpers.ImageFolders as M exposing (..)
2024-12-11 03:48:49 -06:00
import Config.Helpers.Response
2024-12-09 20:30:04 -06:00
exposing
( pageList
, topLevelContainer
)
2024-12-15 02:31:26 -06:00
import Config.Helpers.StrengthBar
exposing
( barMaker
, barPadding
)
import Config.Helpers.ToolTip exposing (tooltip)
2024-12-09 19:53:09 -06:00
import Config.Helpers.Viewport exposing (..)
2024-12-15 02:31:26 -06:00
import Config.Pages.Donate.Records.Cardano exposing (donateCardano)
import Config.Pages.Donate.Records.KoFi exposing (donateKoFi)
import Config.Pages.Donate.Records.LiberaPay exposing (donateLiberaPay)
import Config.Pages.Donate.Records.Merch exposing (donateMerch)
import Config.Pages.Donate.Records.Patreon exposing (donatePatreon)
import Config.Pages.Donate.Records.PayPal exposing (donatePayPal)
import Config.Pages.Donate.Records.Stripe exposing (donateStripe)
import Config.Pages.Donate.Records.YouTube exposing (donateYouTube)
2024-12-09 19:53:09 -06:00
import Config.Pages.Donate.Types exposing (..)
2024-12-27 01:30:21 -06:00
import Config.Style.Colour.Helpers as T exposing (..)
2024-12-24 03:08:39 -06:00
import Config.Style.Images exposing (imageSquareMaker)
2024-11-28 19:28:24 -06:00
import Effect exposing (Effect)
2024-11-30 04:32:00 -06:00
import Element as E exposing (..)
2024-12-15 02:31:26 -06:00
import Element.Background as B
import Element.Border as D
import Element.Font as F
import Html.Attributes as H
2024-11-28 19:28:24 -06:00
import Layouts
import Page exposing (Page)
import Route exposing (Route)
import Shared exposing (..)
2024-12-03 04:59:27 -06:00
import Task
2024-11-28 19:28:24 -06:00
import View exposing (View)
page : Shared.Model -> Route () -> Page Model Msg
page shared route =
Page.new
{ init = init
, update = update
, subscriptions = subscriptions
, view = view shared
2024-11-28 19:28:24 -06:00
}
|> Page.withLayout toLayout
toLayout : Model -> Layouts.Layout Msg
toLayout model =
2024-12-06 22:03:24 -06:00
Layouts.Navbar {}
2024-11-28 19:28:24 -06:00
-- INIT
type alias Model =
{}
init : () -> ( Model, Effect Msg )
init () =
( {}
2024-12-03 04:59:27 -06:00
, Effect.map
(\_ -> NoOp)
(Effect.sendCmd resetViewport)
2024-11-28 19:28:24 -06:00
)
-- UPDATE
type Msg
= NoOp
update : Msg -> Model -> ( Model, Effect Msg )
update msg model =
case msg of
NoOp ->
( model
, Effect.none
)
-- SUBSCRIPTIONS
subscriptions : Model -> Sub Msg
subscriptions model =
Sub.none
-- VIEW
view : Shared.Model -> Model -> View Msg
view shared model =
2024-12-14 23:59:50 -06:00
{ title = pageNames.pageDonate
2024-11-28 19:28:24 -06:00
, attributes = []
, element = donateContainer shared.device
2024-11-28 19:28:24 -06:00
}
donateContainer : Device -> Element msg
donateContainer device =
topLevelContainer (donateList device)
2024-11-28 19:28:24 -06:00
donateList : Device -> Element msg
donateList device =
column
(case ( device.class, device.orientation ) of
2024-12-07 15:43:26 -06:00
_ ->
2024-12-22 19:42:23 -06:00
pageList device
)
<|
2024-12-01 02:56:13 -06:00
List.concat
2024-12-22 04:36:03 -06:00
[ [ headerMaker (R.Donate donateHeader) ]
, List.map
2024-12-21 23:23:59 -06:00
(\donate ->
cardMaker device (C.Donate donate) (contentList device donate)
)
2024-11-30 04:32:00 -06:00
[ donateLiberaPay
2024-12-09 03:06:20 -06:00
, donateStripe
2024-11-30 04:32:00 -06:00
, donatePatreon
, donateCardano
, donateKoFi
, donateYouTube
, donateMerch
]
2024-12-01 02:56:13 -06:00
]
2024-12-15 02:31:26 -06:00
contentList : Device -> Donate -> List (Element msg)
contentList device donate =
2024-12-24 03:08:39 -06:00
let
image : String -> Element msg
image size =
el
[ alignLeft
, alignTop
, paddingEach
{ top = 0
, right = 10
, bottom = 0
, left = 0
}
]
<|
imageSquareMaker device (imagePathMaker M.Donate donate.donateImage) True size
in
2024-12-27 23:24:35 -06:00
[ detailFormat row
[ image "Fatty"
, detailFormat column
2024-12-24 03:08:39 -06:00
[ feeMaker donate
, preferenceMaker donate
2024-12-27 23:24:35 -06:00
, tableMaker donate device
2024-12-24 03:08:39 -06:00
]
]
2024-12-27 23:24:35 -06:00
, proConMaker donate
]
2024-12-15 02:31:26 -06:00
feeMaker : Donate -> Element msg
feeMaker donate =
2024-12-27 23:24:35 -06:00
detailFormat row
[ detailTitleMaker TextLightOrange "Fees:"
, detailBodyMaker TextLightGrey (text donate.donateFees)
2024-12-15 02:31:26 -06:00
]
2024-12-27 23:24:35 -06:00
proConMaker : Donate -> Element msg
proConMaker donate =
detailFormat column
[ detailTitleMaker TextLightOrange "Pros:"
, listMaker makePro donate.donatePros
, detailTitleMaker TextLightOrange "Cons:"
, listMaker makeCon donate.donateCons
2024-12-15 02:31:26 -06:00
]
makePro : Pros -> Element msg
makePro pro =
2024-12-27 23:24:35 -06:00
listItem TextLightGrey pro.pro
2024-12-15 02:31:26 -06:00
makeCon : Cons -> Element msg
makeCon con =
2024-12-27 23:24:35 -06:00
listItem TextLightGrey con.con
2024-12-15 02:31:26 -06:00
preferenceMaker : Donate -> Element msg
preferenceMaker donate =
2024-12-27 23:24:35 -06:00
detailFormat row
[ el
[ tooltip
"This represents how strongly I prefer a given platform relative to other platforms."
2024-12-15 02:31:26 -06:00
]
2024-12-27 23:24:35 -06:00
<|
detailTitleMaker TextLightOrange "Preference:"
2024-12-15 02:31:26 -06:00
, barPadding
[ barMaker getPreferenceTooltip donate.donatePreference ]
]
getPreferenceTooltip : Int -> String
getPreferenceTooltip num =
case num of
0 ->
"Disdain this platform."
1 ->
"Very negative towards this platform."
2 ->
"Strongly dislike this platform."
3 ->
"Dislike this platform."
4 ->
"Somewhat dislike this platform."
5 ->
"Neutral, no strong feelings."
6 ->
"Somewhat like this platform."
7 ->
"Like this platform."
8 ->
"Strongly like this platform."
9 ->
"Very positive towards this platform."
10 ->
"Absolutely love this platform!"
_ ->
"Preference is out of bounds."
2024-12-18 20:11:04 -06:00
tableMaker : Donate -> Device -> Element msg
tableMaker donate device =
2024-12-27 23:24:35 -06:00
el
[ E.alignLeft
2024-12-15 02:31:26 -06:00
, E.width fill
2024-12-27 23:24:35 -06:00
, centerX
2024-12-15 02:31:26 -06:00
]
2024-12-27 23:24:35 -06:00
<|
E.table
([ spacing 0
, D.rounded 10
, D.width 2
, D.color colourTheme.textDarkGrey
, clip
]
++ (case ( device.class, device.orientation ) of
( Phone, Portrait ) ->
[ B.color colourTheme.backgroundSpreadsheet ]
( Tablet, Portrait ) ->
[ B.color colourTheme.backgroundSpreadsheet ]
_ ->
[]
)
)
{ data = donate.donateFeatures
, columns =
List.map createColumn
(case ( device.class, device.orientation ) of
( Phone, Portrait ) ->
mobileLabels
( Tablet, Portrait ) ->
mobileLabels
_ ->
desktopLabels
)
}
2024-12-15 02:31:26 -06:00
2024-12-18 20:11:04 -06:00
desktopLabels : List { label : String, getter : { a | free : b, subscriptions : b, userFriendly : b, anonymous : b, rewardTiers : b } -> b }
desktopLabels =
[ { label = "Zero Fees"
, getter = .free
}
, { label = "Subscriptions"
, getter = .subscriptions
}
, { label = "User Friendly"
, getter = .userFriendly
}
, { label = "Anonymous"
, getter = .anonymous
}
, { label = "Rewards"
, getter = .rewardTiers
}
]
mobileLabels : List { label : String, getter : { a | free : b, subscriptions : b, userFriendly : b, anonymous : b } -> b }
mobileLabels =
[ { label = "Free"
, getter = .free
}
, { label = "Subs"
, getter = .subscriptions
}
, { label = "Easy"
, getter = .userFriendly
}
, { label = "Safe"
, getter = .anonymous
}
]
2024-12-15 02:31:26 -06:00
createColumn : { label : String, getter : Features -> Maybe Bool } -> Column Features msg
createColumn { label, getter } =
{ header =
el
[ F.bold
, D.widthEach
{ bottom = 1
, top = 1
, left = 1
2024-12-22 04:36:03 -06:00
, right = 0
2024-12-15 02:31:26 -06:00
}
, D.color colourTheme.textDarkGrey
2024-12-27 23:24:35 -06:00
, padding 5
2024-12-15 02:31:26 -06:00
, E.width fill
, F.center
]
(text label)
|> el [ F.color colourTheme.textLightOrange ]
, width = fill
, view =
\feature ->
row
[ F.color colourTheme.textLightOrange
, F.bold
, D.widthEach
{ bottom = 1
, top = 0
, left = 1
2024-12-22 04:36:03 -06:00
, right = 0
2024-12-15 02:31:26 -06:00
}
, D.color colourTheme.textDarkGrey
2024-12-27 23:24:35 -06:00
, padding 5
2024-12-15 02:31:26 -06:00
, E.height fill
]
2024-12-27 23:24:35 -06:00
[ row
[ centerX
, centerY
]
2024-12-15 02:31:26 -06:00
[ paragraph []
[ E.image
[ E.width <| px 30
, E.height <| px 30
]
(featureToString (getter feature))
]
]
]
}
featureToString : Maybe Bool -> { src : String, description : String }
featureToString maybeBool =
case maybeBool of
Just True ->
{ src = "donate/checkmark.png", description = "" }
Just False ->
{ src = "donate/ex.png", description = "" }
Nothing ->
{ src = "donate/question.png", description = "" }