website/frontend/src/Pages/Donate.elm

462 lines
11 KiB
Elm
Raw Normal View History

2024-11-28 19:28:24 -06:00
module Pages.Donate exposing (Model, Msg, page)
2025-01-02 02:33:57 -06:00
-- import Html.Attributes as H
import Config.Data.Identity exposing (pageNames)
import Config.Data.ImageFolders as M
exposing
( ImageFolder(..)
, imagePathMaker
)
import Config.Helpers.Cards.Inner.StrengthBar
exposing
( barMaker
, barPadding
)
import Config.Helpers.Cards.Inner.Text
2024-12-15 02:31:26 -06:00
exposing
2025-01-02 02:33:57 -06:00
( detailBodyMaker
, detailFormat
, detailTitleMaker
, listItem
, listMaker
2024-12-15 02:31:26 -06:00
)
2025-01-02 02:33:57 -06:00
import Config.Helpers.Cards.Inner.ToolTip exposing (tooltip)
import Config.Helpers.Cards.Outer.Helpers exposing (cardMaker)
import Config.Helpers.Cards.Outer.Types as C exposing (Cardable(..))
import Config.Helpers.Headers.Helpers exposing (headerMaker)
2024-12-22 04:36:03 -06:00
import Config.Helpers.Headers.Records exposing (donateHeader)
2025-01-02 02:33:57 -06:00
import Config.Helpers.Headers.Types as R exposing (Header)
2024-12-11 03:48:49 -06:00
import Config.Helpers.Response
2024-12-09 20:30:04 -06:00
exposing
( pageList
, topLevelContainer
)
2025-01-02 02:33:57 -06:00
import Config.Helpers.Viewport exposing (resetViewport)
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)
2025-01-02 02:33:57 -06:00
import Config.Pages.Donate.Types
exposing
( Cons
, Donate
, Features
, Pros
)
import Config.Style.Colour.Helpers as T
exposing
( ThemeColor(..)
, getThemeColor
)
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)
2025-01-02 02:33:57 -06:00
import Element as E
exposing
( Column
, Device
, DeviceClass(..)
, Element
, Orientation(..)
, alignLeft
, alignTop
, centerX
, centerY
, clip
, column
, el
, fill
, padding
, paddingEach
, paragraph
, px
, row
, spacing
, text
)
import Element.Background as B exposing (color)
2024-12-15 02:31:26 -06:00
import Element.Border as D
2025-01-02 02:33:57 -06:00
exposing
( color
, widthEach
)
2024-12-15 02:31:26 -06:00
import Element.Font as F
2025-01-02 02:33:57 -06:00
exposing
( bold
, center
, color
)
2024-11-28 19:28:24 -06:00
import Layouts
import Page exposing (Page)
import Route exposing (Route)
2025-01-02 02:33:57 -06:00
import Shared exposing (Model)
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 = []
2024-12-28 22:30:45 -06:00
, element = donateContainer shared
2024-11-28 19:28:24 -06:00
}
2024-12-28 22:30:45 -06:00
donateContainer : Shared.Model -> Element msg
donateContainer shared =
topLevelContainer (donateList shared)
2024-11-28 19:28:24 -06:00
2024-12-28 22:30:45 -06:00
donateList : Shared.Model -> Element msg
donateList shared =
column
2024-12-28 22:30:45 -06:00
(case ( shared.device.class, shared.device.orientation ) of
2024-12-07 15:43:26 -06:00
_ ->
2024-12-28 22:30:45 -06:00
pageList shared.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 ->
2024-12-28 22:30:45 -06:00
cardMaker shared.device (C.Donate donate) (contentList shared donate)
2024-12-21 23:23:59 -06:00
)
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
2024-12-28 22:30:45 -06:00
contentList : Shared.Model -> Donate -> List (Element msg)
contentList shared 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
}
]
<|
2024-12-28 22:30:45 -06:00
imageSquareMaker shared.device (imagePathMaker M.Donate donate.donateImage) True size
2024-12-24 03:08:39 -06:00
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
2024-12-28 22:30:45 -06:00
, preferenceMaker shared donate
, tableMaker donate shared.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
2024-12-28 22:30:45 -06:00
preferenceMaker : Shared.Model -> Donate -> Element msg
preferenceMaker shared donate =
2024-12-27 23:24:35 -06:00
detailFormat row
[ el
2024-12-28 22:30:45 -06:00
(if not shared.isNavbarExpanded then
[ tooltip
"This represents how strongly I prefer a given platform relative to other platforms."
2025-01-02 02:33:57 -06:00
True
2024-12-28 22:30:45 -06:00
]
else
[]
)
2024-12-27 23:24:35 -06:00
<|
2024-12-28 22:30:45 -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
2025-01-02 02:33:57 -06:00
, D.color (getThemeColor TextDarkGrey)
2024-12-27 23:24:35 -06:00
, clip
]
++ (case ( device.class, device.orientation ) of
( Phone, Portrait ) ->
2025-01-02 02:33:57 -06:00
[ B.color (getThemeColor BackgroundSpreadsheet) ]
2024-12-27 23:24:35 -06:00
( Tablet, Portrait ) ->
2025-01-02 02:33:57 -06:00
[ B.color (getThemeColor BackgroundSpreadsheet) ]
2024-12-27 23:24:35 -06:00
_ ->
[]
)
)
{ 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
}
2025-01-02 02:33:57 -06:00
, D.color (getThemeColor 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)
2025-01-02 02:33:57 -06:00
|> el [ F.color (getThemeColor TextLightOrange) ]
2024-12-15 02:31:26 -06:00
, width = fill
, view =
\feature ->
row
2025-01-02 02:33:57 -06:00
[ F.color (getThemeColor TextLightOrange)
2024-12-15 02:31:26 -06:00
, 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
}
2025-01-02 02:33:57 -06:00
, D.color (getThemeColor 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 = "" }