mirror of
https://gitlab.com/upRootNutrition/website.git
synced 2025-06-16 04:25:11 -05:00
feat: v1 finally done?
This commit is contained in:
parent
9f8d9c3146
commit
07b9330264
245 changed files with 3140 additions and 2197 deletions
|
@ -1,69 +1,115 @@
|
|||
module Pages.Debate.Arguments exposing (Model, Msg, page)
|
||||
|
||||
import Browser.Events as Events
|
||||
import Config.Data.Identity exposing (pageNames)
|
||||
import Config.Helpers.Cards.Inner.Helpers
|
||||
import Config.Data.ImageFolders as M
|
||||
exposing
|
||||
( argumentButton
|
||||
, bodyFormat
|
||||
( ImageFolder(..)
|
||||
, imagePathMaker
|
||||
)
|
||||
import Config.Helpers.Cards.Inner.StrengthBar exposing (barMaker)
|
||||
import Config.Helpers.Cards.Inner.Text
|
||||
exposing
|
||||
( bodyFormat
|
||||
, detailBodyLink
|
||||
, detailBodyMaker
|
||||
, detailFormat
|
||||
, detailSpacing
|
||||
, detailTitleMaker
|
||||
, generalButton
|
||||
, getHoverColours
|
||||
)
|
||||
import Config.Helpers.Cards.Inner.ToolTip exposing (tooltip)
|
||||
import Config.Helpers.Cards.Outer.Helpers exposing (cardMaker)
|
||||
import Config.Helpers.Cards.Outer.Types as C
|
||||
import Config.Helpers.Cards.Outer.Types as C exposing (Cardable(..))
|
||||
import Config.Helpers.Converters exposing (toTitleCase)
|
||||
import Config.Helpers.Format
|
||||
exposing
|
||||
( headerFontSizeSmall
|
||||
, paragraphFontSize
|
||||
, paragraphSpacing
|
||||
)
|
||||
import Config.Helpers.Headers.Helpers exposing (..)
|
||||
import Config.Helpers.Headers.Helpers exposing (headerMaker)
|
||||
import Config.Helpers.Headers.Records exposing (argumentHeader)
|
||||
import Config.Helpers.Headers.Types as R exposing (..)
|
||||
import Config.Helpers.ImageFolders as M exposing (..)
|
||||
import Config.Helpers.Headers.Types as R exposing (Headerable(..))
|
||||
import Config.Helpers.Response
|
||||
exposing
|
||||
( pageList
|
||||
, topLevelContainer
|
||||
)
|
||||
import Config.Helpers.StrengthBar
|
||||
exposing
|
||||
( barMaker
|
||||
, barPadding
|
||||
)
|
||||
import Config.Helpers.ToolTip exposing (tooltip)
|
||||
import Config.Helpers.Viewport exposing (resetViewport)
|
||||
import Config.Pages.Debate.Arguments.List
|
||||
exposing
|
||||
( argumentList
|
||||
)
|
||||
import Config.Pages.Debate.Arguments.Types exposing (..)
|
||||
import Config.Pages.Debate.Arguments.Types exposing (Argument)
|
||||
import Config.Style.Colour.Helpers
|
||||
exposing
|
||||
( ThemeColor(..)
|
||||
, colourTheme
|
||||
, getThemeColor
|
||||
)
|
||||
import Config.Style.Glow
|
||||
import Config.Style.Icons.Icons
|
||||
exposing
|
||||
( glowDeepDarkGrey
|
||||
, glowDeepDarkOrange
|
||||
( code
|
||||
, copyLink
|
||||
, thumbsDown
|
||||
)
|
||||
import Config.Style.Icons.Types as TySvg
|
||||
exposing
|
||||
( InnerPart
|
||||
, OuterPart
|
||||
)
|
||||
import Config.Style.Images exposing (imageSquareMaker)
|
||||
import Config.Style.Transitions exposing (transitionStyleSlow)
|
||||
import Effect exposing (Effect)
|
||||
import Element as E exposing (..)
|
||||
import Element.Background as B
|
||||
import Element as E
|
||||
exposing
|
||||
( Attribute
|
||||
, Device
|
||||
, DeviceClass(..)
|
||||
, Element
|
||||
, Orientation(..)
|
||||
, alignLeft
|
||||
, alignRight
|
||||
, alignTop
|
||||
, centerX
|
||||
, centerY
|
||||
, clip
|
||||
, column
|
||||
, el
|
||||
, fill
|
||||
, focused
|
||||
, height
|
||||
, htmlAttribute
|
||||
, maximum
|
||||
, none
|
||||
, paddingEach
|
||||
, paddingXY
|
||||
, paragraph
|
||||
, rgba
|
||||
, row
|
||||
, spacing
|
||||
, text
|
||||
, width
|
||||
)
|
||||
import Element.Background as B exposing (color)
|
||||
import Element.Border as D
|
||||
exposing
|
||||
( color
|
||||
, rounded
|
||||
, shadow
|
||||
)
|
||||
import Element.Font as F
|
||||
import Html exposing (div, hr)
|
||||
import Html.Attributes as H exposing (style, title, wrap)
|
||||
exposing
|
||||
( bold
|
||||
, center
|
||||
, color
|
||||
)
|
||||
import Element.Input as Input
|
||||
import Html.Attributes as H exposing (style)
|
||||
import Layouts
|
||||
import Page exposing (Page)
|
||||
import Ports
|
||||
import Process
|
||||
import Route exposing (Route)
|
||||
import Route.Path as Path
|
||||
import Shared
|
||||
import Svg.Attributes as SvgAttr
|
||||
import Task
|
||||
import View exposing (View)
|
||||
|
||||
|
||||
|
@ -88,12 +134,12 @@ toLayout model =
|
|||
|
||||
|
||||
type alias Model =
|
||||
{}
|
||||
{ hasBeenCopied : List Bool }
|
||||
|
||||
|
||||
init : () -> ( Model, Effect Msg )
|
||||
init () =
|
||||
( {}
|
||||
( { hasBeenCopied = List.repeat 51 False }
|
||||
, Effect.batch
|
||||
[ Effect.map
|
||||
(\_ -> NoOp)
|
||||
|
@ -108,12 +154,45 @@ init () =
|
|||
|
||||
|
||||
type Msg
|
||||
= NoOp
|
||||
= CopyText String Int
|
||||
| ResetCopyState Int
|
||||
| NoOp
|
||||
|
||||
|
||||
update : Msg -> Model -> ( Model, Effect Msg )
|
||||
update msg model =
|
||||
let
|
||||
urlLinkClickUpdate : Int -> Model
|
||||
urlLinkClickUpdate index =
|
||||
{ model
|
||||
| hasBeenCopied =
|
||||
List.take index model.hasBeenCopied
|
||||
++ (case List.head (List.drop index model.hasBeenCopied) of
|
||||
Just isCLicked ->
|
||||
[ not isCLicked ]
|
||||
|
||||
Nothing ->
|
||||
[]
|
||||
-- shouldn't happen
|
||||
)
|
||||
++ List.drop (index + 1) model.hasBeenCopied
|
||||
}
|
||||
in
|
||||
case msg of
|
||||
CopyText text index ->
|
||||
( urlLinkClickUpdate index
|
||||
, Effect.batch
|
||||
[ Effect.sendCmd (Ports.copyToClipboard text)
|
||||
, Effect.sendCmd (Process.sleep 700 |> Task.perform (\_ -> ResetCopyState index))
|
||||
]
|
||||
)
|
||||
|
||||
ResetCopyState index ->
|
||||
( urlLinkClickUpdate index
|
||||
-- wrong lol
|
||||
, Effect.none
|
||||
)
|
||||
|
||||
NoOp ->
|
||||
( model
|
||||
, Effect.none
|
||||
|
@ -137,17 +216,17 @@ view : Shared.Model -> Model -> View Msg
|
|||
view shared model =
|
||||
{ title = "debate (" ++ pageNames.pageArguments ++ ")"
|
||||
, attributes = []
|
||||
, element = debateContainer shared
|
||||
, element = debateContainer shared model
|
||||
}
|
||||
|
||||
|
||||
debateContainer : Shared.Model -> Element msg
|
||||
debateContainer shared =
|
||||
topLevelContainer (debateList shared)
|
||||
debateContainer : Shared.Model -> Model -> Element Msg
|
||||
debateContainer shared model =
|
||||
topLevelContainer (debateList shared model)
|
||||
|
||||
|
||||
debateList : Shared.Model -> Element msg
|
||||
debateList shared =
|
||||
debateList : Shared.Model -> Model -> Element Msg
|
||||
debateList shared model =
|
||||
column
|
||||
(case ( shared.device.class, shared.device.orientation ) of
|
||||
_ ->
|
||||
|
@ -156,16 +235,20 @@ debateList shared =
|
|||
<|
|
||||
List.concat
|
||||
[ [ headerMaker (R.Arguments argumentHeader) ]
|
||||
, List.map
|
||||
(\argument ->
|
||||
cardMaker shared.device (C.Argument argument) (contentList shared argument)
|
||||
, List.map3
|
||||
(\argument dummy index ->
|
||||
cardMaker shared.device
|
||||
(C.Argument argument)
|
||||
(contentList shared model dummy index argument)
|
||||
)
|
||||
argumentList
|
||||
model.hasBeenCopied
|
||||
(List.range 0 (List.length argumentList))
|
||||
]
|
||||
|
||||
|
||||
contentList : Shared.Model -> Argument -> List (Element msg)
|
||||
contentList shared argument =
|
||||
contentList : Shared.Model -> Model -> Bool -> Int -> Argument -> List (Element Msg)
|
||||
contentList shared model isLinkClicked index argument =
|
||||
let
|
||||
image : String -> Element msg
|
||||
image size =
|
||||
|
@ -223,18 +306,67 @@ contentList shared argument =
|
|||
, formalizationMaker shared.device argument
|
||||
, el [ alignRight ] <|
|
||||
row [ width fill, spacing 20 ]
|
||||
[ argumentButton (Path.toString Path.Contact_Criticism) "Reject Premise"
|
||||
, argumentButton argument.proofLink "Proof Tree"
|
||||
[ generalButton shared (Path.toString Path.Contact_Criticism) thumbsDown
|
||||
, generalButton shared argument.proofLink code
|
||||
, copyButton shared model isLinkClicked index argument
|
||||
]
|
||||
]
|
||||
|
||||
|
||||
copyButton : Shared.Model -> Model -> Bool -> Int -> Argument -> Element Msg
|
||||
copyButton shared model isLinkClicked index argument =
|
||||
Input.button
|
||||
[ focused
|
||||
[ D.color (rgba 0 0 0 0)
|
||||
, D.shadow { blur = 0, color = rgba 0 0 0 0, offset = ( 0, 0 ), size = 0 }
|
||||
]
|
||||
]
|
||||
{ onPress = Just (CopyText ("https://uprootnutrition.com" ++ Path.toString Path.Debate_Arguments ++ "#" ++ argument.argumentImage) index)
|
||||
, label =
|
||||
el
|
||||
(if isLinkClicked then
|
||||
[ transitionStyleSlow
|
||||
, tooltip "Copied!" False
|
||||
, case ( shared.device.class, shared.device.orientation ) of
|
||||
( Phone, Portrait ) ->
|
||||
B.color (getThemeColor BackgroundDarkGrey)
|
||||
|
||||
( Tablet, Portrait ) ->
|
||||
B.color (getThemeColor BackgroundDarkGrey)
|
||||
|
||||
_ ->
|
||||
B.color (getThemeColor BackgroundDeepDarkGrey)
|
||||
, paddingXY 7 7
|
||||
, D.rounded 10
|
||||
, F.color (getThemeColor TextLightOrange)
|
||||
]
|
||||
|
||||
else
|
||||
[ transitionStyleSlow
|
||||
, B.color (getThemeColor Transparent)
|
||||
, paddingXY 7 7
|
||||
, D.rounded 10
|
||||
, F.color (getThemeColor TextLightOrange)
|
||||
]
|
||||
++ getHoverColours TextLightOrange
|
||||
)
|
||||
<|
|
||||
copyLink
|
||||
{ elementAttributes =
|
||||
[]
|
||||
, sharedModel = shared
|
||||
, svgAttributes = [ SvgAttr.width "20" ]
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
strengthMaker : Shared.Model -> Element msg
|
||||
strengthMaker shared =
|
||||
el
|
||||
(if not shared.isNavbarExpanded then
|
||||
[ tooltip
|
||||
"This represents my confidence in the soundness of the argument."
|
||||
"This represents how pleasant the host was to engage with."
|
||||
True
|
||||
]
|
||||
|
||||
else
|
||||
|
@ -303,15 +435,15 @@ tableMaker device argument =
|
|||
E.table
|
||||
([ D.rounded 10
|
||||
, D.width 2
|
||||
, D.color colourTheme.textDarkGrey
|
||||
, D.color (getThemeColor TextDarkGrey)
|
||||
, clip
|
||||
]
|
||||
++ (case ( device.class, device.orientation ) of
|
||||
( Phone, Portrait ) ->
|
||||
[ B.color colourTheme.backgroundSpreadsheet ]
|
||||
[ B.color (getThemeColor BackgroundSpreadsheet) ]
|
||||
|
||||
( Tablet, Portrait ) ->
|
||||
[ B.color colourTheme.backgroundSpreadsheet ]
|
||||
[ B.color (getThemeColor BackgroundSpreadsheet) ]
|
||||
|
||||
_ ->
|
||||
[]
|
||||
|
@ -328,7 +460,7 @@ tableMaker device argument =
|
|||
, left = 1
|
||||
, right = 1
|
||||
}
|
||||
, D.color colourTheme.textDarkGrey
|
||||
, D.color (getThemeColor TextDarkGrey)
|
||||
, cellPadding
|
||||
, E.width fill
|
||||
]
|
||||
|
@ -346,7 +478,7 @@ tableMaker device argument =
|
|||
, left = 1
|
||||
, right = 1
|
||||
}
|
||||
, D.color colourTheme.textDarkGrey
|
||||
, D.color (getThemeColor TextDarkGrey)
|
||||
, cellPadding
|
||||
, E.height fill
|
||||
]
|
||||
|
@ -366,7 +498,7 @@ tableMaker device argument =
|
|||
, left = 0
|
||||
, right = 1
|
||||
}
|
||||
, D.color colourTheme.textDarkGrey
|
||||
, D.color (getThemeColor TextDarkGrey)
|
||||
, cellPadding
|
||||
, E.width fill
|
||||
]
|
||||
|
@ -382,7 +514,7 @@ tableMaker device argument =
|
|||
, left = 0
|
||||
, right = 1
|
||||
}
|
||||
, D.color colourTheme.textDarkGrey
|
||||
, D.color (getThemeColor TextDarkGrey)
|
||||
, cellPadding
|
||||
, E.height fill
|
||||
]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue