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

Add "header" region #264

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
10 changes: 8 additions & 2 deletions src/Element/Region.elm
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
module Element.Region exposing
( mainContent, navigation, heading, aside, footer
( header, mainContent, navigation, heading, aside, footer
, description
, announce, announceUrgently
)
Expand All @@ -19,7 +19,7 @@ Here's an example of annotating your navigation region:
[-- ..your navigation links
]

@docs mainContent, navigation, heading, aside, footer
@docs header, mainContent, navigation, heading, aside, footer

@docs description

Expand All @@ -31,6 +31,12 @@ import Element exposing (Attribute)
import Internal.Model as Internal exposing (Description(..))


{-| -}
header : Attribute msg
header =
Internal.Describe Header


{-| -}
mainContent : Attribute msg
mainContent =
Expand Down
4 changes: 4 additions & 0 deletions src/Internal/Model.elm
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ type TransformComponent

type Description
= Main
| Header
| Navigation
-- | Search
| ContentInfo
Expand Down Expand Up @@ -1122,6 +1123,9 @@ gatherAttrRecursive classes node has transform styles attrs children elementAttr
Main ->
gatherAttrRecursive classes (addNodeName "main" node) has transform styles attrs children remaining

Header ->
gatherAttrRecursive classes (addNodeName "header" node) has transform styles attrs children remaining

Navigation ->
gatherAttrRecursive classes (addNodeName "nav" node) has transform styles attrs children remaining

Expand Down
43 changes: 43 additions & 0 deletions tests-rendering/cases/Manual/Regions.elm
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
module Tests.Manual.Regions exposing (..)

import Browser
import Element exposing (..)
import Element.Region as Region
import Html
import Html.Attributes


type alias Model =
{}


init : () -> ( Model, Cmd Msg )
init flags =
( {}, Cmd.none )


type Msg
= NoOp


update msg model =
case msg of
NoOp ->
( model, Cmd.none )


header =
el [ Region.header ] (el [ Region.heading 1 ] (text "This is a h1 in a header"))


view model =
Element.layout [] (Element.column [] [ header ])


main =
Browser.element
{ init = init
, view = view
, update = update
, subscriptions = \_ -> Sub.none
}