Skip to content

Commit 7bab229

Browse files
committed
fix discord url bug i think
1 parent f71cce2 commit 7bab229

File tree

5 files changed

+63
-37
lines changed

5 files changed

+63
-37
lines changed

src/Main.elm

Lines changed: 27 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ main =
2424

2525
init : () -> Url -> Nav.Key -> ( Model, Cmd Msg )
2626
init _ url key =
27-
( { route = ( Route.fromUrl url )
27+
( { route = Route.fromUrl url
2828
, key = key
2929
}
30-
, Cmd.none
30+
, Cmd.none
3131
)
3232

3333

@@ -47,10 +47,19 @@ update : Msg -> Model -> ( Model, Cmd Msg )
4747
update msg model =
4848
case msg of
4949
ChangedUrl url ->
50-
( { route = (Route.fromUrl url)
51-
, key = model.key }
52-
, Cmd.none
53-
)
50+
let
51+
route =
52+
Route.maybeFromUrl url
53+
in
54+
case route of
55+
Nothing ->
56+
( { route = Route.Home, key = model.key }, Cmd.none )
57+
58+
Just Discord ->
59+
( model, Nav.load (Route.routeToString Route.Discord) )
60+
61+
Just other ->
62+
( { route = other, key = model.key }, Cmd.none )
5463

5564
ClickedLink request ->
5665
case request of
@@ -70,6 +79,7 @@ update msg model =
7079
)
7180

7281

82+
7383
-- SUBSCRIPTIONS
7484

7585

@@ -85,12 +95,16 @@ subscriptions _ =
8595
view : Model -> Document Msg
8696
view model =
8797
let
88-
page = case model.route of
89-
Home ->
90-
Page.view Page.Home ( Home.view { key = model.key } )
98+
page =
99+
case model.route of
100+
Home ->
101+
Page.view Page.Home (Home.view { key = model.key })
91102

92-
Rules ->
93-
Page.view Page.Rules ( Rules.view { key = model.key } )
94-
in
95-
{ title = page.title, body = List.map ( Html.map (\_ -> NewPage) ) page.body }
103+
Rules ->
104+
Page.view Page.Rules (Rules.view { key = model.key })
96105

106+
Discord ->
107+
-- default to home, this should never happen
108+
Page.view Page.Home (Home.view { key = model.key })
109+
in
110+
{ title = page.title, body = List.map (Html.map (\_ -> NewPage)) page.body }

src/Page.elm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,12 @@ navbarLink page route name =
4040
a (Route.href route :: deselected) [ text name ]
4141

4242

43-
selected : List ( Attribute msg )
43+
selected : List (Attribute msg)
4444
selected =
4545
[ Tw.font_bold, Tw.rounded_2xl, Tw.px_3, Tw.py_1, Tw.bg_gradient_to_r, Tw.from_blue_700, Tw.to_pink_700, Tw.text_gray_50 ]
4646

4747

48-
deselected : List ( Attribute msg )
48+
deselected : List (Attribute msg)
4949
deselected =
5050
[ Tw.hover__bg_gray_300, Tw.rounded_2xl, Tw.px_3, Tw.py_1, Tw.ease_in_out, Tw.duration_300 ]
5151

src/Route.elm

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
module Route exposing (Route(..), fromUrl, href)
1+
module Route exposing (Route(..), fromUrl, href, maybeFromUrl, routeToString)
22

33
import Html exposing (Attribute)
44
import Html.Attributes as Attr
@@ -9,13 +9,15 @@ import Url.Parser as Parser exposing ((</>), Parser, oneOf)
99
type Route
1010
= Home
1111
| Rules
12+
| Discord
1213

1314

1415
parser : Parser (Route -> a) a
1516
parser =
1617
oneOf
1718
[ Parser.map Home Parser.top
1819
, Parser.map Rules (Parser.s "rules")
20+
, Parser.map Discord (Parser.s "discord")
1921
]
2022

2123

@@ -24,10 +26,15 @@ href target =
2426
Attr.href (routeToString target)
2527

2628

29+
maybeFromUrl : Url -> Maybe Route
30+
maybeFromUrl url =
31+
Parser.parse parser url
32+
33+
2734
fromUrl : Url -> Route
2835
fromUrl url =
29-
case ( Parser.parse parser url ) of
30-
(Just route) ->
36+
case Parser.parse parser url of
37+
Just route ->
3138
route
3239

3340
Nothing ->
@@ -47,3 +54,6 @@ routeToPieces route =
4754

4855
Rules ->
4956
[ "rules" ]
57+
58+
Discord ->
59+
[ "discord" ]

src/Views/Home.elm

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -24,34 +24,36 @@ view _ =
2424
[ h1 [ Tw.text_center, Tw.text_9xl, class "horta" ] [ text "Developer Den" ]
2525
, h2 [ Tw.text_center, Tw.font_titillium, Tw.text_2xl, Tw.py_4 ] [ text "A closely-knit community anchored in a common passion for programming." ]
2626
, div [ Tw.py_7 ]
27-
[ a [ href discordURL, Tw.bg_indigo_500, Tw.text_2xl, Tw.p_5, Tw.rounded_2xl, Tw.shadow_md, Tw.hover__bg_indigo_600, Tw.ease_in_out, Tw.duration_300 ]
28-
[ button [ Tw.font_titillium, Tw.font_bold ]
29-
[ i [ Tw.px_1, Tw.pr_3, class "fab fa-discord" ] []
30-
, text "Interested? Join our Discord!" ]
31-
]
32-
]
27+
[ a [ href discordURL, Tw.bg_indigo_500, Tw.text_2xl, Tw.p_5, Tw.rounded_2xl, Tw.shadow_md, Tw.hover__bg_indigo_600, Tw.ease_in_out, Tw.duration_300 ]
28+
[ button [ Tw.font_titillium, Tw.font_bold ]
29+
[ i [ Tw.px_1, Tw.pr_3, class "fab fa-discord" ] []
30+
, text "Interested? Join our Discord!"
31+
]
32+
]
33+
]
3334
, div [ Tw.inline_flex, Tw.flex_row, Tw.ml_5, Tw.mt_5 ]
34-
[ projectOf [ ] "web frontend" "the frontend website that you're viewing now that is written in elm and tailwind css" "https://github.com/TheDeveloperDen/devden-web-frontend"
35-
, projectOf [ ] "discord bot" "the discord bot that manages many aspects of our discord server (ex. xp, leaderboards)" "https://github.com/TheDeveloperDen/DevDenBot"
36-
, projectOf [ ] "learning resources" "a repository containing crowd-sourced information on how to learn different languages" "https://github.com/TheDeveloperDen/LearningResources"
35+
[ projectOf [] "web frontend" "the frontend website that you're viewing now that is written in elm and tailwind css" "https://github.com/TheDeveloperDen/devden-web-frontend"
36+
, projectOf [] "discord bot" "the discord bot that manages many aspects of our discord server (ex. xp, leaderboards)" "https://github.com/TheDeveloperDen/DevDenBot"
37+
, projectOf [] "learning resources" "a repository containing crowd-sourced information on how to learn different languages" "https://github.com/TheDeveloperDen/LearningResources"
3738
]
3839
, div [ Tw.absolute, Tw.bottom_5, Tw.right_5, Tw.flex, Tw.flex_row, Tw.space_x_1, Tw.rounded_xl, Tw.py_2, Tw.px_2, Tw.bg_gray_200, Tw.shadow_md ]
39-
[ a [ href discordURL ] [ button (class "hover:bg-indigo-500 hover:text-white" :: buttonStyles) [ i [ Tw.px_1, class "fab fa-discord" ] [] ] ]
40-
, a [ href githubURL ] [ button (class "hover:bg-gray-900 hover:text-white" :: buttonStyles) [ i [ Tw.px_1, class "fab fa-github" ] [] ] ]
41-
]
40+
[ a [ href discordURL ] [ button (class "hover:bg-indigo-500 hover:text-white" :: buttonStyles) [ i [ Tw.px_1, class "fab fa-discord" ] [] ] ]
41+
, a [ href githubURL ] [ button (class "hover:bg-gray-900 hover:text-white" :: buttonStyles) [ i [ Tw.px_1, class "fab fa-github" ] [] ] ]
42+
]
4243
]
4344
}
4445

46+
4547
projectOf : List (Attribute Msg) -> String -> String -> String -> Html Msg
4648
projectOf attr name desc url =
47-
div attr [ fieldset [ Tw.p_3, Tw.border_gray_300, Tw.border_2, Tw.border_opacity_50, Tw.m_5, Tw.rounded_2xl, Tw.shadow_md, Tw.w_auto ]
48-
[ legend [ Tw.px_1_dot_5, Tw.py_0, Tw.hover__bg_gray_200, Tw.rounded_2xl, Tw.duration_300, Tw.ease_in_out ]
49+
div attr
50+
[ fieldset [ Tw.p_3, Tw.border_gray_300, Tw.border_2, Tw.border_opacity_50, Tw.m_5, Tw.rounded_2xl, Tw.shadow_md, Tw.w_auto ]
51+
[ legend [ Tw.px_1_dot_5, Tw.py_0, Tw.hover__bg_gray_200, Tw.rounded_2xl, Tw.duration_300, Tw.ease_in_out ]
4952
[ a [ href url, Tw.font_poppins, Tw.font_bold, Tw.hover__text_black, Tw.p_0_dot_5, Tw.duration_300, Tw.ease_in_out ] [ text name ] ]
50-
, p [ Tw.font_titillium, Tw.break_words ] [ text desc ]
51-
]
53+
, p [ Tw.font_titillium, Tw.break_words ] [ text desc ]
5254
]
55+
]
56+
5357

5458
buttonStyles =
5559
[ Tw.font_titillium, Tw.rounded_full, Tw.text_black, Tw.font_semibold, Tw.py_2, Tw.px_2, Tw.transform, Tw.transition, Tw.duration_300, Tw.ease_in_out ]
56-
57-

src/Views/Rules.elm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ ruleHeader body =
6060
ruleLine text =
6161
h4 [ Tw.pl_8, Tw.font_titillium, Tw.text_lg ] text
6262

63+
6364
inlineLink : String -> String -> Html Msg
6465
inlineLink val link =
6566
a [ Tw.text_indigo_300, Tw.underline, Tw.hover__text_blue_500, Tw.duration_300, Tw.ease_in_out, href link ] [ text val ]
66-

0 commit comments

Comments
 (0)