Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Assets #4 #5

Merged
merged 2 commits into from
Feb 14, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added assets/images/dwyl.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
84 changes: 77 additions & 7 deletions elm.js
Original file line number Diff line number Diff line change
Expand Up @@ -6013,7 +6013,6 @@ var $author$project$Main$update = F2(
}
});
var $elm$html$Html$a = _VirtualDom_node('a');
var $elm$html$Html$h1 = _VirtualDom_node('h1');
var $elm$json$Json$Encode$string = _Json_wrap;
var $elm$html$Html$Attributes$stringProperty = F2(
function (key, string) {
Expand All @@ -6022,12 +6021,32 @@ var $elm$html$Html$Attributes$stringProperty = F2(
key,
$elm$json$Json$Encode$string(string));
});
var $elm$html$Html$Attributes$class = $elm$html$Html$Attributes$stringProperty('className');
var $elm$html$Html$h1 = _VirtualDom_node('h1');
var $elm$html$Html$Attributes$href = function (url) {
return A2(
$elm$html$Html$Attributes$stringProperty,
'href',
_VirtualDom_noJavaScriptUri(url));
};
var $elm$html$Html$img = _VirtualDom_node('img');
var $author$project$Asset$Image = function (a) {
return {$: 'Image', a: a};
};
var $author$project$Asset$image = function (filename) {
return $author$project$Asset$Image('/assets/images/' + filename);
};
var $author$project$Asset$logo = $author$project$Asset$image('dwyl.png');
var $elm$html$Html$Attributes$src = function (url) {
return A2(
$elm$html$Html$Attributes$stringProperty,
'src',
_VirtualDom_noJavaScriptOrHtmlUri(url));
};
var $author$project$Asset$src = function (_v0) {
var url = _v0.a;
return $elm$html$Html$Attributes$src(url);
};
var $elm$virtual_dom$VirtualDom$text = _VirtualDom_text;
var $elm$html$Html$text = $elm$virtual_dom$VirtualDom$text;
var $author$project$Main$view = function (model) {
Expand All @@ -6042,18 +6061,39 @@ var $author$project$Main$view = function (model) {
$elm$html$Html$a,
_List_fromArray(
[
$elm$html$Html$Attributes$href('/auth')
$elm$html$Html$Attributes$href('/')
]),
_List_fromArray(
[
$elm$html$Html$text('login/signup')
A2(
$elm$html$Html$img,
_List_fromArray(
[
$author$project$Asset$src($author$project$Asset$logo),
$elm$html$Html$Attributes$class('center db pt2')
]),
_List_Nil)
])),
A2(
$elm$html$Html$h1,
_List_Nil,
_List_fromArray(
[
$elm$html$Html$Attributes$class('tc')
]),
_List_fromArray(
[
$elm$html$Html$text('Dwyl application')
])),
A2(
$elm$html$Html$a,
_List_fromArray(
[
$elm$html$Html$Attributes$href('/auth'),
$elm$html$Html$Attributes$class('tc db')
]),
_List_fromArray(
[
$elm$html$Html$text('login/signup')
]))
]);
case 'Auth':
Expand All @@ -6067,11 +6107,21 @@ var $author$project$Main$view = function (model) {
]),
_List_fromArray(
[
$elm$html$Html$text('home')
A2(
$elm$html$Html$img,
_List_fromArray(
[
$author$project$Asset$src($author$project$Asset$logo),
$elm$html$Html$Attributes$class('center db pt2')
]),
_List_Nil)
])),
A2(
$elm$html$Html$h1,
_List_Nil,
_List_fromArray(
[
$elm$html$Html$Attributes$class('tc')
]),
_List_fromArray(
[
$elm$html$Html$text('login page')
Expand All @@ -6081,8 +6131,28 @@ var $author$project$Main$view = function (model) {
return _List_fromArray(
[
A2(
$elm$html$Html$a,
_List_fromArray(
[
$elm$html$Html$Attributes$href('/')
]),
_List_fromArray(
[
A2(
$elm$html$Html$img,
_List_fromArray(
[
$author$project$Asset$src($author$project$Asset$logo),
$elm$html$Html$Attributes$class('center db pt2')
]),
_List_Nil)
])),
A2(
$elm$html$Html$h1,
_List_Nil,
_List_fromArray(
[
$elm$html$Html$Attributes$class('tc')
]),
_List_fromArray(
[
$elm$html$Html$text('page not found')
Expand Down
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="Description" content="DWYL application, built with Elm!">
<link rel="canonical" href="https://app-mvp-elm.herokuapp.com"/>
<link rel="stylesheet" href="https://unpkg.com/tachyons@4.10.0/css/tachyons.min.css"/>
</head>

<body>
Expand Down
23 changes: 23 additions & 0 deletions src/Asset.elm
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
module Asset exposing (Image, logo, src)

import Html exposing (Attribute)
import Html.Attributes as Attr


type Image
= Image String


logo : Image
logo =
image "dwyl.png"


image : String -> Image
image filename =
Image ("/assets/images/" ++ filename)


src : Image -> Attribute msg
src (Image url) =
Attr.src url
14 changes: 9 additions & 5 deletions src/Main.elm
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
module Main exposing (Page(..), main, routeParser)

import Asset
import Browser
import Browser.Navigation as Nav
import Html exposing (..)
Expand Down Expand Up @@ -94,15 +95,18 @@ view model =
, body =
case model.page of
Home ->
[ a [ href "/auth" ] [ text "login/signup" ]
, h1 [] [ text "Dwyl application" ]
[ a [ href "/" ] [ img [ Asset.src Asset.logo, class "center db pt2" ] [] ]
, h1 [ class "tc" ] [ text "Dwyl application" ]
, a [ href "/auth", class "tc db" ] [ text "login/signup" ]
]

Auth ->
[ a [ href "/" ] [ text "home" ]
, h1 [] [ text "login page" ]
[ a [ href "/" ] [ img [ Asset.src Asset.logo, class "center db pt2" ] [] ]
, h1 [ class "tc" ] [ text "login page" ]
]

NotFound ->
[ h1 [] [ text "page not found" ] ]
[ a [ href "/" ] [ img [ Asset.src Asset.logo, class "center db pt2" ] [] ]
, h1 [ class "tc" ] [ text "page not found" ]
]
}
18 changes: 18 additions & 0 deletions tests/AssetTests.elm
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
module AssetTests exposing (suite)

import Asset
import Expect exposing (Expectation)
import Fuzz exposing (Fuzzer, int, list, string)
import Html.Attributes as Attr
import Main exposing (..)
import Test exposing (..)


suite : Test
suite =
describe "test Asset module"
[ test "src logo is defined" <|
\_ ->
Asset.src Asset.logo
|> Expect.equal (Attr.src "/assets/images/dwyl.png")
]